Spaces:
Runtime error
Runtime error
Commit
·
aad3cee
1
Parent(s):
0af5b3f
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,32 @@
|
|
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# gr.Interface.load("models/PranomVignesh/Handwritten-Characters").launch()
|
2 |
import gradio as gr
|
3 |
+
from transformers import pipeline
|
4 |
|
5 |
+
imageClassifier = pipeline(task="image-classification",
|
6 |
+
model="PranomVignesh/Handwritten-Characters")
|
7 |
+
|
8 |
+
def predict(image):
|
9 |
+
predictions = imageClassifier(image)
|
10 |
+
output = {}
|
11 |
+
for item in predictions:
|
12 |
+
output[item['label']] = item['score']
|
13 |
+
|
14 |
+
return output
|
15 |
+
|
16 |
+
|
17 |
+
inputs = gr.Sketchpad(shape=(224, 224),
|
18 |
+
label="Draw your characters to detect")
|
19 |
+
|
20 |
+
outputs = gr.Label(label="Predicted Character")
|
21 |
+
|
22 |
+
interface = gr.Interface(
|
23 |
+
fn=predict,
|
24 |
+
inputs=inputs,
|
25 |
+
outputs=outputs,
|
26 |
+
# title=title,
|
27 |
+
# examples=examples,
|
28 |
+
# description=description,
|
29 |
+
# cache_examples=True,
|
30 |
+
theme='huggingface'
|
31 |
+
)
|
32 |
+
interface.launch(debug=True, enable_queue=True)
|