This project is a tribute to Pokimane, a popular content creator on Twitter. The goal of this project is to scrape images from Pokimane's Twitter account, classify the emotions in those images, and serve them through a Node.js server.
The repository has the following structure:
.gitignoreEmotion Classifier/emotions.pymodel.h5
File Hasher/hash_filenames.pyscraped_duplicate_remover.py
Node/index.jspackage.json
Scraper/twitter_scraper.py
LICENSEImmages/scraped/to_sort/sorted/display/
The repository consists of several scripts that perform specific tasks:
-
The
twitter_scraper.pyscript is used to scrape tweets from Pokimane's Twitter account. The scraped images are stored in the/Images/scrapeddirectory. -
The scraped images are then transferred from the
/Images/scrapeddirectory to the/Images/to_sortdirectory. -
The
scraped_duplicate_remover.pyscript is run to remove any duplicate images in the/Images/to_sortdirectory. It uses a sha256 hash of the images to compare and identify duplicates. -
The
emotions.pyscript is used to classify the emotions in the images. It utilizes a CNN model trained on emotion detection. The script uses face recognition to locate faces in the images, extracts the pixels within those coordinates, resizes them to 48x48 pixels, and passes them through the trained model. The emotions detected are then appended to the filenames of the sorted images in the/Images/sorteddirectory. -
The
hash_filenames.pyscript generates SHA256 hashes for the filenames in the/Images/sorteddirectory. The hashed filenames are saved in the format[emotion]_[sha256hash].jpg. -
The Node.js server is started by running the
index.jsfile in theNodedirectory. The server serves the processed images located in the/Images/displaydirectory. It uses Express.js and provides endpoints to access the images.
To use this repository, follow these steps:
-
Set up the environment by installing the required dependencies. You can find the dependencies in the
package.jsonfile in the Node directory. -
Run the
Scraper/twitter_scraper.pyscript to scrape tweets from Pokimane's Twitter account and store the images in the/Images/scrapeddirectory. -
Transfer the scraped images from the
/Images/scrapeddirectory to the/Images/to_sortdirectory. -
Run the
File Hasher/scraped_duplicate_remover.pyscript to remove any duplicate images in the/Images/to_sortdirectory. -
Run the
Emotion Classifier/emotions.pyscript to classify the emotions in the images using the trained model (Emotion Classifier/model.h5). The emotions will be appended to the filenames of the sorted images in the/Images/sorteddirectory. -
Run the
File Hasher/hash_filenames.pyscript to generate SHA256 hashes for the filenames in the/Images/sorteddirectory. The hashed filenames will be saved in the format[emotion]_[sha256hash].jpg. -
Start the Node.js server by running the
Node/index.jsfile. The server will serve the processed images located in the/Images/displaydirectory. -
Access the served images through the server's endpoint, e.g.,
http://localhost:8081/.
Please note that you may need to adjust the paths and configurations in the scripts according to your system setup.
This project is licensed under the MIT License.
