Matthijs Hollemans commited on
Commit
8239775
β€’
1 Parent(s): 2c1d18b

let's try a classifier first

Browse files
Files changed (3) hide show
  1. README.md +1 -1
  2. app.py +11 -4
  3. requirements.txt +2 -0
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: Mobilevit Deeplab Demo
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
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
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