AtzePengg
commited on
Commit
·
8343f2c
1
Parent(s):
6e67586
Improve sample video loading and add status messages
Browse files
app.py
CHANGED
@@ -220,16 +220,19 @@ def stylize_video(video_path, style_prompt, api_key):
|
|
220 |
return None, f"Error: {str(e)}"
|
221 |
|
222 |
def use_sample_bear_video():
|
223 |
-
"""Function to
|
224 |
-
#
|
225 |
-
bear_url = "https://
|
226 |
|
227 |
# Download the video to a temporary file
|
228 |
temp_video_path = download_video_from_url(bear_url)
|
229 |
if temp_video_path:
|
230 |
return temp_video_path, "Studio Ghibli animation with Hayao Miyazaki's distinctive hand-drawn art style"
|
231 |
else:
|
232 |
-
|
|
|
|
|
|
|
233 |
|
234 |
with gr.Blocks(title="Video-to-Ghibli Style Converter") as iface:
|
235 |
gr.Markdown("# Video-to-Ghibli Style Converter")
|
@@ -254,7 +257,7 @@ with gr.Blocks(title="Video-to-Ghibli Style Converter") as iface:
|
|
254 |
|
255 |
with gr.Column():
|
256 |
video_output = gr.Video(label="Stylized Video")
|
257 |
-
status_output = gr.Textbox(label="Status")
|
258 |
|
259 |
submit_btn.click(
|
260 |
fn=stylize_video,
|
@@ -262,10 +265,14 @@ with gr.Blocks(title="Video-to-Ghibli Style Converter") as iface:
|
|
262 |
outputs=[video_output, status_output]
|
263 |
)
|
264 |
|
|
|
|
|
|
|
|
|
265 |
example_btn.click(
|
266 |
-
fn=
|
267 |
inputs=None,
|
268 |
-
outputs=[video_input, style_prompt]
|
269 |
)
|
270 |
|
271 |
gr.Markdown("""
|
|
|
220 |
return None, f"Error: {str(e)}"
|
221 |
|
222 |
def use_sample_bear_video():
|
223 |
+
"""Function to use a sample bear video"""
|
224 |
+
# Try using a shorter, more reliable sample video URL
|
225 |
+
bear_url = "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4"
|
226 |
|
227 |
# Download the video to a temporary file
|
228 |
temp_video_path = download_video_from_url(bear_url)
|
229 |
if temp_video_path:
|
230 |
return temp_video_path, "Studio Ghibli animation with Hayao Miyazaki's distinctive hand-drawn art style"
|
231 |
else:
|
232 |
+
# Return a more descriptive error message
|
233 |
+
print("Failed to download sample video. Using fallback.")
|
234 |
+
# If download fails, try a direct URL
|
235 |
+
return bear_url, "Studio Ghibli animation with Hayao Miyazaki's distinctive hand-drawn art style"
|
236 |
|
237 |
with gr.Blocks(title="Video-to-Ghibli Style Converter") as iface:
|
238 |
gr.Markdown("# Video-to-Ghibli Style Converter")
|
|
|
257 |
|
258 |
with gr.Column():
|
259 |
video_output = gr.Video(label="Stylized Video")
|
260 |
+
status_output = gr.Textbox(label="Status", value="Ready. Upload a video or use the sample video.")
|
261 |
|
262 |
submit_btn.click(
|
263 |
fn=stylize_video,
|
|
|
265 |
outputs=[video_output, status_output]
|
266 |
)
|
267 |
|
268 |
+
def load_example_and_update_status():
|
269 |
+
video, prompt = use_sample_bear_video()
|
270 |
+
return video, prompt, "Sample video loaded. Enter your OpenAI API key and click 'Stylize Video'."
|
271 |
+
|
272 |
example_btn.click(
|
273 |
+
fn=load_example_and_update_status,
|
274 |
inputs=None,
|
275 |
+
outputs=[video_input, style_prompt, status_output]
|
276 |
)
|
277 |
|
278 |
gr.Markdown("""
|