Teamtheo613 commited on
Commit
0fccf00
Β·
verified Β·
1 Parent(s): 26c5e9c

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -104
app.py DELETED
@@ -1,104 +0,0 @@
1
- #!/usr/bin/env python3
2
- import os
3
- import sys
4
- import subprocess
5
- import gradio as gr
6
- import torch
7
-
8
- sys.path.insert(0, '/app/FunGen')
9
-
10
- def process_video(video, mode, overwrite, autotune):
11
- """Process video with FunGen"""
12
- print(f"[DEBUG] Called with video={video}, mode={mode}, overwrite={overwrite}, autotune={autotune}")
13
-
14
- if video is None:
15
- return "❌ No video uploaded", None
16
-
17
- try:
18
- input_path = video
19
- print(f"[DEBUG] Input path: {input_path}")
20
-
21
- if not os.path.exists(input_path):
22
- return f"❌ File not found: {input_path}", None
23
-
24
- file_size_mb = os.path.getsize(input_path) / (1024**2)
25
- status = f"πŸš€ Processing: {os.path.basename(input_path)}\n"
26
- status += f"πŸ“ Size: {file_size_mb:.1f} MB\n"
27
- status += f"βš™οΈ Mode: {mode}\n"
28
- status += f"⏳ Starting...\n\n"
29
-
30
- print(f"[DEBUG] Status: {status}")
31
-
32
- cmd = ["python", "/app/FunGen/main.py", input_path, "--mode", mode, "--skip-dependency-check"]
33
- if overwrite:
34
- cmd.append("--overwrite")
35
- if not autotune:
36
- cmd.append("--no-autotune")
37
-
38
- print(f"[DEBUG] Command: {' '.join(cmd)}")
39
-
40
- # Set environment to suppress FunGen checks
41
- env = os.environ.copy()
42
- env['PYTHONDONTWRITEBYTECODE'] = '1'
43
-
44
- result = subprocess.run(cmd, cwd="/app/FunGen", capture_output=True, text=True, timeout=3600, env=env)
45
-
46
- # Check if processing succeeded despite dependency warnings
47
- if "ERROR" in result.stderr and "torch-tensorrt" not in result.stderr:
48
- error = f"❌ Error:\n{result.stderr}"
49
- print(f"[DEBUG] Error: {error}")
50
- return error, None
51
-
52
- # If torch-tensorrt warning but funscript was generated, that's OK
53
- if os.path.exists("/app/FunGen/output"):
54
- for root, dirs, files in os.walk("/app/FunGen/output"):
55
- for f in files:
56
- if f.endswith(".funscript") and not f.endswith(".roll.funscript"):
57
- output_file = os.path.join(root, f)
58
- status += f"βœ… Complete!\nπŸ“œ {os.path.basename(output_file)}"
59
- print(f"[DEBUG] Success: {status}")
60
- return status, output_file
61
-
62
- # No output found
63
- status += f"⚠️ Processing completed but no funscript found"
64
- print(f"[DEBUG] No output: {status}")
65
- return status, None
66
-
67
- except Exception as e:
68
- error = f"❌ Exception: {str(e)}"
69
- print(f"[DEBUG] Exception: {error}")
70
- import traceback
71
- print(traceback.format_exc())
72
- return error, None
73
-
74
- with gr.Blocks(title="FunGen") as demo:
75
- gr.Markdown("# 🎬 FunGen - Funscript Generator")
76
-
77
- with gr.Row():
78
- gpu_info = "βœ… GPU Available" if torch.cuda.is_available() else "❌ No GPU"
79
- gr.Textbox(value=gpu_info, label="Status", interactive=False)
80
-
81
- with gr.Row():
82
- with gr.Column():
83
- video_input = gr.File(label="Upload Video", file_types=["video"], type="filepath")
84
- mode_input = gr.Dropdown(
85
- ["Hybrid Intelligence Tracker", "Oscillation Detector (Legacy)", "YOLO ROI Tracker"],
86
- value="Hybrid Intelligence Tracker",
87
- label="Mode"
88
- )
89
- overwrite_input = gr.Checkbox(label="Overwrite", value=False)
90
- autotune_input = gr.Checkbox(label="Apply Autotune", value=True)
91
- process_btn = gr.Button("Process Video", variant="primary")
92
-
93
- with gr.Column():
94
- status_output = gr.Textbox(label="Status", lines=8, interactive=False)
95
- file_output = gr.File(label="Download", interactive=False)
96
-
97
- process_btn.click(
98
- fn=process_video,
99
- inputs=[video_input, mode_input, overwrite_input, autotune_input],
100
- outputs=[status_output, file_output]
101
- )
102
-
103
- if __name__ == "__main__":
104
- demo.queue().launch(server_name="0.0.0.0", server_port=7860, show_error=True)