Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.8%) to scientific vocabulary
Last synced: 6 months ago · JSON representation ·

Repository

Basic Info
  • Host: GitHub
  • Owner: fabariagbora
  • Language: Python
  • Default Branch: main
  • Size: 13.5 MB
Statistics
  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created 8 months ago · Last pushed 8 months ago
Metadata Files
Readme Citation

README.md

🏷️ Logo Few-Shot Learning & Self-Supervised Invariance

Project Title:
Cross-Domain Logo Recognition with Prototypical Networks and Self-Supervised Invariance Validation


📌 Project Summary

This project implements a pipeline for few-shot learning (FSL) on logo images using Prototypical Networks, combined with self-supervised learning (SSL) to validate feature invariance properties.
It demonstrates how rotation and domain invariance scores relate to few-shot classification performance, using both t-SNE/UMAP visualizations and correlation plots.

The goal:
Evaluate whether self-supervised rotation invariance signals correlate with how well logos generalize across domains (register ↔ product).


📂 Directory Structure

bash logo_fsl_ssl/ ├── data │ ├── raw/ │ │ ├── product_annotations_train_split.csv # Not used for this research. But useful if the research goal is domain adaptation instead of domain generalization │ │ ├── product_annotations_val_split.csv # Used for cross-domain evaluation in evaluate_product.py │ │ ├── register_tm_train_split.csv # Used for model training in train_few_shot.py │ │ ├── register_tm_val_split.csv # Used for in-domain evaluation in evaluate_register.py ├── datasets/ # Logo dataset loader, few-shot sampler │ ├── logo_fsl_dataset.py # Loads registration & product splits │ ├── few_shot_sampler.py # Dynamically builds FSL tasks ├── models/ # Encoder (ResNet18) + Prototypical Head │ ├── logo_encoder.py # ResNet-based feature extractor │ ├── prototypical_head.py # Computes class prototypes ├── scripts/ # All run scripts │ ├── ssl_validate.py # Computes SSL scores (rotation, domain) │ ├── evaluate_product.py # Runs few-shot cross-domain evaluation (product) │ ├── evaluate_register.py # Runs few-shot in-domain evaluation (register) │ ├── visualize_embeddings.py # t-SNE / UMAP embeddings │ ├── plot_ssl_correlation.py # Correlation plots │ ├── plot_domain_correlation.py # domain Correlation plots │ ├── plot_results.py # results plots │ ├── preprocess_register_and_product.py # downloads and preprocesses images │ ├── save_summary.py # saves a summary of the results │ ├── test_logo_dataset.py # tests if labels are properly extracted during preprocessing │ ├── train_few_shot.py # trains the registration dataset. The output is model weights in checkpoints ├── checkpoints/ # Model weights (use .gitignore for large files) ├── results/ # CSVs, plots, summaries ├── data/processed/ # ⚠️ Not versioned — add your data ├── README.md # This file └── .gitignore # Large data / zips excluded

⚙️ Installation & Setup

1️⃣ Clone the repository

bash git clone https://github.com/fabariagbora/logo_fsl_ssl/ cd logo_fsl_ssl

2️⃣ Create a Python environment

Example using Conda: bash conda create -n logo-fsl python=3.10 conda activate logo-fsl

Or virtualenv: bash python -m venv venv source venv/bin/activate

3️⃣ Install dependencies

Create a requirements.txt if not already done: torch>=1.13 torchvision numpy pandas scikit-learn umap-learn matplotlib tqdm Pillow

Install: bash pip install -r requirements.txt

📁 Add Your Data

Use data/raw or add your data

Your processed logo dataset should be in: data/processed/

bash ├── register/val/<mark_id>/*.jpg ├── product/val/<mark_id>/*.jpg ⚠️ This folder is not pushed to GitHub — it stays local.

🚀 How to Run

✅ Step 1 — Run Preprocessor

bash python scripts/preprocess_register_and_product.py

Creates: - Downloaded images from URL links. - Cropped logos using gt_annotation bounding box from the product dataset.

Handles: - Encoding errors (utf-8). - Download progress using tqdm

Saved in data/processed/

✅ Step 2 — Run Few-Shot Training

bash python scripts/train_few_shot.py

Creates: - model weights in checkpoints/

No training on product data to ensure true domain generalization.

✅ Step 3 — Run few-shot evaluations

bash python scripts/evaluate_product.py python scripts/evaluate_register.py

Creates: - results/productperclass.csv - results/registerperclass.csv - results/evalproduct.txt - results/evalregister.txt

Records csv and txt outputs in results/

✅ Step 4 — Run SSL validators

bash python scripts/ssl_validate.py

Creates: - results/sslrotation.csv - results/ssldomain.csv - results/ssl_summary.txt

✅ Step 5 — Generate correlation plots

bash python scripts/plot_ssl_correlation.py

Creates: - results/sslrotationvsfewshotproduct.png - results/sslrotationvsfewshotregister.png - results/ssl_correlation.csv # ⬅️ Save the Pearson r values too!

✅ Step 6 — Visualize embeddings

bash python scripts/visualize_embeddings.py

Creates: - results/tsneregister.png - results/umapregister.png - results/tsneproduct.png - results/umapproduct.png

📊 Example Metrics

  • Product domain few-shot accuracy: ~82.68%
  • Register domain few-shot accuracy: varies by run & split
  • SSL rotation invariance: saved per class
  • Correlation: Pearson r shows how well invariance aligns with few-shot performance.

🚫 What's NOT Pushed to Git

To keep the repo lightweight: - Large processed data → data/processed/ - Large zipped files → *.zip - Checkpoints (optionally use Git LFS)

Example .gitignore: ```bash

Ignore data & archives

data/processed/ *.zip checkpoints/ ```

📝 License

MIT License Feel free to adapt, reuse, and build on this work.

📚 Citation

This project uses the following open dataset.
If you build on this work or use the dataset, please cite the original authors:

bibtex @software{Zhao_Open_set_cross_2025, author = {Zhao, Xiaonan and Li, Chenge and Liu, Zongyi and Feng, Yarong and Chen, Qipin}, month = feb, title = {{Open set cross domain few shot logo recognition}}, url = {https://github.com/wacv2025-image-quality-workshop2/cross-domain-logo-recognition}, version = {1.0.4}, year = {2025} }

✨ Acknowledgements

  • Inspired by standard Prototypical Networks (https://arxiv.org/abs/1703.05175) Snell et al.
  • Self-supervised methods inspired by SimCLR, BYOL, and basic SSL invariance tests.

🧑‍💻 Maintainer

Fabari Agbora
Data Scientist at Nepsix Technology Limited
📧 agfabariagbora@gmail.com

🗂️ Future Work

  • Experiment with other SSL tasks (jigsaw, colorization)
  • Try additional backbones (ViT, ConvNeXt)
  • Publish a cleaned dataset & benchmark config

✅✅✅ Happy few-shot learning!

If you use this, please ⭐️ the repo and open an issue if you find bugs or improvements.

Owner

  • Login: fabariagbora
  • Kind: user
  • Company: @skitpay

I build products that people love

Citation (citation.cff)

## Citation

This project uses the following open dataset.  
If you build on this work or use the dataset, please cite the original authors:

```bibtex
@software{Zhao_Open_set_cross_2025,
  author  = {Zhao, Xiaonan and Li, Chenge and Liu, Zongyi and Feng, Yarong and Chen, Qipin},
  month   = feb,
  title   = {{Open set cross domain few shot logo recognition}},
  url     = {https://github.com/wacv2025-image-quality-workshop2/cross-domain-logo-recognition},
  version = {1.0.4},
  year    = {2025}
}

GitHub Events

Total
  • Push event: 1
Last Year
  • Push event: 1

Dependencies

requirements.txt pypi
  • Automat ==20.2.0
  • Babel ==2.8.0
  • Brotli ==1.0.9
  • Glances ==3.2.4.2
  • Jinja2 ==3.0.3
  • Markdown ==3.3.6
  • MarkupSafe ==2.0.1
  • Pillow ==9.0.1
  • PyGObject ==3.42.1
  • PyHamcrest ==2.0.2
  • PyJWT ==2.3.0
  • PyYAML ==5.4.1
  • Pygments ==2.11.2
  • SecretStorage ==3.3.1
  • Twisted ==22.1.0
  • Werkzeug ==2.0.2
  • absl-py ==2.1.0
  • appdirs ==1.4.4
  • argcomplete ==1.8.1
  • astunparse ==1.6.3
  • attrs ==21.2.0
  • backcall ==0.2.0
  • bcrypt ==3.2.0
  • beautifulsoup4 ==4.10.0
  • beniget ==0.4.1
  • bleach ==4.1.0
  • blinker ==1.4
  • bottle ==0.12.19
  • certifi ==2020.6.20
  • cffi ==1.15.0
  • chardet ==4.0.0
  • click ==8.0.3
  • cloud-init ==24.4.1
  • colorama ==0.4.4
  • command-not-found ==0.3
  • commonmark ==0.9.1
  • configobj ==5.0.6
  • constantly ==15.1.0
  • cryptography ==3.4.8
  • ctop ==1.0.0
  • cycler ==0.11.0
  • dbus-python ==1.2.18
  • decorator ==4.4.2
  • defusedxml ==0.7.1
  • distlib ==0.3.4
  • distro ==1.7.0
  • distro-info ==1.1
  • docker ==5.0.3
  • entrypoints ==0.4
  • filelock ==3.6.0
  • flake8 ==4.0.1
  • flatbuffers ===1.12.1
  • fonttools ==4.29.1
  • fs ==2.4.12
  • fsspec ==2024.3.1
  • future ==0.18.2
  • gast ==0.5.2
  • google-pasta ==0.2.0
  • grpcio ==1.30.2
  • h5py ==3.6.0
  • h5py.-debian-h5py-serial ==3.6.0
  • html5lib ==1.1
  • httplib2 ==0.20.2
  • hyperlink ==21.0.0
  • icdiff ==2.0.4
  • idna ==3.3
  • importlib-metadata ==4.6.4
  • incremental ==21.3.0
  • influxdb ==5.3.1
  • iotop ==0.6
  • ipykernel ==6.7.0
  • ipython ==7.31.1
  • ipython_genutils ==0.2.0
  • jax ==0.5.1
  • jax-cuda12-pjrt ==0.5.1
  • jax-cuda12-plugin ==0.5.1
  • jaxlib ==0.5.1
  • jedi ==0.18.0
  • jeepney ==0.7.1
  • joblib ==0.17.0
  • jsonpatch ==1.32
  • jsonpointer ==2.0
  • jsonschema ==3.2.0
  • jupyter-client ==7.1.2
  • jupyter-core ==4.9.1
  • kaptan ==0.5.12
  • keras ==3.6.0
  • keyring ==23.5.0
  • kiwisolver ==1.3.2
  • launchpadlib ==1.10.16
  • lazr.restfulclient ==0.14.4
  • lazr.uri ==1.0.6
  • libtmux ==0.10.1
  • livereload ==2.6.3
  • lxml ==4.8.0
  • lz4 ==3.1.3
  • matplotlib ==3.5.1
  • matplotlib-inline ==0.1.3
  • mccabe ==0.6.1
  • mkdocs ==1.1.2
  • ml-dtypes ==0.5.0
  • more-itertools ==8.10.0
  • mpmath ==0.0.0
  • msgpack ==1.0.3
  • namex ==0.0.8
  • nest-asyncio ==1.5.4
  • netifaces ==0.11.0
  • networkx ==2.4
  • numpy ==1.21.5
  • nvidia-ml-py ==12.555.43
  • oauthlib ==3.2.0
  • olefile ==0.46
  • opt-einsum ==3.3.0
  • optree ==0.13.1
  • packaging ==21.3
  • pandas ==1.3.5
  • parso ==0.8.1
  • pexpect ==4.8.0
  • pickleshare ==0.7.5
  • pipx ==1.0.0
  • platformdirs ==2.5.1
  • ply ==3.11
  • prompt-toolkit ==3.0.28
  • protobuf ==4.21.12
  • psutil ==5.9.0
  • ptyprocess ==0.7.0
  • py ==1.10.0
  • pyOpenSSL ==21.0.0
  • pyasn1 ==0.4.8
  • pyasn1-modules ==0.2.1
  • pycodestyle ==2.8.0
  • pycparser ==2.21
  • pycryptodomex ==3.11.0
  • pyflakes ==2.4.0
  • pyinotify ==0.9.6
  • pyparsing ==2.4.7
  • pyrsistent ==0.18.1
  • pyserial ==3.5
  • pysmi ==0.3.2
  • pysnmp ==4.4.12
  • pystache ==0.6.0
  • python-apt ==2.4.0
  • python-dateutil ==2.8.1
  • python-magic ==0.4.24
  • pythran ==0.10.0
  • pytz ==2022.1
  • pyzmq ==22.3.0
  • requests ==2.25.1
  • rich ==11.2.0
  • scikit-learn ==0.23.2
  • scipy ==1.8.0
  • service-identity ==18.1.0
  • six ==1.16.0
  • sos ==4.7.2
  • soupsieve ==2.3.1
  • ssh-import-id ==5.11
  • sympy ==1.12
  • tensorboard ==2.18.0
  • tensorflow ==2.18.0
  • termcolor ==1.1.0
  • threadpoolctl ==3.1.0
  • tmuxp ==1.9.2
  • torch ==2.6.0
  • torchvision ==0.21.0
  • tornado ==6.1
  • tqdm ==4.67.1
  • traitlets ==5.1.1
  • triton ==3.2.0
  • typing_extensions ==4.10.0
  • ufoLib2 ==0.13.1
  • ufw ==0.36.1
  • unattended-upgrades ==0.1
  • unicodedata2 ==14.0.0
  • urllib3 ==1.26.5
  • userpath ==1.8.0
  • virtualenv ==20.13.0
  • wadllib ==1.3.6
  • wcwidth ==0.2.5
  • webencodings ==0.5.1
  • websocket-client ==1.2.3
  • wrapt ==1.13.3
  • zipp ==1.0.0
  • zope.interface ==5.4.0