Spaces:
Runtime error
Runtime error
ClauMS commited on
Commit ·
46a98b4
1
Parent(s): f61fa0e
Model and Interface Ready
Browse files- app.py +18 -4
- boleta.jpg +0 -0
- doc_classifier_model.pkl +3 -0
- factura.jpg +0 -0
- formulario.jpg +0 -0
app.py
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
| 4 |
-
return "Hello " + name + "!!"
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastai.vision import *
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
learner = load_learner('doc_classifier_model.pkl')
|
|
|
|
| 5 |
|
| 6 |
+
categories = ['Factura', 'Boleta', 'Formulario']
|
| 7 |
+
|
| 8 |
+
def classify_doc(img):
|
| 9 |
+
pred, idx, probs = learner.predict(img)
|
| 10 |
+
return dict(zip(categories, map(float, probs)))
|
| 11 |
+
|
| 12 |
+
image = gr.inputs.Image(shape=(224, 224))
|
| 13 |
+
label = gr.outputs.Label(num_top_classes=3)
|
| 14 |
+
examples = [
|
| 15 |
+
['factura.jpg'],
|
| 16 |
+
['boleta.jpg'],
|
| 17 |
+
['formulario.jpg']
|
| 18 |
+
]
|
| 19 |
+
|
| 20 |
+
iface = gr.Interface(fn=classify_doc, inputs=image, outputs=label, examples=examples)
|
| 21 |
+
iface.launch(inline=False)
|
boleta.jpg
ADDED
|
doc_classifier_model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5e4984ffd183852fd3fbd151ff3087cc2df8a7f7490848de0f77959a0836fe8b
|
| 3 |
+
size 46974219
|
factura.jpg
ADDED
|
formulario.jpg
ADDED
|