Spaces:
Runtime error
Runtime error
jpablolastra
commited on
Commit
•
852cee1
1
Parent(s):
fd4228d
Added first version of app
Browse files- README.md +3 -3
- app.py +20 -0
- export.pkl +3 -0
- ori.jpg +0 -0
- requirements.txt +2 -0
README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
---
|
2 |
title: Mycatdetector
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.43.2
|
8 |
app_file: app.py
|
|
|
1 |
---
|
2 |
title: Mycatdetector
|
3 |
+
emoji:
|
4 |
+
colorFrom: gray
|
5 |
+
colorTo: orange
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.43.2
|
8 |
app_file: app.py
|
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
import skimage
|
4 |
+
def is_cat(x): return x[0].isupper()
|
5 |
+
learn = load_learner('export.pkl')
|
6 |
+
|
7 |
+
labels = learn.dls.vocab
|
8 |
+
def predict(img):
|
9 |
+
img = PILImage.create(img)
|
10 |
+
pred,pred_idx,probs = learn.predict(img)
|
11 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
12 |
+
|
13 |
+
title = "Mi detector de gatos / My Cat Detector"
|
14 |
+
description = "Un modelo de prueba para aprender, siguiendo las instrucciones de la lección 2 del curso de fast.ai. El modelo detecta si la foto es de uno de mis dos gatos. / A test model to learn, following the instructions in lesson 2 of the fast.ai course. The model detects if the picture is one of my two cats."
|
15 |
+
article="<p style='text-align: center'><a href='https://papagame.dev/2023/09/mi-detector-de-gatos.html' target='_blank'>Artículo en PapaGameDev</a></p><p style='text-align: center'><a href='https://papagame.dev/2023/09/my-cat-detector.html' target='_blank'>PapaGameDev Blog Post</a></p>"
|
16 |
+
examples = ['ori.jpg']
|
17 |
+
interpretation='default'
|
18 |
+
enable_queue=True
|
19 |
+
|
20 |
+
gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=3),title=title,description=description,article=article,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()
|
export.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7354857ac2c5a1461676779135eb7b937fd14393256b0465186a9a2e87b24105
|
3 |
+
size 47061419
|
ori.jpg
ADDED
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|