Update app.py
Browse files
app.py
CHANGED
@@ -100,10 +100,13 @@ def predict_image(img, confidence_threshold):
|
|
100 |
# Check if either class meets the confidence threshold
|
101 |
if result_2['AI Image'] >= confidence_threshold:
|
102 |
label_2 = f"AI, Confidence: {result_2['AI Image']:.4f}"
|
|
|
103 |
elif result_2['Real Image'] >= confidence_threshold:
|
104 |
label_2 = f"Real, Confidence: {result_2['Real Image']:.4f}"
|
|
|
105 |
else:
|
106 |
label_2 = "Uncertain Classification"
|
|
|
107 |
except Exception as e:
|
108 |
label_2 = f"Error: {str(e)}"
|
109 |
|
@@ -127,10 +130,13 @@ def predict_image(img, confidence_threshold):
|
|
127 |
# Check if either class meets the confidence threshold
|
128 |
if result_3['AI'] >= confidence_threshold:
|
129 |
label_3 = f"AI, Confidence: {result_3['AI']:.4f}"
|
|
|
130 |
elif result_3['Real'] >= confidence_threshold:
|
131 |
label_3 = f"Real, Confidence: {result_3['Real']:.4f}"
|
|
|
132 |
else:
|
133 |
label_3 = "Uncertain Classification"
|
|
|
134 |
except Exception as e:
|
135 |
label_3 = f"Error: {str(e)}"
|
136 |
|
@@ -154,17 +160,20 @@ def predict_image(img, confidence_threshold):
|
|
154 |
# Check if either class meets the confidence threshold
|
155 |
if result_4['AI'] >= confidence_threshold:
|
156 |
label_4 = f"AI, Confidence: {result_4['AI']:.4f}"
|
|
|
157 |
elif result_4['Real'] >= confidence_threshold:
|
158 |
label_4 = f"Real, Confidence: {result_4['Real']:.4f}"
|
|
|
159 |
else:
|
160 |
label_4 = "Uncertain Classification"
|
|
|
161 |
except Exception as e:
|
162 |
label_4 = f"Error: {str(e)}"
|
163 |
|
164 |
try:
|
165 |
img_bytes = convert_pil_to_bytes(img_pil)
|
166 |
|
167 |
-
print(
|
168 |
print(img_bytes)
|
169 |
|
170 |
response5_raw = call_inference(img_bytes)
|
|
|
100 |
# Check if either class meets the confidence threshold
|
101 |
if result_2['AI Image'] >= confidence_threshold:
|
102 |
label_2 = f"AI, Confidence: {result_2['AI Image']:.4f}"
|
103 |
+
result_2output += ['AI']
|
104 |
elif result_2['Real Image'] >= confidence_threshold:
|
105 |
label_2 = f"Real, Confidence: {result_2['Real Image']:.4f}"
|
106 |
+
result_2output += ['REAL']
|
107 |
else:
|
108 |
label_2 = "Uncertain Classification"
|
109 |
+
result_2output += ['UNCERTAIN']
|
110 |
except Exception as e:
|
111 |
label_2 = f"Error: {str(e)}"
|
112 |
|
|
|
130 |
# Check if either class meets the confidence threshold
|
131 |
if result_3['AI'] >= confidence_threshold:
|
132 |
label_3 = f"AI, Confidence: {result_3['AI']:.4f}"
|
133 |
+
result_3output += ['AI']
|
134 |
elif result_3['Real'] >= confidence_threshold:
|
135 |
label_3 = f"Real, Confidence: {result_3['Real']:.4f}"
|
136 |
+
result_3output += ['REAL']
|
137 |
else:
|
138 |
label_3 = "Uncertain Classification"
|
139 |
+
result_3output += ['UNCERTAIN']
|
140 |
except Exception as e:
|
141 |
label_3 = f"Error: {str(e)}"
|
142 |
|
|
|
160 |
# Check if either class meets the confidence threshold
|
161 |
if result_4['AI'] >= confidence_threshold:
|
162 |
label_4 = f"AI, Confidence: {result_4['AI']:.4f}"
|
163 |
+
result_4output += ['AI']
|
164 |
elif result_4['Real'] >= confidence_threshold:
|
165 |
label_4 = f"Real, Confidence: {result_4['Real']:.4f}"
|
166 |
+
result_4output += ['REAL']
|
167 |
else:
|
168 |
label_4 = "Uncertain Classification"
|
169 |
+
result_4output += ['UNCERTAIN']
|
170 |
except Exception as e:
|
171 |
label_4 = f"Error: {str(e)}"
|
172 |
|
173 |
try:
|
174 |
img_bytes = convert_pil_to_bytes(img_pil)
|
175 |
|
176 |
+
print(img)
|
177 |
print(img_bytes)
|
178 |
|
179 |
response5_raw = call_inference(img_bytes)
|