Skip to content

ch9968/triplet_loss_intern

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

nabla-dna

Image fingerprinting system combining gradient-based feature extraction (C) with metric learning (Python / Keras).

About

Codebase from an undergraduate ML research internship. The original system was developed by the research lab; this repository preserves the implementation I worked with for portfolio reference. The project explores image fingerprinting via two complementary pipelines:

  1. Classical pipeline (C + Python) — Uses nabla (gradient) operators on bitmap images to derive feature histograms.
  2. Deep learning pipeline — MobileNet backbone + Dense embedding layer trained with triplet loss to produce a 64-dimensional image fingerprint ("DNA").

Two embeddings can then be compared via cosine similarity for image retrieval and matching tasks.

Tech Stack

Layer Technology
Native processing C, CMake
Numerical / image NumPy, Pillow, SciPy
Deep learning TensorFlow / Keras, MobileNet
Metric learning Triplet loss (margin = 0.4, embedding dim = 64)

Project Structure

nabla-dna-master/
├── CMakeLists.txt          # Builds the `mkdna` C executable
├── src/mkdna/              # C source: bitmap → DNA fingerprint
├── python/                 # Python toolchain (BMP, histogram, distance, sobel, ...)
│   ├── mkdna.py            # Python driver
│   ├── nbmp.py, sobel.py, histo.py
│   ├── dist.py, getdist.py, dist_histo.py
│   └── ...
└── DL-DNA/                 # Deep learning pipeline
    ├── dl_dna.py           # CLI entry point
    ├── dl_dna_model.py     # Abstract model base + cosine similarity
    ├── triplet_model.py    # Triplet-loss MobileNet (anchor / positive / negative)
    ├── mobilenet.py        # Plain MobileNet baseline
    └── lineEnumerator.py

Build

Native (C)

cd nabla-dna-master
mkdir build && cd build
cmake ..
make            # produces the `mkdna` executable

Deep learning pipeline

cd nabla-dna-master/DL-DNA
pip install -r requirements.txt

Usage (DL pipeline)

# Train with triplet loss, save the trained model
python dl_dna.py -m triplet_loss -t triples.txt -s model.keras -f images/

# Get the embedding for a single image
python dl_dna.py -l model.keras some_image_name

# Compute cosine similarity between two images
python dl_dna.py -l model.keras image_a image_b

# Compute similarities for a batch (pairs file)
python dl_dna.py -l model.keras pairs.txt

Environment variables: N_UNITS, IMAGE_FOLDER, EPOCHS.

Notes

This repository is a snapshot of the codebase from the internship and is preserved here for portfolio reference. Module naming and architecture reflect the original lab conventions.

About

Image fingerprinting with triplet loss metric learning. Codebase from undergraduate ML research internship.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors