Downloads · 30 days
13
9% of all-time downloads
W4ashabii/SmolVLM256M_CropDisease
SmolVLM256M_CropDisease is a image-text-to-text model from W4ashabii. Use it for the image-text-to-text task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as apache-2.0.
A LoRA fine-tune of HuggingFaceTB/SmolVLM-256M-Instruct that answers "What crop is shown in this image, and does it have any disease?" for photos of Nepali crops. Trained on w4ashabii/nepalicropdata, a ShareGPT-format…
Downloads · 30 days
13
9% of all-time downloads
All-time downloads
147
Public
Repo size
458 MB
Likes
0
Public
Click a slice to open those files.
.safetensors15.2 MB · 81%
From the Hugging Face model README
A LoRA fine-tune of HuggingFaceTB/SmolVLM-256M-Instruct that answers "What crop is shown in this image, and does it have any disease?" for photos of Nepali crops. Trained on w4ashabii/nepali_crop_data, a ShareGPT-format visual-QA dataset covering 9 crops.
| Base model | HuggingFaceTB/SmolVLM-256M-Instruct (~256M params) |
| Fine-tuning method | LoRA (adapters only, base weights frozen) |
| Trainable params | 3,769,344 / 260,254,272 (1.45%) |
| Framework | 🤗 transformers Trainer + Unsloth FastVisionModel |
| LoRA targets | Attention + MLP modules across both vision encoder and language model |
| LoRA config | r=8, alpha=16, dropout=0.05, bias="none" |
| Precision | fp16 |
| Hardware | 1x NVIDIA T4 (Google Colab) |
| Language(s) | English (Q&A text); images of Nepali-grown crops |
| License | Apache 2.0 (inherited from base model) |
w4ashabii/nepali_crop_datasharegpt.jsonl), one user turn (image + question) → one assistant turn (crop + disease answer)longest_edge=512, image splitting disabled (not needed for single-leaf/crop photos)| Hyperparameter | Value |
|---|---|
| Epochs | 2 |
| Per-device batch size | 8 |
| Gradient accumulation steps | 2 |
| Effective batch size | 16 |
| Learning rate | 1e-4 |
| LR schedule | cosine, 3% warmup |
| Optimizer | AdamW (Trainer default) |
| Total steps | 5,000 |
| Total training time | ~3h 3m (11,012s) |
| Throughput | 7.26 samples/sec |
Checkpoints were saved locally every 500 steps and mirrored to this Hub repo roughly every hour during training via a custom TrainerCallback (each upload replaced the repo's prior contents), with a final clean upload of just the adapter + processor after training completed.
| Step | Training Loss | Validation Loss |
|---|---|---|
| 500 | 0.1948 | 0.1918 |
| 1000 | 0.1842 | 0.1871 |
| 1500 | 0.1878 | 0.1858 |
| 2000 | 0.1827 | 0.1865 |
| 2500 | 0.1685 | 0.1856 |
| 3000 | 0.1809 | 0.1841 |
| 3500 | 0.1825 | 0.1837 |
| 4000 | 0.1730 | 0.1836 |
| 4500 | 0.1758 | 0.1833 |
| 5000 | 0.1860 | 0.1833 |
Final train loss: 0.2363 (mean over all logged steps, includes early-training values before it stabilized). Validation loss plateaued around 0.183 from step ~3500 onward, suggesting the model converged with room left in the schedule rather than overfitting.
import torch
from PIL import Image
from transformers import AutoProcessor, AutoModelForVision2Seq
from peft import PeftModel
BASE_MODEL = "HuggingFaceTB/SmolVLM-256M-Instruct"
ADAPTER_REPO = "w4ashabii/SmolVLM256M_CropDisease"
processor = AutoProcessor.from_pretrained(ADAPTER_REPO)
base_model = AutoModelForVision2Seq.from_pretrained(BASE_MODEL, torch_dtype=torch.float16)
model = PeftModel.from_pretrained(base_model, ADAPTER_REPO).to("cuda")
model.eval()
image = Image.open("your_crop_photo.jpg").convert("RGB")
question = "What crop is shown in this image, and does it have any disease? If so, name the disease."
messages = [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": question}]}]
prompt = processor.apply_chat_template(messages, add_generation_prompt=True)
inputs = processor(text=prompt, images=[image], return_tensors="pt").to("cuda")
with torch.no_grad():
generated_ids = model.generate(**inputs, max_new_tokens=64)
answer = processor.batch_decode(
generated_ids[:, inputs["input_ids"].shape[1]:], skip_special_tokens=True
)[0]
print(answer.strip())
from unsloth import FastVisionModel
model, processor = FastVisionModel.from_pretrained("w4ashabii/SmolVLM256M_CropDisease")
FastVisionModel.for_inference(model)
# ... same generate() call as above
w4ashabii/nepali_crop_data; performance on out-of-distribution crops, lighting conditions, or camera angles is untested.Fine-tuned with 🤗 transformers.Trainer and LoRA adapters loaded/attached via Unsloth's FastVisionModel (use_gradient_checkpointing="unsloth") for reduced VRAM use and faster steps on a single T4 GPU.