Git Product home page Git Product logo

Comments (2)

steffanjensen avatar steffanjensen commented on August 17, 2024

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.

steffanjensen avatar steffanjensen commented on August 17, 2024

The error does not happen if i comment out
from mtcnn.mtcnn import MTCNN

from mtcnn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.