A set of Python scripts for cutting out segments from videos containing specified faces. These segments can be uploaded to the permaweb using the permaweb_uploader.py. The system uses face detection and face recognition implemented in PyTorch.
This project was created as a part of gitcoin contest organized by Arweave.
-
Clone the project:
git clone https://github.com/benesjan/video-presence-tracker.git
-
Enter the directory and install the dependencies:
cd video-presence-tracker pip install -r requirements.txt
-
Create a dataset with identities to track. The data has to be in the standard format:
- dataset
- name1
- image1.jpg
- image2.jpg
- image3.jpg
- name2
- image1.jpg
- image2.jpg
- ...
- name1
Each image has to contain exactly one face. If the face is not detected in any of the images corresponding to the identity, new images will have to be provided.
- dataset
-
Set the DATASET constant in the config.py file aiming at the dataset root folder.
-
Finally, execute the setup.py script:
python ./setup.py
This command downloads the model weights and computes representative feature vectors from the provided dataset.
-
To process a specific video, run the following command:
python ./process_video.py --display-video --video-path path/to/video.mp4
If the --display-video flag is present, the video will be displayed in a window as it is processed.
-
The track_yt_channel.py continually processes new videos uploaded to a YouTube channel specified by the CHANNEL_ID. To execute the script run the command bellow:
python ./track_yt_channel.py --display-video --channel-id CHANNEL_ID --yt-api-key API_KEY
To obtain the CHANNEL_ID go to this site and enter the channel name. The get the YouTube API key read the Data API documentation.
-
To upload the videos to permaweb install the arweave CLI:
npm i arweave-deploy
-
And run the permaweb_uploader:
python ./permaweb_uploader.py --arweave-key path/to/arweave-keyfile.json
The script will check for new videos every few minutes and uploads them to the permaweb.
Every transaction has two or more tags:
-
A tag with the feed name:
Feed-Name:VideoPresenceTracker
-
A tag or multiple tags (there can be multiple tracked identities in the video) with identities, e.g:
Donald_Trump:1
The tag value is always set to 1
Concrete example how to query the data from VideoPresenceTracker feed is available at example_query.py.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.