Spaces:
Runtime error
Runtime error
davidrd123
commited on
Commit
·
a31b360
1
Parent(s):
20b16dc
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
import skimage
|
4 |
+
|
5 |
+
learn = load_learner('movements_05_02_22_4pm.pkl')
|
6 |
+
|
7 |
+
def predict(img):
|
8 |
+
labels = learn.dls.vocab
|
9 |
+
im = PILImage.create(img)
|
10 |
+
pred,pred_idx,probs = learn.predict(im)
|
11 |
+
return {label: float(prob) for (label,prob) in zip(labels,probs)}
|
12 |
+
|
13 |
+
examples = [f"Image{n:02d}" for n in range(25)]
|
14 |
+
|
15 |
+
gr.Interface(fn=predict,
|
16 |
+
inputs=gr.inputs.Image(shape=((512,512))),
|
17 |
+
outputs=gr.outputs.Label(num_top_classes=5),
|
18 |
+
title = "Art Movements",
|
19 |
+
examples = examples
|
20 |
+
description= "What Art Movement Matches the Image Best? Expressionism | Impressionism | Hudson River School | Ukiyo-e | Pre-Raphaelite").launch(share=True, enable_queue=True)
|