TinyNet-A Image Classification
Classify images into 1,000 ImageNet categories with the compact TinyNet-A convolutional neural network.
TinyNet-A Image Classification
Classify images into 1,000 ImageNet categories with the compact TinyNet-A convolutional neural network.
Summary
- Introduction
- Parameters
- Example
- Usage for developers
- Project structure
- Limitations
- References
- Citation
- License
Introduction
This repository packages timm/tinynet_a.in1k for the AIOZ AI Node runtime. TinyNet-A was trained on ImageNet-1k and is designed to balance input resolution, network depth, and network width under a small computational budget.
Model characteristics:
- Task: image classification
- Architecture: TinyNet-A
- Dataset: ImageNet-1k
- Parameters: approximately 6.2 million
- Compute: approximately 0.3 GMACs per image
- Activations: approximately 5.4 million
- Input size:
192 x 192pixels - Output classes: 1,000
All model artifacts are loaded from models/image_classification. Inference does not download model weights from the network.
Parameters
Input
input_image(image/string, required): Local image path or HTTP(S) image URL. JPEG, PNG, WebP, and BMP images are supported by the playground contract.top_k(integer, optional): Number of ranked predictions to return, from 1 to 1,000. The default is 5.device(string, optional):cpu,cuda, orgpu. An unavailable CUDA device falls back to CPU.model_storage_directory(string, optional): Parent directory containingimage_classification. AIOZ supplies this value at runtime.
Output
output(JSON string): A ranked array of objects withclass_index, human-readablelabel, andscore. Scores are softmax probabilities in the range[0, 1].
Example
[
{
"class_index": 281,
"label": "tabby, tabby cat",
"score": 0.73451234
},
{
"class_index": 282,
"label": "tiger cat",
"score": 0.12876543
}
]
The values above illustrate the response format; actual predictions depend on the input image.
Usage for developers
Requirements
- Python 3.10 or newer
- Git LFS for the model checkpoints
- A CUDA-capable GPU is optional
Fetch LFS objects if the repository was cloned without them, then install the dependencies:
git lfs pull
pip install -r requirements.txt
Run the demo
python demo.py path/to/image.jpg --top-k 5 --device cpu
An HTTP(S) image URL can be used in place of a local path.
Use the AIOZ entry point
import my_ai_lib
from aioz_ainode_adapter.schemas import InputObject
input_obj = InputObject(
input_image="path/to/image.jpg",
top_k=5,
device="cpu",
model_storage_directory="models",
)
output_obj = my_ai_lib.run(input_obj)
print(output_obj.output)
The public API is my_ai_lib.run(input_obj). Task-specific schemas and inference logic live in my_ai_lib/run.py as MyInput, MyOutput, do_ai_task, and run.
Project structure
.
├── aioz_ainode_adapter/
│ ├── __init__.py
│ ├── adapter.py
│ ├── common.py
│ ├── schemas.py
│ ├── utils.py
│ └── version.py
├── models/
│ └── image_classification/
│ ├── config.json
│ ├── model.safetensors
│ └── pytorch_model.bin
├── my_ai_lib/
│ ├── __init__.py
│ └── run.py
├── demo.py
├── LICENSE
├── README.md
└── requirements.txt
model.safetensors is the preferred checkpoint. pytorch_model.bin is retained as a compatibility fallback from the original model distribution.
Limitations
- Predictions are limited to the 1,000 ImageNet-1k categories and may not describe out-of-domain content accurately.
- Softmax scores are ranking confidences, not calibrated probabilities.
- Small or highly cropped objects may lose detail when transformed to the model's
192 x 192input. - Remote images are limited to 20 MB and require network access; local paths work offline.
References
- TinyNet-A source model
- Model Rubik's Cube: Twisting Resolution, Depth and Width for TinyNets
- PyTorch Image Models (
timm)
The TinyNet definitions and weights distributed through timm originate from the TinyNet authors' work. Attribution to the TinyNet authors and to timm is preserved below.
Citation
@article{han2020model,
title={Model Rubik's Cube: Twisting Resolution, Depth and Width for TinyNets},
author={Han, Kai and Wang, Yunhe and Zhang, Qiulin and Zhang, Wei and Xu, Chunjing and Zhang, Tong},
journal={Advances in Neural Information Processing Systems},
volume={33},
pages={19353--19364},
year={2020}
}
@misc{rw2019timm,
author={Ross Wightman},
title={PyTorch Image Models},
year={2019},
publisher={GitHub},
journal={GitHub repository},
doi={10.5281/zenodo.4414861},
howpublished={\url{https://github.com/huggingface/pytorch-image-models}}
}
License
The source model repository declares the model under the Apache License 2.0. The full license text is provided in LICENSE. Copyright and attribution for TinyNet and timm remain with their respective authors and contributors.