In this project, we utilize the CelebA dataset, a well-known dataset for exploring facial attributes.
You can train Siamese Network with SupConLoss very easily, just run the following code
python train.py --partition_path <...> --identity_path <...> --dataset_dir <...>
with
--dataset_dir
: Path of your dataset directory, which contains images.--partition_path
: Path to partition file for splitting the dataset into train/val/test sets.--identity_path
: Path to identity file for labeling your images (image belongs to specific celebrity)
Besides these parameters, you also have various other parameters as well for you to adjust.
In this project, because of the lack of resources, we only use 1 positive per anchor image (more details in dataset.py), you can also try to increase the number of positives per anchor image and increase batch size for better performance.
To create embedding vectors for your dataset, run the following code
python embedding.py --dataset-dir <...> --model-weights <...> --fname <...>
with
--dataset-dir
: Name of your dataset directory.--model-weights
: Model checkpoint.--fname
: Name of embedding file, file.h5
Example
python embedding.py --dataset-dir ./img_dataset --model-weights ./model.pt --fname face_vecs
python cbir_system.py
TaiQuach123 |
QuangTruong-Nguyen |
hari-huynh |