JKrishnanandhaa commited on
Commit
1dd4d9d
·
verified ·
1 Parent(s): 36c9274

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -10
app.py CHANGED
@@ -309,14 +309,10 @@ def detect_forgery(file):
309
  return None, None, None, None, empty_html
310
 
311
  # Get file path
312
- file_path = file.name if hasattr(file, 'name') else file
313
 
314
- # Check if PDF
315
- if file_path.lower().endswith('.pdf'):
316
- original, overlay, gauge_dice, gauge_acc, results_html = detector.detect(file_path)
317
- else:
318
- image = Image.open(file_path)
319
- original, overlay, gauge_dice, gauge_acc, results_html = detector.detect(image)
320
 
321
  return original, overlay, gauge_dice, gauge_acc, results_html
322
 
@@ -357,10 +353,10 @@ with gr.Blocks(css=custom_css) as demo:
357
  with gr.Row():
358
  with gr.Column(scale=1):
359
  gr.Markdown("### Upload Document")
360
- input_file = gr.File(
361
  label="Document (Image or PDF)",
362
- file_types=["image", ".pdf"],
363
- type="filepath"
364
  )
365
 
366
  with gr.Row():
 
309
  return None, None, None, None, empty_html
310
 
311
  # Get file path
312
+ file_path = file if isinstance(file, str) else file
313
 
314
+ # Detect forgeries
315
+ original, overlay, gauge_dice, gauge_acc, results_html = detector.detect(file_path)
 
 
 
 
316
 
317
  return original, overlay, gauge_dice, gauge_acc, results_html
318
 
 
353
  with gr.Row():
354
  with gr.Column(scale=1):
355
  gr.Markdown("### Upload Document")
356
+ input_file = gr.Image(
357
  label="Document (Image or PDF)",
358
+ type="filepath",
359
+ sources=["upload"]
360
  )
361
 
362
  with gr.Row():