| --- |
| title: NanoVLM |
| emoji: π€ |
| colorFrom: blue |
| colorTo: indigo |
| sdk: gradio |
| sdk_version: "5.0.0" |
| app_file: app.py |
| pinned: false |
| license: mit |
| --- |
| |
| # NanoVLM |
|
|
| NanoVLM is a lightweight Vision-Language Model (VLM) designed for efficient multimodal understanding. It combines image encoding and language generation to answer questions about images while remaining suitable for resource-constrained environments. |
|
|
| ## Features |
|
|
| - πΌοΈ Image understanding |
| - π¬ Visual Question Answering (VQA) |
| - β‘ Lightweight architecture |
| - π€ Hugging Face compatible |
| - π Training and inference notebook included |
|
|
| ## Model Architecture |
|
|
| The model consists of: |
|
|
| - Vision Encoder |
| - Projection Layer |
| - Language Model |
| - Cross-modal fusion between visual and textual representations |
|
|
| ``` |
| Image |
| β |
| Vision Encoder |
| β |
| Projection Layer |
| β |
| Language Model |
| β |
| Generated Answer |
| ``` |
|
|
| ## Installation |
|
|
| Clone the repository |
|
|
| ```bash |
| git clone https://github.com/your-username/nanovlm.git |
| cd nanovlm |
| ``` |
|
|
| Install dependencies |
|
|
| ```bash |
| pip install -r requirements.txt |
| ``` |
|
|
| ## Usage |
|
|
| ### Inference |
|
|
| ```python |
| from PIL import Image |
| |
| image = Image.open("example.jpg") |
| |
| question = "What is in this image?" |
| |
| answer = model.chat(image, question) |
| |
| print(answer) |
| ``` |
|
|
| ### Notebook |
|
|
| Open the notebook: |
|
|
| ``` |
| NanoVlm_fixed.ipynb |
| ``` |
|
|
| and execute all cells. |
|
|
| ## Dataset |
|
|
| The model can be trained on datasets such as: |
|
|
| - COCO Captions |
| - VQAv2 |
| - Flickr30k |
| - Custom datasets |
|
|
| ## Training |
|
|
| Example: |
|
|
| ```bash |
| python train.py |
| ``` |
|
|
| Adjust hyperparameters such as: |
|
|
| - Learning rate |
| - Batch size |
| - Number of epochs |
| - Image resolution |
|
|
| ## Results |
|
|
| | Metric | Value | |
| |---------|------:| |
| | Accuracy | -- | |
| | BLEU | -- | |
| | CIDEr | -- | |
|
|
| *(Replace with your experimental results.)* |
|
|
| ## Repository Structure |
|
|
| ``` |
| . |
| βββ NanoVlm_fixed.ipynb |
| βββ app.py |
| βββ requirements.txt |
| βββ README.md |
| βββ images/ |
| βββ model/ |
| ``` |
|
|
| ## Requirements |
|
|
| - Python 3.10+ |
| - PyTorch |
| - Transformers |
| - Pillow |
| - Torchvision |
| - Gradio (optional) |
|
|
| Install: |
|
|
| ```bash |
| pip install torch torchvision transformers pillow gradio |
| ``` |
|
|
| ## Citation |
|
|
| If you use this project, please cite: |
|
|
| ```bibtex |
| @misc{nanovlm2026, |
| title={NanoVLM: A Lightweight Vision-Language Model}, |
| author={Your Name}, |
| year={2026}, |
| publisher={Hugging Face} |
| } |
| ``` |
|
|
| ## License |
|
|
| MIT License |
|
|
| ## Acknowledgements |
|
|
| This project builds upon the excellent work of: |
|
|
| - Hugging Face Transformers |
| - PyTorch |
| - Vision Transformer (ViT) |
| - Large Language Models research |
|
|
| --- |
|
|
| β If you find this project useful, consider giving it a star on GitHub or liking it on Hugging Face. |