DeepTuner
Description
DeepTuner is an open source Python package for fine-tuning computer vision (CV) based deep models. It supports multiple architectures including Siamese Networks with triplet loss and ArcFace with additive angular margin loss. The package provides various model backbones, data preprocessing tools, and evaluation metrics.
Installation
To install the package, use the following command:
pip install DeepTuner
Usage
Training with ArcFace
DeepTuner now supports ArcFace training with additive angular margin loss, which is particularly effective for face recognition tasks:
from deeptuner.backbones.resnet import ResNetBackbone
from deeptuner.losses.arcface_loss import ArcFaceModel, arcface_loss
from deeptuner.datagenerators.arcface_generator import ArcFaceDataGenerator
# Create data generators
train_generator = ArcFaceDataGenerator(
data_dir='path/to/train/data',
batch_size=32,
image_size=(224, 224),
augment=True
)
# Create backbone and ArcFace model
backbone = ResNetBackbone(input_shape=(224, 224, 3))
backbone_model = backbone.create_model()
model = ArcFaceModel(
backbone=backbone_model,
num_classes=num_classes,
embedding_dim=512,
margin=0.5,
scale=64.0
)
# Compile and train
model.compile(
optimizer='adam',
loss=arcface_loss(),
metrics=['accuracy']
)
model.fit(
train_generator.create_dataset(is_training=True),
epochs=50
)
Fine-tuning Models with Siamese Architecture and Triplet Loss
For similarity learning tasks, you can use the Siamese architecture with triplet loss:
from deeptuner.backbones.resnet import ResNetBackbone
from deeptuner.architectures.siamese import SiameseArchitecture
from deeptuner.losses.triplet_loss import triplet_loss
from deeptuner.datagenerators.triplet_data_generator import TripletDataGenerator
# Create data generators
train_generator = TripletDataGenerator(
train_paths, train_labels,
batch_size=32,
image_size=(224, 224),
num_classes=num_classes
)
# Create Siamese network
backbone = ResNetBackbone(input_shape=(224, 224, 3))
embedding_model = backbone.create_model()
siamese_architecture = SiameseArchitecture(
input_shape=(224, 224, 3),
embedding_model=embedding_model
)
siamese_network = siamese_architecture.create_siamese_network()
# Train the model
model.compile(optimizer='adam', loss=triplet_loss(margin=0.5))
model.fit(train_generator, epochs=50)
Features
- Multiple architectures:
- Siamese Networks with triplet loss
- ArcFace with additive angular margin loss
- Various backbone models:
- ResNet
- EfficientNet
- MobileNet
- Specialized data generators:
- TripletDataGenerator for Siamese networks
- ArcFaceDataGenerator for ArcFace training
- Training utilities:
- Fine-tuning callbacks
- Learning rate scheduling
- Wandb integration for experiment tracking
Configuration
You can use a configuration file (e.g., JSON) to store hyperparameters. Example config for ArcFace:
{
"data_dir": "path/to/data",
"image_size": [224, 224],
"batch_size": 32,
"epochs": 50,
"learning_rate": 0.001,
"patience": 5,
"unfreeze_layers": 10,
"embedding_dim": 512,
"arcface_margin": 0.5,
"arcface_scale": 64.0
}
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for deeptuner 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| deeptuner-0.2.0.tar.gz | 15.4 kB | Without provenance | Details for deeptuner-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| deeptuner-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for deeptuner-0.2.0-py3-none-any.whl |
Total release size: 33.2 kB
Release files / deeptuner-0.2.0.tar.gz
| Download URL | deeptuner-0.2.0.tar.gz |
|---|---|
| Size | 15.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8e7f7f28980597e99bc1d5fda7b41f47fe5f41fc6123685abe7c1af1959377be
|
|
BLAKE2b-256 checksum How to use checksums |
39eb8e13d4b5395384345c57ba7644ce07a6ecfe3fd6c62e3ed2c33eab597dfa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / deeptuner-0.2.0-py3-none-any.whl
| Download URL | deeptuner-0.2.0-py3-none-any.whl |
|---|---|
| Size | 17.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1978ad5c586d4560b56dfef2e7bb7d9a6fd97cda144484e049f308b49fbea703
|
|
BLAKE2b-256 checksum How to use checksums |
c939440d20609d5063f90d36ddadf2a98fb1768f84c02124b14b7b956659e43a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Security for deeptuner 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.