Spaces:
Runtime error
Runtime error
Commit
Β·
64df5a3
1
Parent(s):
275f52e
V0
Browse files
app.py
CHANGED
|
@@ -635,21 +635,6 @@ def create_gradio_interface():
|
|
| 635 |
|
| 636 |
try:
|
| 637 |
import torch
|
| 638 |
-
output.append(f"**PyTorch:** {torch.__version__}")
|
| 639 |
-
output.append(f"**CUDA Available:** {'Yes β
' if torch.cuda.is_available() else 'No β'}")
|
| 640 |
-
if torch.cuda.is_available():
|
| 641 |
-
output.append(f"**GPU:** {torch.cuda.get_device_name(0)}")
|
| 642 |
-
output.append(f"**MPS Available:** {'Yes β
' if hasattr(torch.backends, 'mps') and torch.backends.mps.is_available() else 'No β'}")
|
| 643 |
-
except ImportError:
|
| 644 |
-
output.append("**PyTorch:** Not installed β")
|
| 645 |
-
|
| 646 |
-
output.append("\n## Model Files")
|
| 647 |
-
|
| 648 |
-
# Check model files
|
| 649 |
-
if os.path.exists(DEFAULT_DAMAGE_MODEL_PATH):
|
| 650 |
-
file_size = os.path.getsize(DEFAULT_DAMAGE_MODEL_PATH) / (1024 * 1024) # Size in MB
|
| 651 |
-
output.append(f"**Damage Model:** Available β
({file_size:.2f} MB)")
|
| 652 |
-
else:
|
| 653 |
output.append(f"**Damage Model:** Not found β at {DEFAULT_DAMAGE_MODEL_PATH}")
|
| 654 |
|
| 655 |
if os.path.exists(DEFAULT_DEEPFAKE_MODEL_PATH):
|
|
@@ -788,7 +773,7 @@ def create_gradio_interface():
|
|
| 788 |
outputs=[output_image, output_text],
|
| 789 |
fn=lambda x: process_image(
|
| 790 |
x, DEFAULT_DAMAGE_MODEL_PATH, DEFAULT_DEEPFAKE_MODEL_PATH,
|
| 791 |
-
0.7, 0.5, False, "auto"
|
| 792 |
),
|
| 793 |
cache_examples=True
|
| 794 |
)
|
|
@@ -803,16 +788,17 @@ def create_gradio_interface():
|
|
| 803 |
damage_threshold,
|
| 804 |
deepfake_threshold,
|
| 805 |
skip_damage,
|
| 806 |
-
device
|
|
|
|
| 807 |
],
|
| 808 |
-
outputs=[output_image, output_text]
|
| 809 |
)
|
| 810 |
|
| 811 |
# Clear button functionality
|
| 812 |
clear_btn.click(
|
| 813 |
-
fn=lambda: [None, ""],
|
| 814 |
inputs=[],
|
| 815 |
-
outputs=[output_image, output_text]
|
| 816 |
)
|
| 817 |
|
| 818 |
# System diagnostic buttons
|
|
@@ -835,10 +821,17 @@ def create_gradio_interface():
|
|
| 835 |
outputs=paths_result
|
| 836 |
)
|
| 837 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 838 |
return app
|
| 839 |
|
| 840 |
if __name__ == "__main__":
|
| 841 |
|
| 842 |
# Create and launch the Gradio app
|
| 843 |
app = create_gradio_interface()
|
| 844 |
-
app.launch(share=False) # Set share=True to create a public
|
|
|
|
| 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):
|
|
|
|
| 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
|
| 777 |
),
|
| 778 |
cache_examples=True
|
| 779 |
)
|
|
|
|
| 788 |
damage_threshold,
|
| 789 |
deepfake_threshold,
|
| 790 |
skip_damage,
|
| 791 |
+
device,
|
| 792 |
+
usage_counter # Add the usage counter state here
|
| 793 |
],
|
| 794 |
+
outputs=[output_image, output_text, usage_counter] # Update usage counter in outputs
|
| 795 |
)
|
| 796 |
|
| 797 |
# Clear button functionality
|
| 798 |
clear_btn.click(
|
| 799 |
+
fn=lambda: [None, "", 0], # Reset usage counter to 0 when clearing
|
| 800 |
inputs=[],
|
| 801 |
+
outputs=[output_image, output_text, usage_counter]
|
| 802 |
)
|
| 803 |
|
| 804 |
# System diagnostic buttons
|
|
|
|
| 821 |
outputs=paths_result
|
| 822 |
)
|
| 823 |
|
| 824 |
+
# Update usage display when counter changes
|
| 825 |
+
usage_counter.change(
|
| 826 |
+
fn=lambda count: f"**Usage: {count}/{MAX_TRIES}**",
|
| 827 |
+
inputs=[usage_counter],
|
| 828 |
+
outputs=[usage_display]
|
| 829 |
+
)
|
| 830 |
+
|
| 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__}")
|