Comments (2)
main.py
import os
from instabot import Bot
import argparse
import time
import threading
import random
import sys
import cv2
import json
import random
import faceai
class Bots:
def face_detection(username):
x = 0
''' Get user media and scan it for a face'''
user_id = bot.get_user_id_from_username(username)
medias = bot.get_user_medias(user_id, filtration=False)
for media in medias:
while x < 1:
try:
bot.logger.info(media)
path = bot.download_photo(media, folder=username)
img = cv2.imread(path)
faceai.face_detection(img)
if not detect:
bot.logger.info("no face detected")
x += 1
elif detect:
bot.logger.info("there was a face detected")
bot.api.like(media)
display_url = bot.get_link_from_media_id(media)
bot.logger.info("liked " + display_url + " by " + username)
x += 1
else:
x += 1
except Exception as e:
bot.logger.info(e)
x += 1
def face_detection_comment(username, comment):
x = 0
''' Get user media and scan it for a face'''
user_id = bot.get_user_id_from_username(username)
medias = bot.get_user_medias(user_id, filtration=False)
for media in medias:
while x < 1:
try:
bot.logger.info(media)
path = bot.download_photo(media, folder=username)
img = cv2.imread(path)
detector = MTCNN()
detect = detector.detect_faces(img)
if not detect:
bot.logger.info("no face detected")
x += 1
elif detect:
bot.logger.info("there was a face detected")
bot.api.comment(media, comment)
does_exist = bot.get_media_comments(media, only_text=True)
if str(username) in does_exist:
x += 1
print("image has been commented")
else:
display_url = bot.get_link_from_media_id(media)
bot.logger.info("commented " + display_url + " by " + username)
x += 1
else:
x += 1
except Exception as e:
bot.logger.info(e)
x += 1
def like_followers(username, time_sleep):
user_id = bot.get_user_id_from_username(username)
followers = bot.get_user_followers(user_id)
for user in followers:
pusername = bot.get_username_from_user_id(user)
Bots.face_detection(pusername)
time.sleep(int(time_sleep))
def like_following(username, time_sleep):
user_id = bot.get_user_id_from_username(username)
following = bot.get_user_following(user_id)
for user in following:
pusername = bot.get_username_from_user_id(user)
Bots.face_detection(pusername)
time.sleep(int(time_sleep))
def like_hashtags(hashtag, time_sleep):
hashtags = bot.get_hashtag_users(hashtag)
for user in hashtags:
pusername = bot.get_username_from_user_id(user)
Bots.face_detection(pusername)
time.sleep(int(time_sleep))
def comment(hashtag, comment, time_sleep):
hashtags = bot.get_hashtag_users(hashtag)
for user in hashtags:
pusername = bot.get_username_from_user_id(user)
Bots.face_detection_comment(pusername, comment)
time.sleep(int(time_sleep))
#try:
# input = raw_input
#except NameError:
# pass
COOKIES = {}
bot = Bot()
parser = argparse.ArgumentParser(add_help=True)
parser.add_argument('-u', type=str, help="username")
parser.add_argument('-p', type=str, help="password")
parser.add_argument('-proxy', type=str, help="proxy")
args = parser.parse_args()
username = str(args.u)
# Check if user cookie exist
#bot.login(username=args.u, password=args.p, proxy=args.proxy, use_cookie=True)
# Check if user cookie exist
if __name__ == '__main__':
bot.login(username=args.u, password=args.p, proxy=args.proxy)
faceai.py
from mtcnn.mtcnn import MTCNN
detector = MTCNN()
def face_detection(img):
detect = detector.detect_faces(img)
return detect
`
from mtcnn.
The error does not happen if i comment out
from mtcnn.mtcnn import MTCNN
from mtcnn.
Related Issues (20)
- Can i rewrite the structure of Pnet or Rnet on factory.py? or i need retraining them
- Error with tf-nightly-gpu 2.5.0.dev20201207
- How do I install on Ubuntu 18.04?
- Memory leak from mtcnn
- Performance is not what it could be HOT 1
- Please release the newest version to Pypi HOT 1
- cannot import name 'get_config' from 'tensorflow.python.eager.context' HOT 2
- Evaluation Metrics for the default model weights
- AttributeError: module 'keras.utils.generic_utils' has no attribute 'to_snake_case'
- Error in importing
- AttributeError: module 'keras.utils.generic_utils' has no attribute 'populate_dict_with_module_objects'
- Get wrong detected face
- PyTorch : unable to load the dataset HOT 2
- Disable progress bars? HOT 14
- mtcnn: self.thresholds, self.nms_thresholds,self.factor What does it mean? How do I tweak it? HOT 1
- CPU allocation for some of the computational tensors
- process is killed automatically HOT 2
- How to download datasets? HOT 1
- Prevent mtcnn logging HOT 4
- Cannot import mtcnn!! because of ImportError "most likely due to a circular import" HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mtcnn.