Update app.py
Browse files
app.py
CHANGED
@@ -37,11 +37,17 @@ transform = transforms.Compose([
|
|
37 |
# Logging setup
|
38 |
log_path = "prediction_logs.csv"
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
def log_prediction(filename, prediction, confidence):
|
41 |
timestamp = datetime.datetime.now().isoformat()
|
42 |
row = [timestamp, filename, prediction, f"{confidence:.4f}"]
|
43 |
|
44 |
-
print("⏺ Logging prediction:", row)
|
45 |
|
46 |
with open(log_path, mode='a', newline='') as file:
|
47 |
writer = csv.writer(file)
|
@@ -84,7 +90,3 @@ gr.Interface(
|
|
84 |
title="Diabetic Retinopathy Detection",
|
85 |
description="Upload a retinal image to classify DR and view Grad-CAM heatmap. All predictions are logged for analysis."
|
86 |
).launch()
|
87 |
-
s=[cam_output, prediction_output]
|
88 |
-
)
|
89 |
-
|
90 |
-
demo.launch()
|
|
|
37 |
# Logging setup
|
38 |
log_path = "prediction_logs.csv"
|
39 |
|
40 |
+
# Create the CSV file with headers if it doesn't exist
|
41 |
+
if not os.path.exists(log_path):
|
42 |
+
with open(log_path, mode='w', newline='') as file:
|
43 |
+
writer = csv.writer(file)
|
44 |
+
writer.writerow(["timestamp", "image_name", "prediction", "confidence"])
|
45 |
+
|
46 |
def log_prediction(filename, prediction, confidence):
|
47 |
timestamp = datetime.datetime.now().isoformat()
|
48 |
row = [timestamp, filename, prediction, f"{confidence:.4f}"]
|
49 |
|
50 |
+
print("⏺ Logging prediction:", row)
|
51 |
|
52 |
with open(log_path, mode='a', newline='') as file:
|
53 |
writer = csv.writer(file)
|
|
|
90 |
title="Diabetic Retinopathy Detection",
|
91 |
description="Upload a retinal image to classify DR and view Grad-CAM heatmap. All predictions are logged for analysis."
|
92 |
).launch()
|
|
|
|
|
|
|
|