Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,16 @@
|
|
| 1 |
from transformers import AutoModel
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
model = AutoModel.from_pretrained("KFrimps/oxford-pets-vit-from-scratch")
|
|
|
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
from PIL import Image
|
| 8 |
|
| 9 |
def predict(image):
|
| 10 |
"""Predicts the class of the input image using the fine-tuned student model."""
|
|
|
|
| 1 |
from transformers import AutoModel
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from PIL import Image
|
| 4 |
+
import torch
|
| 5 |
|
| 6 |
model = AutoModel.from_pretrained("KFrimps/oxford-pets-vit-from-scratch")
|
| 7 |
+
processor = ViTImageProcessor.from_pretrained("KFrimps/oxford-pets-vit-from-scratch")
|
| 8 |
|
| 9 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 10 |
+
model.to(device)
|
| 11 |
+
|
| 12 |
+
id2label = model.config.id2label
|
| 13 |
|
|
|
|
| 14 |
|
| 15 |
def predict(image):
|
| 16 |
"""Predicts the class of the input image using the fine-tuned student model."""
|