Spaces:
Runtime error
Runtime error
Matthijs Hollemans
commited on
Commit
β’
8239775
1
Parent(s):
2c1d18b
let's try a classifier first
Browse files- README.md +1 -1
- app.py +11 -4
- requirements.txt +2 -0
README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
emoji: π
|
4 |
colorFrom: red
|
5 |
colorTo: pink
|
|
|
1 |
---
|
2 |
+
title: MobileViT Deeplab Demo
|
3 |
emoji: π
|
4 |
colorFrom: red
|
5 |
colorTo: pink
|
app.py
CHANGED
@@ -1,8 +1,15 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
pipeline = pipeline(task="image-classification", model="apple/mobilevit-small")
|
|
|
5 |
|
6 |
+
def predict(image):
|
7 |
+
predictions = pipeline(image)
|
8 |
+
return {p["label"]: p["score"] for p in predictions}
|
9 |
|
10 |
+
gr.Interface(
|
11 |
+
fn=predict,
|
12 |
+
inputs=gr.inputs.Image(label="Upload image", type="filepath"),
|
13 |
+
outputs=gr.outputs.Label(num_top_classes=5),
|
14 |
+
title="This is a title",
|
15 |
+
).launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
torch
|