Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
'/kaggle/input/healthy-cells/normalbloodsmear.jpg'
|
| 11 |
-
]
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
allow_flagging=False,
|
| 21 |
-
article='Sickle cell disease (SCD) is a group of inherited red blood cell disorders. In SCD, the red blood cells become hard and sticky and look like a C-shaped farm tool called a “sickle.” The disease can be managed under proper medical supervision.'
|
| 22 |
-
)
|
| 23 |
|
| 24 |
-
|
| 25 |
-
intf.launch(inline=False)
|
|
|
|
| 1 |
+
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
def get_label(x):
|
| 5 |
+
return 'dog' if 'dog' in x.name else 'cat'
|
| 6 |
+
|
| 7 |
+
learn = load_learner('cat_or_dog.pkl')
|
| 8 |
+
|
| 9 |
+
# Extract categories directly from the learner to ensure correct order
|
| 10 |
+
categories = learn.dls.vocab
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
def classify_img(img):
|
| 13 |
+
pred, idx, probs = learn.predict(img)
|
| 14 |
+
return {categories[i]: float(probs[i]) for i in range(len(categories))}
|
| 15 |
+
|
| 16 |
+
image = gr.Image()
|
| 17 |
+
labels = gr.Label()
|
| 18 |
+
examples = ['dog.jpg', 'cat.jpeg']
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
intf = gr.Interface(fn=classify_img, inputs=image, outputs=labels, examples=examples)
|
| 21 |
+
intf.launch(inline=False, share=True)
|