Spaces:
Runtime error
Runtime error
Nithila Ariyapperuma
commited on
Commit
•
81e469f
1
Parent(s):
f4d5990
new
Browse files
app.py
CHANGED
@@ -1,33 +1,12 @@
|
|
1 |
-
import requests
|
2 |
-
|
3 |
import gradio as gr
|
4 |
-
import
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
**resolve_data_config({}, model=model)
|
16 |
-
)
|
17 |
-
|
18 |
-
model.eval()
|
19 |
-
|
20 |
-
def predict_fn(img):
|
21 |
-
img = img.convert('RGB')
|
22 |
-
img = transform(img).unsqueeze(0)
|
23 |
-
|
24 |
-
with torch.no_grad():
|
25 |
-
out = model(img)
|
26 |
-
|
27 |
-
probabilites = torch.nn.functional.softmax(out[0], dim=0)
|
28 |
-
|
29 |
-
values, indices = torch.topk(probabilites, k=5)
|
30 |
-
|
31 |
-
return {LABELS[i]: v.item() for i, v in zip(indices, values)}
|
32 |
-
|
33 |
-
gr.Interface(predict_fn, gr.inputs.Image(type='pil'), outputs='label').launch()
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
pipe = pipeline(task="image-classification",
|
5 |
+
# model that can do 22k-category classification
|
6 |
+
model="abhishek/autotrain_fashion_mnist_vit_base")
|
7 |
+
gr.Interface.from_pipeline(pipe,
|
8 |
+
title="22k Image Classification",
|
9 |
+
description="Object Recognition using Microsoft BEIT",
|
10 |
+
examples = ['wonder_cat.jpg', 'aki_dog.jpg',],
|
11 |
+
article = "Author: <a href=\"https://huggingface.co/rowel\">Rowel Atienza</a>",
|
12 |
+
).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|