JKrishnanandhaa commited on
Commit
78f065c
·
verified ·
1 Parent(s): 5f84c07

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -11
app.py CHANGED
@@ -218,7 +218,7 @@ class ForgeryDetector:
218
  # Create HTML response
219
  results_html = self._create_html_report(results)
220
 
221
- return original_image, overlay, gauge_dice, gauge_accuracy, results_html
222
 
223
  def _create_overlay(self, image, results):
224
  """Create overlay visualization"""
@@ -312,15 +312,15 @@ def detect_forgery(file):
312
  try:
313
  if file is None:
314
  empty_html = "<div style='padding:12px; border:1px solid #d9534f; border-radius:8px;'>❌ <b>No file uploaded.</b></div>"
315
- return None, None, None, None, empty_html
316
 
317
  # Get file path
318
  file_path = file if isinstance(file, str) else file
319
 
320
  # Detect forgeries
321
- original, overlay, gauge_dice, gauge_acc, results_html = detector.detect(file_path)
322
 
323
- return original, overlay, gauge_dice, gauge_acc, results_html
324
 
325
  except Exception as e:
326
  import traceback
@@ -331,7 +331,7 @@ def detect_forgery(file):
331
  ❌ <b>Error:</b> {str(e)}
332
  </div>
333
  """
334
- return None, None, None, None, error_html
335
 
336
 
337
  # Custom CSS - subtle styling
@@ -384,9 +384,7 @@ with gr.Blocks(css=custom_css) as demo:
384
 
385
  with gr.Column(scale=2):
386
  gr.Markdown("### Detection Results")
387
- with gr.Row():
388
- original_image = gr.Image(label="Original Document", type="numpy")
389
- output_image = gr.Image(label="Detected Forgeries", type="numpy")
390
 
391
  with gr.Row():
392
  with gr.Column(scale=1):
@@ -414,13 +412,13 @@ with gr.Blocks(css=custom_css) as demo:
414
  analyze_btn.click(
415
  fn=detect_forgery,
416
  inputs=[input_file],
417
- outputs=[original_image, output_image, gauge_dice, gauge_accuracy, output_html]
418
  )
419
 
420
  clear_btn.click(
421
- fn=lambda: (None, None, None, None, None, "<i>No analysis yet. Upload a document and click Analyze.</i>"),
422
  inputs=None,
423
- outputs=[input_file, original_image, output_image, gauge_dice, gauge_accuracy, output_html]
424
  )
425
 
426
 
 
218
  # Create HTML response
219
  results_html = self._create_html_report(results)
220
 
221
+ return overlay, gauge_dice, gauge_accuracy, results_html
222
 
223
  def _create_overlay(self, image, results):
224
  """Create overlay visualization"""
 
312
  try:
313
  if file is None:
314
  empty_html = "<div style='padding:12px; border:1px solid #d9534f; border-radius:8px;'>❌ <b>No file uploaded.</b></div>"
315
+ return None, None, None, empty_html
316
 
317
  # Get file path
318
  file_path = file if isinstance(file, str) else file
319
 
320
  # Detect forgeries
321
+ overlay, gauge_dice, gauge_acc, results_html = detector.detect(file_path)
322
 
323
+ return overlay, gauge_dice, gauge_acc, results_html
324
 
325
  except Exception as e:
326
  import traceback
 
331
  ❌ <b>Error:</b> {str(e)}
332
  </div>
333
  """
334
+ return None, None, None, error_html
335
 
336
 
337
  # Custom CSS - subtle styling
 
384
 
385
  with gr.Column(scale=2):
386
  gr.Markdown("### Detection Results")
387
+ output_image = gr.Image(label="Detected Forgeries", type="numpy")
 
 
388
 
389
  with gr.Row():
390
  with gr.Column(scale=1):
 
412
  analyze_btn.click(
413
  fn=detect_forgery,
414
  inputs=[input_file],
415
+ outputs=[output_image, gauge_dice, gauge_accuracy, output_html]
416
  )
417
 
418
  clear_btn.click(
419
+ fn=lambda: (None, None, None, None, "<i>No analysis yet. Upload a document and click Analyze.</i>"),
420
  inputs=None,
421
+ outputs=[input_file, output_image, gauge_dice, gauge_accuracy, output_html]
422
  )
423
 
424