Spaces:
Runtime error
Runtime error
Kelly Nicholes commited on
Commit ·
5284493
1
Parent(s): 99bb198
Try different object
Browse files
app.py
CHANGED
|
@@ -5,26 +5,10 @@ import gradio as gr
|
|
| 5 |
# Cell
|
| 6 |
learn = load_learner('model.pkl')
|
| 7 |
|
| 8 |
-
# Cell
|
| 9 |
-
# categories = ('Toronto, Canada', 'Denver, Colorado, USA', 'Emeryville, California, USA','Lehi, Utah, USA', 'Los Angeles, California, USA', 'College Park, Maryland, USA','Mexico City, Mexico', 'Arden Hills, Minnesota, USA', 'São Paulo, Brazil','New York, New York, USA', 'Portland, Oregon, USA', 'San Francisco, California, USA','Seattle, Washington, USA', 'Shanghai, China', 'Guangzhou, China', 'Hong Kong, China','Noida, India', 'Dublin, Ireland', 'Milan, Italy', 'Rome, Italy', 'Chisinau, Moldova','Amsterdam, Netherlands', 'Austin, Texas, USA', 'McLean, Virginia, USA','Washington D.C., USA', 'Atlanta, Georgia, USA', 'Waltham, Massachusetts, USA','Cambridge, Massachusetts, USA', 'San Jose, California, USA', 'Chicago, Illinois, USA','Ottawa, Canada', 'Bangalore, India', 'Mumbai, India', 'Gurgaon, India','Tokyo, Japan', 'Seoul, South Korea', 'Singapore, Singapore', 'Shenzhen, China','Bangkok, Thailand', 'Taipei, Taiwan', 'Melbourne, Australia', 'Sydney, Australia','Canberra, Australia', 'Yerevan, Armenia', 'Diegem, Belgium', 'Copenhagen, Denmark','Paris, France', 'Munich, Germany', 'Berlin, Germany', 'Hamburg, Germany','Basel, Switzerland', 'Zurich, Switzerland', 'Warsaw, Poland', 'Bucharest, Romania','Johannesburg, South Africa', 'Madrid, Spain', 'Barcelona, Spain', 'Stockholm, Sweden','Maidenhead, United Kingdom', 'London, United Kingdom', 'Edinburgh, Scotland')
|
| 10 |
-
|
| 11 |
-
|
| 12 |
labels = learn.dls.vocab
|
| 13 |
def predict(img):
|
| 14 |
img = PILImage.create(img)
|
| 15 |
pred,pred_idx,probs = learn.predict(img)
|
| 16 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 17 |
|
| 18 |
-
|
| 19 |
-
# pred,idx,probs = learn.predict(img)
|
| 20 |
-
# return dict(zip(categories, map(float,probs)))
|
| 21 |
-
|
| 22 |
-
# Cell
|
| 23 |
-
# image = gr.inputs.Image(shape=(192, 192))
|
| 24 |
-
# label = gr.outputs.Label()
|
| 25 |
-
# examples = []
|
| 26 |
-
|
| 27 |
-
# intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 28 |
-
# intf.launch(inline=False)
|
| 29 |
-
|
| 30 |
-
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3)).launch(share=True)
|
|
|
|
| 5 |
# Cell
|
| 6 |
learn = load_learner('model.pkl')
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
labels = learn.dls.vocab
|
| 9 |
def predict(img):
|
| 10 |
img = PILImage.create(img)
|
| 11 |
pred,pred_idx,probs = learn.predict(img)
|
| 12 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 13 |
|
| 14 |
+
gr.Interface(fn=predict, inputs=gr.Image(shape=(512, 512)), outputs=gr.Label(num_top_classes=3)).launch(share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|