Coder Social home page Coder Social logo

blm-instagram-bot's Introduction

blm-instagram-bot

Instagram bot that informs users using the BlackLivesMatter tag to post solid images that they may be accidentally hiding important information about the movement. Demonstration 1 Demonstration 2

Uses a Google Cloud Function called blm-cloud-function to determine if the image is a solid black image. This is to offload the image processing to the cloud and hopefully keep things running smooth.

Setup

You need Python 3 and pip. On Ubuntu: sudo apt install python3-dev python3-pip will get you there. You will use python3 and pip3 in place of pip and python, unless you override which the default is with your $PATH variable.

  1. Create a burner account or two. Edit accounts.json to include their login information.
  2. Edit the bios to include relevant information. Example
  3. Run pip install -r requirements.txt. If you are not on Windows, comment out the lines with pywin32 and pypiwin32.
  4. Rename .env.example to .env
  5. Run python3 bot.py. If you get a missing module error, python3 -m pip install -r requirements.txt and try again.

To-Do

  1. Poll the tag. Right now it only goes through the current posts and stops.

Make sure to rename .env.example to .env Also make sure you're using Python 3.5 or greater.

blm-instagram-bot's People

Contributors

baecon avatar cchriso avatar dependabot[bot] avatar esayles avatar jeffreylo avatar kraj011 avatar leoyoshinaga avatar mathematicalmichael avatar mehdichekori avatar user24 avatar voidstar0 avatar xeloader avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blm-instagram-bot's Issues

Enhancement: Scaling with Celery

I saw that you mentioned looking for assistance with scaling. Using a distributed computing library to assign work to a group of "worker" nodes would be a nice way to implement this. I'm familiar with a Python library called Celery that does just that. The main question is how to set up a release distribution that enables individuals to spin up their own workers easily on whatever computing resources they have available.

Additionally, I imagine querying for and detecting image matches is the most computationally expensive task in this project. With this in mind, a distributed system will require a way to designate "chunks of work" to individual instances/nodes so that repeat queries are avoided where possible.

I'll look deeper into the code to see if this can be easily accomplished with the current setup.

Rate Limited

Not sure if this issue is solely with my implementation but for some reason I am constantly being given the "rate limited" error message, along with an index error from the line of code "post = feed['items'].pop(0).

Use smallest image from image_versions2

Currently the bot is just picking out the zeroth element:

url = post['image_versions2']['candidates'][0]['url']

But it would be more efficient if we sorted by size and picked the smallest image to send to the detection API.

I've done this in JS (am working on a node version bc I don't know python) but in the meantime if someone wants to port this to python I think this would be an improvement:

const smallestImage = item.image_versions2.candidates.sort((a, b) => a.width * a.height > b.width * b.height).pop();

#BlackoutTuesday getting merged into #BlackLivesMatter?

I've heard some anecdotal reports that Instagram is merging the two hashtags. Does it make sense to change the script of the comment to urge people to post links to local bail funds, mutual aid organizations, protest groups, NAACP chapters, etc?

TODO: Detection method for black photos

Currently the logic checks if all pixels in all channels are below 20.

How well is this working? If it's fine, keep it.

If you want to do something else, here are some suggestions based on my experience with image processing:

Take the average pixel value across all channels. Threshold it to <5. That way, even small blips of white that may be there will get washed out in the process of averaging. From what I understand, having a single pixel of (255,255,255) right now would prevent the logic from returning True (I'm not native to JS but that's my understanding from the cloudfunction repo's index.js).

Take the median. Same logic.

Sum all three channels, divide by 3. If the proportion of pixels below (5,5,5) exceeds 95% / 99%, mark it as solid.

JPEG compression really in theory shouldn't be leaving artifacts in all-black images. But if someone clips just a bit of white in there, we want to be able to catch that.

change default message

current message assumes info in bio. needs to be more general, point to a specific account (blm_tag_bot)

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.