Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,11 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from transformers import ViTForImageClassification,
|
| 3 |
from PIL import Image
|
| 4 |
import torch
|
| 5 |
|
| 6 |
-
# মডেল ও প্রসেসর লোড করো
|
| 7 |
model = ViTForImageClassification.from_pretrained("rakib730/vit-base-oxford-iiit-pets")
|
| 8 |
-
processor =
|
| 9 |
|
| 10 |
-
# প্রেডিকশন ফাংশন
|
| 11 |
def classify_image(image):
|
| 12 |
inputs = processor(images=image, return_tensors="pt")
|
| 13 |
with torch.no_grad():
|
|
@@ -17,7 +15,6 @@ def classify_image(image):
|
|
| 17 |
label = model.config.id2label[predicted_class_idx]
|
| 18 |
return label
|
| 19 |
|
| 20 |
-
# Gradio UI
|
| 21 |
iface = gr.Interface(
|
| 22 |
fn=classify_image,
|
| 23 |
inputs=gr.Image(type="pil"),
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import ViTForImageClassification, AutoImageProcessor
|
| 3 |
from PIL import Image
|
| 4 |
import torch
|
| 5 |
|
|
|
|
| 6 |
model = ViTForImageClassification.from_pretrained("rakib730/vit-base-oxford-iiit-pets")
|
| 7 |
+
processor = AutoImageProcessor.from_pretrained("rakib730/vit-base-oxford-iiit-pets")
|
| 8 |
|
|
|
|
| 9 |
def classify_image(image):
|
| 10 |
inputs = processor(images=image, return_tensors="pt")
|
| 11 |
with torch.no_grad():
|
|
|
|
| 15 |
label = model.config.id2label[predicted_class_idx]
|
| 16 |
return label
|
| 17 |
|
|
|
|
| 18 |
iface = gr.Interface(
|
| 19 |
fn=classify_image,
|
| 20 |
inputs=gr.Image(type="pil"),
|