Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -201,7 +201,6 @@ def generate_pdf(accuracy, roc_score, report_html, confusion_matrix_plot):
|
|
201 |
buffer = BytesIO()
|
202 |
c = canvas.Canvas(buffer, pagesize=letter)
|
203 |
|
204 |
-
# Add content to PDF
|
205 |
c.drawString(100, 750, f"Model Results")
|
206 |
c.drawString(100, 730, f"Accuracy: {accuracy:.2f}")
|
207 |
c.drawString(100, 710, f"ROC Score: {roc_score:.2f}")
|
@@ -214,7 +213,6 @@ def generate_pdf(accuracy, roc_score, report_html, confusion_matrix_plot):
|
|
214 |
c.drawString(100, y_position, line.strip())
|
215 |
y_position -= 20
|
216 |
|
217 |
-
# Save Confusion Matrix Plot as an Image and Add it to the PDF
|
218 |
img_buffer = BytesIO()
|
219 |
confusion_matrix_plot.savefig(img_buffer, format="png")
|
220 |
img_buffer.seek(0)
|
@@ -224,6 +222,16 @@ def generate_pdf(accuracy, roc_score, report_html, confusion_matrix_plot):
|
|
224 |
buffer.seek(0)
|
225 |
return buffer
|
226 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
detector = AIDetector()
|
228 |
|
229 |
def create_gradio_interface():
|
@@ -247,16 +255,15 @@ def create_gradio_interface():
|
|
247 |
output_label = gr.Label(label="Output")
|
248 |
|
249 |
with gr.Tab("Batch Image Processing"):
|
250 |
-
with gr.Accordion("Upload Zip File
|
251 |
zip_file = gr.File(
|
252 |
label="Upload Zip (must contain 'real' and 'ai' folders)",
|
253 |
file_types=[".zip"],
|
254 |
-
file_count="single"
|
255 |
-
max_file_size=100 # 100 MB limit
|
256 |
)
|
257 |
zip_process_btn = gr.Button("Process Zip", interactive=False)
|
258 |
|
259 |
-
with gr.Accordion("Upload Individual Files
|
260 |
with gr.Row():
|
261 |
ai_files = gr.File(
|
262 |
label="Upload AI Images",
|
@@ -326,10 +333,10 @@ def create_gradio_interface():
|
|
326 |
|
327 |
def reset_interface():
|
328 |
return [
|
329 |
-
None, None, None, None, None,
|
330 |
-
gr.Button.update(interactive=False),
|
331 |
-
gr.Button.update(interactive=False),
|
332 |
-
None, None, None, None, None
|
333 |
]
|
334 |
|
335 |
reset_btn.click(
|
|
|
201 |
buffer = BytesIO()
|
202 |
c = canvas.Canvas(buffer, pagesize=letter)
|
203 |
|
|
|
204 |
c.drawString(100, 750, f"Model Results")
|
205 |
c.drawString(100, 730, f"Accuracy: {accuracy:.2f}")
|
206 |
c.drawString(100, 710, f"ROC Score: {roc_score:.2f}")
|
|
|
213 |
c.drawString(100, y_position, line.strip())
|
214 |
y_position -= 20
|
215 |
|
|
|
216 |
img_buffer = BytesIO()
|
217 |
confusion_matrix_plot.savefig(img_buffer, format="png")
|
218 |
img_buffer.seek(0)
|
|
|
222 |
buffer.seek(0)
|
223 |
return buffer
|
224 |
|
225 |
+
def load_url(url):
|
226 |
+
try:
|
227 |
+
urllib.request.urlretrieve(url, "temp_image.png")
|
228 |
+
image = Image.open("temp_image.png")
|
229 |
+
message = "Image Loaded"
|
230 |
+
except Exception as e:
|
231 |
+
image = None
|
232 |
+
message = f"Image not Found<br>Error: {e}"
|
233 |
+
return image, message
|
234 |
+
|
235 |
detector = AIDetector()
|
236 |
|
237 |
def create_gradio_interface():
|
|
|
255 |
output_label = gr.Label(label="Output")
|
256 |
|
257 |
with gr.Tab("Batch Image Processing"):
|
258 |
+
with gr.Accordion("Upload Zip File", open=False):
|
259 |
zip_file = gr.File(
|
260 |
label="Upload Zip (must contain 'real' and 'ai' folders)",
|
261 |
file_types=[".zip"],
|
262 |
+
file_count="single"
|
|
|
263 |
)
|
264 |
zip_process_btn = gr.Button("Process Zip", interactive=False)
|
265 |
|
266 |
+
with gr.Accordion("Upload Individual Files", open=False):
|
267 |
with gr.Row():
|
268 |
ai_files = gr.File(
|
269 |
label="Upload AI Images",
|
|
|
333 |
|
334 |
def reset_interface():
|
335 |
return [
|
336 |
+
None, None, None, None, None,
|
337 |
+
gr.Button.update(interactive=False),
|
338 |
+
gr.Button.update(interactive=False),
|
339 |
+
None, None, None, None, None
|
340 |
]
|
341 |
|
342 |
reset_btn.click(
|