Spaces:
Runtime error
Runtime error
ramonvictorn
commited on
Commit
•
0f53425
1
Parent(s):
3888e1f
feat: using different format
Browse files- app copy.py +15 -0
- app.py +29 -12
app copy.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
|
5 |
+
|
6 |
+
def predict(image):
|
7 |
+
predictions = pipeline(image)
|
8 |
+
return {p["label"]: p["score"] for p in predictions}
|
9 |
+
|
10 |
+
gr.Interface(
|
11 |
+
predict,
|
12 |
+
inputs=gr.inputs.Image(label="Upload car candidate", type="filepath"),
|
13 |
+
outputs=gr.outputs.Label(num_top_classes=2),
|
14 |
+
title="Brazilian nacional? Or Imported?",
|
15 |
+
).launch()
|
app.py
CHANGED
@@ -1,15 +1,32 @@
|
|
1 |
-
|
2 |
-
from
|
3 |
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
return {p["label"]: p["score"] for p in predictions}
|
9 |
|
10 |
-
|
11 |
-
predict
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
from gradio as gr
|
3 |
|
4 |
+
def is_imported(x): return x[o].isupper()
|
5 |
|
6 |
+
learn = load_learner("model.pkl")
|
7 |
+
categories = ('Imported', 'Nacional')
|
|
|
8 |
|
9 |
+
def classify_image(img):
|
10 |
+
prd,idx,props = learn.predict(img)
|
11 |
+
return dict(zip(categories, map(float, props)))
|
12 |
+
|
13 |
+
|
14 |
+
image = gr.inputs.Image(shape=(192,192))
|
15 |
+
label = gr.outputs.Label()
|
16 |
+
# examples = ["xx.jpg"]
|
17 |
+
|
18 |
+
|
19 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label)
|
20 |
+
intf.launch(inline=False)
|
21 |
+
# pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
|
22 |
+
|
23 |
+
# def predict(image):
|
24 |
+
# predictions = pipeline(image)
|
25 |
+
# return {p["label"]: p["score"] for p in predictions}
|
26 |
+
|
27 |
+
# gr.Interface(
|
28 |
+
# predict,
|
29 |
+
# inputs=gr.inputs.Image(label="Upload car candidate", type="filepath"),
|
30 |
+
# outputs=gr.outputs.Label(num_top_classes=2),
|
31 |
+
# title="Brazilian nacional? Or Imported?",
|
32 |
+
# ).launch()
|