Spaces:
Runtime error
Runtime error
Download app.py from Haseeb005/aiiproject2: direct link, hf CLI and curl.
- Browser
- Download file 546 Bytes
-
https://huggingface.co/spaces/Haseeb005/aiiproject2/resolve/main/app.py
- Command line
-
hf download hf://spaces/Haseeb005/aiiproject2/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Haseeb005/aiiproject2/resolve/main/app.py
546 Bytes
| import gradio as gr | |
| import joblib # or torch, tensorflow, etc. | |
| import numpy as np | |
| from PIL import Image | |
| model = joblib.load("model.pkl") # Replace with your model | |
| def predict(image): | |
| # Preprocess image | |
| img_array = np.array(image.resize((224, 224))) / 255.0 | |
| img_array = img_array.reshape(1, 224, 224, 3) | |
| # Predict | |
| prediction = model.predict(img_array) | |
| return f"Disease: {prediction[0]}" | |
| gr.Interface( | |
| fn=predict, | |
| inputs=gr.Image(type="pil"), | |
| outputs="text", | |
| title="Plant Disease Detector", | |
| ).launch() | |