This toolkit is designed to assist in the analysis and comparison of media files distributed across various campaigns. It includes utilities for extracting media files, generating embeddings, and computing similarities between campaigns on a day-wise basis or through average clip/blip/convnext model embeddings.
- Media File Extraction: Unzips archive files containing media and stores all JPEG and PNG filenames.
- Embedding Generation: Creates embeddings for image files listed in a specific text file for further analysis.
- Campaign Similarity Analysis: Calculates the similarity between campaigns based on the average clip model embeddings of shared images.
- Day-wise Similarity Matrix: Computes a matrix representing day-wise similarity between two campaigns.
Clone this repository to your local machine using:
git clone <repository-url>Ensure you have Python 3.8 or later installed.
-
Extract Media Files
To extract media files from zipped archives and generate a list of all JPEG and PNG files, run:
python extract.py
This will create a
filenames.txtfile containing the paths to all extracted JPEG and PNG files. -
Generate Embeddings
Before calculating similarities, you need to generate embeddings for your images:
python run_clip.py
or
python run_blip2.py
or
python run_convnext.py
Make sure
filenameslist.txtcontains the paths to the images you wish to process. -
KMeans on campaigns
Creating Kmeans clusters for a given campaign
python taiwan_kmeans.py
-
Campaign Similarity Analysis
To calculate the similarity between the average model embeddings of images from two campaigns, run:
python campaign-sim.py
-
Day-wise Similarity Matrix
For computing a day-wise similarity matrix between two campaigns, use:
python hk-day.py