Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -50,27 +50,30 @@ class CustomTheme(Base):
|
|
50 |
custom_theme = CustomTheme()
|
51 |
|
52 |
def save_uploaded_file(uploaded_file):
|
53 |
-
print(f"Received object type: {type(uploaded_file)}")
|
54 |
if uploaded_file is None:
|
55 |
return None # Handle cases where no file was uploaded
|
56 |
-
|
57 |
-
if isinstance(uploaded_file, gr.NamedString):
|
58 |
-
print(f"File path from NamedString: {uploaded_file}")
|
59 |
-
return uploaded_file # Directly return the path if it's a NamedString
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
file_path = os.path.join(upload_dir, uploaded_file.name)
|
64 |
|
65 |
-
#
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
os.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
|
|
71 |
print(f"File saved to {file_path}, size: {os.path.getsize(file_path)} bytes")
|
72 |
return file_path
|
73 |
|
|
|
74 |
def display_results(video_url, video_file, description):
|
75 |
final_clip_path = None
|
76 |
|
@@ -137,17 +140,18 @@ h3 {
|
|
137 |
}
|
138 |
"""
|
139 |
|
140 |
-
with gr.Blocks(
|
141 |
with gr.Column():
|
142 |
-
gr.
|
143 |
-
gr.
|
144 |
-
gr.
|
145 |
-
video_url = gr.Textbox(label="Video URL:")
|
146 |
-
video_file = gr.File(label="Upload Video File:")
|
147 |
-
description = gr.Textbox(label="Describe your clip:")
|
148 |
submit_button = gr.Button("Process Video")
|
149 |
video_output = gr.Video(label="Processed Video")
|
150 |
download_output = gr.File(label="Download Processed Video")
|
151 |
-
submit_button.click(
|
|
|
|
|
|
|
|
|
152 |
|
153 |
-
demo.launch()
|
|
|
50 |
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 |
+
print(f"Received object type: {type(uploaded_file)}") # Debug: Check the object type
|
57 |
+
print(f"Uploaded file content: {uploaded_file}") # Debug: Inspect the content
|
|
|
58 |
|
59 |
+
# Handling file content based on its type
|
60 |
+
if isinstance(uploaded_file, tuple):
|
61 |
+
# If it's a tuple, it usually contains (filename, filedata)
|
62 |
+
filename, filedata = uploaded_file
|
63 |
+
file_path = os.path.join("uploaded_videos", filename)
|
64 |
+
with open(file_path, "wb") as f:
|
65 |
+
f.write(filedata)
|
66 |
+
elif isinstance(uploaded_file, str):
|
67 |
+
# If it's a string, assuming it's a file path
|
68 |
+
file_path = uploaded_file
|
69 |
+
else:
|
70 |
+
raise ValueError("Unexpected file input type")
|
71 |
|
72 |
+
os.makedirs(os.path.dirname(file_path), exist_ok=True)
|
73 |
print(f"File saved to {file_path}, size: {os.path.getsize(file_path)} bytes")
|
74 |
return file_path
|
75 |
|
76 |
+
|
77 |
def display_results(video_url, video_file, description):
|
78 |
final_clip_path = None
|
79 |
|
|
|
140 |
}
|
141 |
"""
|
142 |
|
143 |
+
with gr.Blocks() as demo:
|
144 |
with gr.Column():
|
145 |
+
video_url = gr.Textbox(label="Video URL")
|
146 |
+
video_file = gr.File(label="Upload Video File", type="file")
|
147 |
+
description = gr.Textbox(label="Describe your clip")
|
|
|
|
|
|
|
148 |
submit_button = gr.Button("Process Video")
|
149 |
video_output = gr.Video(label="Processed Video")
|
150 |
download_output = gr.File(label="Download Processed Video")
|
151 |
+
submit_button.click(
|
152 |
+
fn=display_results,
|
153 |
+
inputs=[video_url, video_file, description],
|
154 |
+
outputs=[video_output, download_output]
|
155 |
+
)
|
156 |
|
157 |
+
demo.launch()
|