seifbenayed commited on
Commit
9bd1724
Β·
1 Parent(s): 64df5a3
Files changed (1) hide show
  1. app.py +23 -5
app.py CHANGED
@@ -615,7 +615,8 @@ def create_gradio_interface():
615
  with gr.Accordion("Analysis Details", open=True):
616
  output_text = gr.Markdown(label="Detection Results")
617
 
618
- # Diagnostics Tab
 
619
  with gr.Tab("System Diagnostics"):
620
  with gr.Row():
621
  run_diagnostic_btn = gr.Button("Run Diagnostics", variant="primary")
@@ -635,6 +636,21 @@ def create_gradio_interface():
635
 
636
  try:
637
  import torch
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
638
  output.append(f"**Damage Model:** Not found ❌ at {DEFAULT_DAMAGE_MODEL_PATH}")
639
 
640
  if os.path.exists(DEFAULT_DEEPFAKE_MODEL_PATH):
@@ -704,8 +720,8 @@ def create_gradio_interface():
704
  output.append("\n**Note:** You may need to restart the application for changes to take effect.")
705
 
706
  return "\n".join(output)
707
-
708
- # Settings Tab
709
  with gr.Tab("Settings"):
710
  gr.Markdown("## Model Settings")
711
 
@@ -770,7 +786,7 @@ def create_gradio_interface():
770
  gr.Examples(
771
  examples=example_inputs,
772
  inputs=input_image,
773
- outputs=[output_image, output_text],
774
  fn=lambda x: process_image(
775
  x, DEFAULT_DAMAGE_MODEL_PATH, DEFAULT_DEEPFAKE_MODEL_PATH,
776
  0.7, 0.5, False, "auto", 0 # Added initial usage_count value of 0
@@ -831,7 +847,9 @@ def create_gradio_interface():
831
  return app
832
 
833
  if __name__ == "__main__":
 
 
834
 
835
  # Create and launch the Gradio app
836
  app = create_gradio_interface()
837
- app.launch(share=False) # Set share=True to create a public linkf"**PyTorch:** {torch.__version__}")
 
615
  with gr.Accordion("Analysis Details", open=True):
616
  output_text = gr.Markdown(label="Detection Results")
617
 
618
+ # This is the continuation of the code, starting from the System Diagnostics tab
619
+
620
  with gr.Tab("System Diagnostics"):
621
  with gr.Row():
622
  run_diagnostic_btn = gr.Button("Run Diagnostics", variant="primary")
 
636
 
637
  try:
638
  import torch
639
+ output.append(f"**PyTorch:** {torch.__version__}")
640
+ output.append(f"**CUDA Available:** {'Yes βœ…' if torch.cuda.is_available() else 'No ❌'}")
641
+ if torch.cuda.is_available():
642
+ output.append(f"**GPU:** {torch.cuda.get_device_name(0)}")
643
+ output.append(f"**MPS Available:** {'Yes βœ…' if hasattr(torch.backends, 'mps') and torch.backends.mps.is_available() else 'No ❌'}")
644
+ except ImportError:
645
+ output.append("**PyTorch:** Not installed ❌")
646
+
647
+ output.append("\n## Model Files")
648
+
649
+ # Check model files
650
+ if os.path.exists(DEFAULT_DAMAGE_MODEL_PATH):
651
+ file_size = os.path.getsize(DEFAULT_DAMAGE_MODEL_PATH) / (1024 * 1024) # Size in MB
652
+ output.append(f"**Damage Model:** Available βœ… ({file_size:.2f} MB)")
653
+ else:
654
  output.append(f"**Damage Model:** Not found ❌ at {DEFAULT_DAMAGE_MODEL_PATH}")
655
 
656
  if os.path.exists(DEFAULT_DEEPFAKE_MODEL_PATH):
 
720
  output.append("\n**Note:** You may need to restart the application for changes to take effect.")
721
 
722
  return "\n".join(output)
723
+
724
+ # Settings Tab
725
  with gr.Tab("Settings"):
726
  gr.Markdown("## Model Settings")
727
 
 
786
  gr.Examples(
787
  examples=example_inputs,
788
  inputs=input_image,
789
+ outputs=[output_image, output_text, usage_counter], # Add usage_counter to outputs
790
  fn=lambda x: process_image(
791
  x, DEFAULT_DAMAGE_MODEL_PATH, DEFAULT_DEEPFAKE_MODEL_PATH,
792
  0.7, 0.5, False, "auto", 0 # Added initial usage_count value of 0
 
847
  return app
848
 
849
  if __name__ == "__main__":
850
+ # Check if dependencies are installed
851
+ auto_install_dependencies()
852
 
853
  # Create and launch the Gradio app
854
  app = create_gradio_interface()
855
+ app.launch(share=False) # Set share=True to create a public link