rongo1 commited on
Commit
1fe0c11
Β·
1 Parent(s): d5b9946

Fix Gradio component JSON schema errors for HF Spaces

Browse files
Files changed (1) hide show
  1. app.py +6 -17
app.py CHANGED
@@ -525,24 +525,18 @@ with gr.Blocks(title="Business Card Data Extractor") as demo:
525
  image_input = gr.File(
526
  label="Upload Business Cards",
527
  file_count="multiple",
528
- file_types=["image"],
529
- type="filepath"
530
  )
531
 
532
  model_selector = gr.Dropdown(
533
- choices=[
534
- ("Gemini 2.5 Pro (Higher Quality, More Accurate)", "gemini-2.5-pro"),
535
- ("Gemini 2.5 Flash (Faster, Cost-effective)", "gemini-2.5-flash")
536
- ],
537
  value="gemini-2.5-flash",
538
- label="πŸ€– AI Model Selection",
539
- info="Choose between speed (Flash) or accuracy (Pro)"
540
  )
541
 
542
  save_images_checkbox = gr.Checkbox(
543
  value=True,
544
- label="πŸ’Ύ Save Business Card Images",
545
- info="Save uploaded images to business_cards folder and include paths in database"
546
  )
547
 
548
  process_btn = gr.Button("Process Business Cards", variant="primary")
@@ -552,7 +546,7 @@ with gr.Blocks(title="Business Card Data Extractor") as demo:
552
  total_file = gr.File(label="πŸ“Š Download Total Database")
553
  status_output = gr.Textbox(label="Processing Status", lines=5)
554
 
555
- preview_output = gr.Dataframe(label="Data Preview (Current Run)", interactive=False)
556
 
557
  # Wrapper function for better error handling and logging
558
  def process_with_logging(images, model_name, save_images):
@@ -591,12 +585,7 @@ with gr.Blocks(title="Business Card Data Extractor") as demo:
591
  if __name__ == "__main__":
592
  logger.info("Starting Gradio demo")
593
  try:
594
- # For Hugging Face Spaces compatibility
595
- demo.launch(
596
- server_name="0.0.0.0",
597
- server_port=7860,
598
- share=False
599
- )
600
  except KeyboardInterrupt:
601
  logger.info("Application stopped by user (Ctrl+C)")
602
  except Exception as e:
 
525
  image_input = gr.File(
526
  label="Upload Business Cards",
527
  file_count="multiple",
528
+ file_types=["image"]
 
529
  )
530
 
531
  model_selector = gr.Dropdown(
532
+ choices=["gemini-2.5-flash", "gemini-2.5-pro"],
 
 
 
533
  value="gemini-2.5-flash",
534
+ label="AI Model Selection"
 
535
  )
536
 
537
  save_images_checkbox = gr.Checkbox(
538
  value=True,
539
+ label="Save Business Card Images"
 
540
  )
541
 
542
  process_btn = gr.Button("Process Business Cards", variant="primary")
 
546
  total_file = gr.File(label="πŸ“Š Download Total Database")
547
  status_output = gr.Textbox(label="Processing Status", lines=5)
548
 
549
+ preview_output = gr.Dataframe(label="Data Preview (Current Run)")
550
 
551
  # Wrapper function for better error handling and logging
552
  def process_with_logging(images, model_name, save_images):
 
585
  if __name__ == "__main__":
586
  logger.info("Starting Gradio demo")
587
  try:
588
+ demo.launch()
 
 
 
 
 
589
  except KeyboardInterrupt:
590
  logger.info("Application stopped by user (Ctrl+C)")
591
  except Exception as e: