Spaces:
Sleeping
Sleeping
Add logo via Git LFS and app updates
Browse files
.gradio/flagged/dataset1.csv
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
image,output,timestamp
|
| 2 |
+
.gradio\flagged\image\9221e60e9a4e88f810fc\test_image.JPG,Prediction: Apple___Apple_scab (Confidence: 1.00),2025-08-14 22:02:58.644569
|
.gradio/flagged/image/9221e60e9a4e88f810fc/test_image.JPG
ADDED
|
|
src/app_gradio.py
CHANGED
|
@@ -3,6 +3,7 @@ from PIL import Image
|
|
| 3 |
import torch
|
| 4 |
import os
|
| 5 |
import json
|
|
|
|
| 6 |
from transformers import AutoImageProcessor, AutoModelForImageClassification
|
| 7 |
|
| 8 |
MODEL_DIR = "models/vit-finetuned"
|
|
@@ -15,9 +16,14 @@ LOGO_ABS = os.path.abspath(os.path.join(
|
|
| 15 |
|
| 16 |
def logo_block():
|
| 17 |
if os.path.exists(LOGO_ABS):
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
else:
|
| 22 |
html = '<div style="color:red;">Logo image not found!</div>'
|
| 23 |
dbg = f"Logo missing at: {LOGO_ABS}"
|
|
@@ -52,16 +58,27 @@ def predict(image):
|
|
| 52 |
|
| 53 |
|
| 54 |
with gr.Blocks() as demo:
|
| 55 |
-
|
| 56 |
-
gr.
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
if __name__ == "__main__":
|
| 67 |
demo.launch(server_port=7860, server_name="127.0.0.1")
|
|
|
|
| 3 |
import torch
|
| 4 |
import os
|
| 5 |
import json
|
| 6 |
+
import base64
|
| 7 |
from transformers import AutoImageProcessor, AutoModelForImageClassification
|
| 8 |
|
| 9 |
MODEL_DIR = "models/vit-finetuned"
|
|
|
|
| 16 |
|
| 17 |
def logo_block():
|
| 18 |
if os.path.exists(LOGO_ABS):
|
| 19 |
+
try:
|
| 20 |
+
with open(LOGO_ABS, "rb") as f:
|
| 21 |
+
b64 = base64.b64encode(f.read()).decode("ascii")
|
| 22 |
+
html = f'<img src="data:image/png;base64,{b64}" width="200" />'
|
| 23 |
+
dbg = f"Logo OK: {LOGO_ABS}"
|
| 24 |
+
except Exception as e:
|
| 25 |
+
html = '<div style="color:red;">Logo image failed to load!</div>'
|
| 26 |
+
dbg = f"Logo read error at {LOGO_ABS}: {e}"
|
| 27 |
else:
|
| 28 |
html = '<div style="color:red;">Logo image not found!</div>'
|
| 29 |
dbg = f"Logo missing at: {LOGO_ABS}"
|
|
|
|
| 58 |
|
| 59 |
|
| 60 |
with gr.Blocks() as demo:
|
| 61 |
+
# Header: logo left, title right
|
| 62 |
+
with gr.Row():
|
| 63 |
+
with gr.Column(scale=0, min_width=220):
|
| 64 |
+
gr.HTML(logo_html)
|
| 65 |
+
with gr.Column(scale=1):
|
| 66 |
+
gr.Markdown("# Plant Disease Classifier")
|
| 67 |
+
gr.Markdown("Upload a plant image to classify its disease.")
|
| 68 |
+
|
| 69 |
+
# Centered interface below header
|
| 70 |
+
with gr.Row():
|
| 71 |
+
with gr.Column(scale=1):
|
| 72 |
+
gr.Markdown("") # left spacer
|
| 73 |
+
with gr.Column(scale=2, min_width=500):
|
| 74 |
+
gr.Interface(
|
| 75 |
+
fn=predict,
|
| 76 |
+
inputs=gr.Image(type="pil"),
|
| 77 |
+
outputs="text",
|
| 78 |
+
description="Upload a plant image to classify its disease."
|
| 79 |
+
)
|
| 80 |
+
with gr.Column(scale=1):
|
| 81 |
+
gr.Markdown("") # right spacer
|
| 82 |
|
| 83 |
if __name__ == "__main__":
|
| 84 |
demo.launch(server_port=7860, server_name="127.0.0.1")
|