Views
No views yet
| Training Loss | Epoch | Step | Validation Loss | Accuracy |
|---|---|---|---|---|
| 0.8211 | 1.0 | 119 | 0.8232 | 78.20% |
| 0.7385 | 2.0 | 238 | 0.7586 | 80.13% |
| 0.6528 | 3.0 | 357 | 0.7408 | 80.57% |
| 0.5283 | 4.0 | 476 | 0.6797 | 82.18% |
| 0.5294 | 4.962 | 590 | 0.6790 | 82.13% |
transformers library and PEFT for efficient fine-tuning:1from transformers import ViTForImageClassification, ViTFeatureExtractor
2from peft import PeftModel
3from PIL import Image
4import torch
5
6# Load base model and LoRA adapter
7base_model = ViTForImageClassification.from_pretrained("path_to_base_model")
8model = PeftModel.from_pretrained(base_model, "path_to_lora_adapter")
9feature_extractor = ViTFeatureExtractor.from_pretrained("path_to_base_model")
10
11# Load and preprocess an image
12image = Image.open("example_food.jpg")
13inputs = feature_extractor(images=image, return_tensors="pt")
14
15# Perform inference
16with torch.no_grad():
17 outputs = model(**inputs)
18 predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
19 predicted_class = predictions.argmax().item()
20
21print(f"Predicted class: {predicted_class}")@misc{my_awesome_food_model_lora,
author = {Your Name},
title = {My Awesome Food Model - Fine-tuned LoRA (Food101)},
year = {2025},
url = {https://huggingface.co/your_model_link}
}