Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -51,19 +51,20 @@ custom_theme = CustomTheme()
|
|
51 |
|
52 |
def save_uploaded_file(uploaded_file):
|
53 |
if uploaded_file is None:
|
|
|
54 |
return None # Handle cases where no file was uploaded
|
55 |
-
|
56 |
-
|
57 |
upload_dir = "uploaded_videos"
|
58 |
os.makedirs(upload_dir, exist_ok=True)
|
59 |
-
file_path = os.path.join(upload_dir, "uploaded_video.mp4")
|
60 |
|
61 |
with open(file_path, "wb") as f:
|
62 |
-
f.write(
|
63 |
f.flush()
|
64 |
os.fsync(f.fileno()) # Ensure all file data is flushed to disk
|
65 |
|
66 |
-
print(f"File saved to {file_path}, size: {os.path.getsize(file_path)} bytes")
|
67 |
return file_path
|
68 |
|
69 |
def display_results(video_url, video_file, description):
|
@@ -136,18 +137,21 @@ h3 {
|
|
136 |
}
|
137 |
"""
|
138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
with gr.Blocks() as demo:
|
140 |
with gr.Column():
|
141 |
-
video_url = gr.Textbox(label="Video URL")
|
142 |
video_file = gr.UploadButton(label="Upload Video File", type="binary", file_types=["video"])
|
143 |
-
description = gr.Textbox(label="Describe your clip")
|
144 |
submit_button = gr.Button("Process Video")
|
145 |
-
|
146 |
-
download_output = gr.Text(label="Download Link")
|
147 |
submit_button.click(
|
148 |
-
fn=
|
149 |
-
inputs=[
|
150 |
-
outputs=[
|
151 |
)
|
152 |
|
153 |
demo.launch()
|
|
|
51 |
|
52 |
def save_uploaded_file(uploaded_file):
|
53 |
if uploaded_file is None:
|
54 |
+
print("No file uploaded.")
|
55 |
return None # Handle cases where no file was uploaded
|
56 |
+
|
57 |
+
print("File received:", type(uploaded_file), len(uploaded_file))
|
58 |
upload_dir = "uploaded_videos"
|
59 |
os.makedirs(upload_dir, exist_ok=True)
|
60 |
+
file_path = os.path.join(upload_dir, "uploaded_video.mp4")
|
61 |
|
62 |
with open(file_path, "wb") as f:
|
63 |
+
f.write(uploaded_file) # Write file content to disk
|
64 |
f.flush()
|
65 |
os.fsync(f.fileno()) # Ensure all file data is flushed to disk
|
66 |
|
67 |
+
print(f"File saved to {file_path}, size: {os.path.getsize(file_path)} bytes") # Debugging
|
68 |
return file_path
|
69 |
|
70 |
def display_results(video_url, video_file, description):
|
|
|
137 |
}
|
138 |
"""
|
139 |
|
140 |
+
def interface_function(video_file):
|
141 |
+
if video_file is not None:
|
142 |
+
file_path = save_uploaded_file(video_file)
|
143 |
+
return f"File saved at {file_path}"
|
144 |
+
return "No file uploaded."
|
145 |
+
|
146 |
with gr.Blocks() as demo:
|
147 |
with gr.Column():
|
|
|
148 |
video_file = gr.UploadButton(label="Upload Video File", type="binary", file_types=["video"])
|
|
|
149 |
submit_button = gr.Button("Process Video")
|
150 |
+
output_text = gr.Text(label="Output")
|
|
|
151 |
submit_button.click(
|
152 |
+
fn=interface_function,
|
153 |
+
inputs=[video_file],
|
154 |
+
outputs=[output_text]
|
155 |
)
|
156 |
|
157 |
demo.launch()
|