Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -20,9 +20,9 @@ async def generate_video(api_key, prompt, loop=False, aspect_ratio="16:9", progr
|
|
20 |
start_time = asyncio.get_event_loop().time()
|
21 |
while True:
|
22 |
status = await client.generations.get(id=generation.id)
|
23 |
-
if status.
|
24 |
break
|
25 |
-
elif status.
|
26 |
raise Exception("Video generation failed")
|
27 |
|
28 |
# Update progress based on time elapsed (assuming 60 seconds total)
|
@@ -56,9 +56,9 @@ async def text_to_video(api_key, prompt, loop, aspect_ratio, progress=gr.Progres
|
|
56 |
|
57 |
try:
|
58 |
video_path = await generate_video(api_key, prompt, loop, aspect_ratio, progress)
|
59 |
-
return
|
60 |
except Exception as e:
|
61 |
-
return
|
62 |
|
63 |
async def image_to_video(api_key, prompt, image_url, loop, aspect_ratio, progress=gr.Progress()):
|
64 |
if not api_key:
|
@@ -86,9 +86,9 @@ async def image_to_video(api_key, prompt, image_url, loop, aspect_ratio, progres
|
|
86 |
start_time = asyncio.get_event_loop().time()
|
87 |
while True:
|
88 |
status = await client.generations.get(id=generation.id)
|
89 |
-
if status.
|
90 |
break
|
91 |
-
elif status.
|
92 |
raise Exception("Video generation failed")
|
93 |
|
94 |
# Update progress based on time elapsed (assuming 60 seconds total)
|
@@ -114,9 +114,9 @@ async def image_to_video(api_key, prompt, image_url, loop, aspect_ratio, progres
|
|
114 |
fd.write(chunk)
|
115 |
|
116 |
progress(1.0, desc="Video generation complete!")
|
117 |
-
return
|
118 |
except Exception as e:
|
119 |
-
return
|
120 |
|
121 |
with gr.Blocks() as demo:
|
122 |
gr.Markdown("# Luma AI Text-to-Video Demo")
|
@@ -156,4 +156,4 @@ with gr.Blocks() as demo:
|
|
156 |
outputs=[img_video_output, img_error_output]
|
157 |
)
|
158 |
|
159 |
-
demo.queue().launch()
|
|
|
20 |
start_time = asyncio.get_event_loop().time()
|
21 |
while True:
|
22 |
status = await client.generations.get(id=generation.id)
|
23 |
+
if status.state == "completed":
|
24 |
break
|
25 |
+
elif status.state == "failed":
|
26 |
raise Exception("Video generation failed")
|
27 |
|
28 |
# Update progress based on time elapsed (assuming 60 seconds total)
|
|
|
56 |
|
57 |
try:
|
58 |
video_path = await generate_video(api_key, prompt, loop, aspect_ratio, progress)
|
59 |
+
return video_path, ""
|
60 |
except Exception as e:
|
61 |
+
return None, f"An error occurred: {str(e)}"
|
62 |
|
63 |
async def image_to_video(api_key, prompt, image_url, loop, aspect_ratio, progress=gr.Progress()):
|
64 |
if not api_key:
|
|
|
86 |
start_time = asyncio.get_event_loop().time()
|
87 |
while True:
|
88 |
status = await client.generations.get(id=generation.id)
|
89 |
+
if status.state == "completed":
|
90 |
break
|
91 |
+
elif status.state == "failed":
|
92 |
raise Exception("Video generation failed")
|
93 |
|
94 |
# Update progress based on time elapsed (assuming 60 seconds total)
|
|
|
114 |
fd.write(chunk)
|
115 |
|
116 |
progress(1.0, desc="Video generation complete!")
|
117 |
+
return file_name, ""
|
118 |
except Exception as e:
|
119 |
+
return None, f"An error occurred: {str(e)}"
|
120 |
|
121 |
with gr.Blocks() as demo:
|
122 |
gr.Markdown("# Luma AI Text-to-Video Demo")
|
|
|
156 |
outputs=[img_video_output, img_error_output]
|
157 |
)
|
158 |
|
159 |
+
demo.queue().launch(share=True)
|