Update app.py
Browse files
app.py
CHANGED
|
@@ -1,28 +1,20 @@
|
|
| 1 |
-
|
| 2 |
-
from
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
inputs
|
| 21 |
-
|
| 22 |
-
# Make predictions
|
| 23 |
-
outputs = model(**inputs)
|
| 24 |
-
logits = outputs.logits
|
| 25 |
-
|
| 26 |
-
# Model predicts one of the 1000 ImageNet classes
|
| 27 |
-
predicted_class_idx = logits.argmax(-1).item()
|
| 28 |
-
print("Predicted class:", model.config.id2label[predicted_class_idx])
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from fastai.vision.all import *
|
| 3 |
+
import skimage
|
| 4 |
+
|
| 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 = "Kapu"
|
| 14 |
+
description = "An app for Chicken Disease Classisfication"
|
| 15 |
+
article="<p style='text-align: center'>The app identifies and classifies three chicken diseases: Coccidiosis, Salmonella, and Newcastle, aiding in effective disease management for poultry farming.</p>"
|
| 16 |
+
examples = ['test_image.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()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|