Spaces:
Sleeping
Sleeping
iamomtiwari
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -45,11 +45,9 @@ def predict(image):
|
|
45 |
predicted_label = labels_list[predicted_class_idx]
|
46 |
|
47 |
# Ask user if the prediction is correct
|
48 |
-
user_feedback = gr.inputs.Textbox(visible=False, default="Please provide feedback on the model prediction.")
|
49 |
-
|
50 |
if predicted_class_idx < len(class_labels): # It's a crop disease
|
51 |
treatment_advice = class_labels[predicted_class_idx + 1]["treatment"]
|
52 |
-
return f"Disease: {predicted_label}\n\nTreatment Advice: {treatment_advice}\n\nIs this prediction correct? (yes/no)"
|
53 |
else:
|
54 |
# If not a crop disease, use the fallback model (ResNet50) for general object detection
|
55 |
inputs_fallback = fallback_feature_extractor(images=image, return_tensors="pt")
|
@@ -59,8 +57,8 @@ def predict(image):
|
|
59 |
|
60 |
# Get the fallback prediction label
|
61 |
fallback_label = fallback_model.config.id2label[predicted_class_idx_fallback]
|
62 |
-
return f"Fallback Prediction (Not a Crop): {fallback_label}\n\nIs this prediction correct? (yes/no)"
|
63 |
|
64 |
# Create Gradio Interface
|
65 |
-
interface = gr.Interface(fn=predict, inputs="image", outputs=
|
66 |
interface.launch()
|
|
|
45 |
predicted_label = labels_list[predicted_class_idx]
|
46 |
|
47 |
# Ask user if the prediction is correct
|
|
|
|
|
48 |
if predicted_class_idx < len(class_labels): # It's a crop disease
|
49 |
treatment_advice = class_labels[predicted_class_idx + 1]["treatment"]
|
50 |
+
return f"Disease: {predicted_label}\n\nTreatment Advice: {treatment_advice}\n\nIs this prediction correct? (yes/no)"
|
51 |
else:
|
52 |
# If not a crop disease, use the fallback model (ResNet50) for general object detection
|
53 |
inputs_fallback = fallback_feature_extractor(images=image, return_tensors="pt")
|
|
|
57 |
|
58 |
# Get the fallback prediction label
|
59 |
fallback_label = fallback_model.config.id2label[predicted_class_idx_fallback]
|
60 |
+
return f"Fallback Prediction (Not a Crop): {fallback_label}\n\nIs this prediction correct? (yes/no)"
|
61 |
|
62 |
# Create Gradio Interface
|
63 |
+
interface = gr.Interface(fn=predict, inputs="image", outputs="text")
|
64 |
interface.launch()
|