Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
from transformers import pipeline
|
| 2 |
import gradio as gr
|
| 3 |
import tensorflow as tf
|
| 4 |
from PIL import Image
|
|
@@ -14,7 +13,7 @@ def predict_image(img):
|
|
| 14 |
img_batch = np.expand_dims(img_array, axis=0)
|
| 15 |
|
| 16 |
# Predict
|
| 17 |
-
pred = model.predict(img_batch)[0][0]
|
| 18 |
label = "dog" if pred > 0.5 else "cat"
|
| 19 |
confidence = float(pred) if pred > 0.5 else float(1 - pred)
|
| 20 |
return {label: confidence}
|
|
@@ -25,8 +24,8 @@ demo = gr.Interface(
|
|
| 25 |
inputs=gr.Image(type="pil"),
|
| 26 |
outputs=gr.Label(num_top_classes=2),
|
| 27 |
examples=[],
|
| 28 |
-
title="
|
| 29 |
-
description="
|
| 30 |
)
|
| 31 |
|
| 32 |
demo.launch()
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import tensorflow as tf
|
| 3 |
from PIL import Image
|
|
|
|
| 13 |
img_batch = np.expand_dims(img_array, axis=0)
|
| 14 |
|
| 15 |
# Predict
|
| 16 |
+
pred = model.predict(img_batch, verbose=0)[0][0]
|
| 17 |
label = "dog" if pred > 0.5 else "cat"
|
| 18 |
confidence = float(pred) if pred > 0.5 else float(1 - pred)
|
| 19 |
return {label: confidence}
|
|
|
|
| 24 |
inputs=gr.Image(type="pil"),
|
| 25 |
outputs=gr.Label(num_top_classes=2),
|
| 26 |
examples=[],
|
| 27 |
+
title="🐱 vs 🐶 Cat or Dog Classifier",
|
| 28 |
+
description="Trained on only 100 images! Upload a photo to see the prediction."
|
| 29 |
)
|
| 30 |
|
| 31 |
demo.launch()
|