Spaces:
Sleeping
Sleeping
add flag_prediction
Browse files
ui/app.py
CHANGED
|
@@ -77,7 +77,29 @@ class PlantDiseaseApp:
|
|
| 77 |
except Exception as e:
|
| 78 |
return None, f"Error during prediction: {str(e)}", ""
|
| 79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
def create_interface():
|
| 83 |
app = PlantDiseaseApp()
|
|
|
|
| 77 |
except Exception as e:
|
| 78 |
return None, f"Error during prediction: {str(e)}", ""
|
| 79 |
|
| 80 |
+
def flag_prediction(self, image, result_info, feedback_text):
|
| 81 |
+
if image is None:
|
| 82 |
+
return "No image uploaded."
|
| 83 |
+
|
| 84 |
+
if not feedback_text.strip():
|
| 85 |
+
return "Please enter feedback before submitting."
|
| 86 |
|
| 87 |
+
try:
|
| 88 |
+
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 89 |
+
|
| 90 |
+
entry = {
|
| 91 |
+
"timestamp": timestamp,
|
| 92 |
+
"feedback": feedback_text,
|
| 93 |
+
"model": self.current_modelName,
|
| 94 |
+
"result_info": result_info
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
self.flagged_predictions.append(entry)
|
| 98 |
+
|
| 99 |
+
return "Thanks! Your feedback has been recorded."
|
| 100 |
+
|
| 101 |
+
except Exception as e:
|
| 102 |
+
return f"Error saving feedback: {str(e)}"
|
| 103 |
|
| 104 |
def create_interface():
|
| 105 |
app = PlantDiseaseApp()
|