Spaces:
Runtime error
Runtime error
update app.py
Browse files
app.py
CHANGED
|
@@ -51,5 +51,28 @@ def pred(img):
|
|
| 51 |
pred = torch.softmax(logits, dim=-1)
|
| 52 |
return f"prediction: {class_names[pred.argmax(dim=-1).item()]} | confidence: {pred.max():.3f}"
|
| 53 |
|
| 54 |
-
demo = gr.
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
pred = torch.softmax(logits, dim=-1)
|
| 52 |
return f"prediction: {class_names[pred.argmax(dim=-1).item()]} | confidence: {pred.max():.3f}"
|
| 53 |
|
| 54 |
+
demo = gr.Blocks()
|
| 55 |
+
|
| 56 |
+
with demo:
|
| 57 |
+
gr.Markdown("""
|
| 58 |
+
# Welcome to FreshVision 📷
|
| 59 |
+
_FreshVision is a machine learning model to classify freshness for fruits. This model
|
| 60 |
+
utilizes transfer learning from pre-trained model from PyTorch [EfficientNetB0](https://pytorch.org/vision/stable/models/generated/torchvision.models.efficientnet_b0.html).
|
| 61 |
+
This model has been trained on [kaggle datasets](https://www.kaggle.com/datasets/sriramr/fruits-fresh-and-rotten-for-classification) using NVIDIA T4 GPU._
|
| 62 |
+
|
| 63 |
+
## Model capabilities:
|
| 64 |
+
- Classify freshness from fruits image (apple, orange, and banana) with two labels: _Fresh_ and _Rotten/spoiled_
|
| 65 |
+
## Model drawbacks:
|
| 66 |
+
- Sometimes perform false prediction on some fruits condition, this is due to low variability on the image datasets
|
| 67 |
+
- Can't perform accurate prediction on multiple objects/combined condition (e.g. two bananas with different freshness condition)
|
| 68 |
+
- This models can't identify non-fruits objects , since it's only trained with fruits dataset.
|
| 69 |
+
|
| 70 |
+
## **How to get the best result with this model:**
|
| 71 |
+
1. The image should only contain fruits that the model can recognize (apple, orange, and banana)
|
| 72 |
+
2. The image should only contain one object (one fruit)
|
| 73 |
+
3. Ensure the object is captured with sufficient light so that the surface of the fruits is exposed properly
|
| 74 |
+
""")
|
| 75 |
+
gr.Interface(pred, gr.Image(), outputs="text")
|
| 76 |
+
|
| 77 |
+
if __name__ == "__main__":
|
| 78 |
+
demo.launch()
|