Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -97,7 +97,7 @@ async def generate_video(client, prompt, loop=False, aspect_ratio="16:9", camera
|
|
97 |
fd.write(chunk)
|
98 |
|
99 |
progress(1.0, desc="λΉλμ€ μμ± μλ£!")
|
100 |
-
return file_name
|
101 |
|
102 |
async def translate_prompt(prompt):
|
103 |
try:
|
@@ -127,13 +127,13 @@ async def text_to_video(prompt, loop, aspect_ratio, camera_motion, extend_id, re
|
|
127 |
if interpolate_id1 and interpolate_id2:
|
128 |
interpolate_ids = [interpolate_id1, interpolate_id2]
|
129 |
|
130 |
-
video_path = await generate_video(
|
131 |
client, translated_prompt, loop, aspect_ratio, camera_motion,
|
132 |
extend_id, reverse_extend_id, interpolate_ids, progress
|
133 |
)
|
134 |
-
return video_path, ""
|
135 |
except Exception as e:
|
136 |
-
return None, f"μ€λ₯ λ°μ: {str(e)}"
|
137 |
|
138 |
async def image_to_video(prompt, image_url, loop, aspect_ratio, camera_motion, progress=gr.Progress()):
|
139 |
api_key = os.getenv("LMGEN_KEY")
|
@@ -200,9 +200,9 @@ async def image_to_video(prompt, image_url, loop, aspect_ratio, camera_motion, p
|
|
200 |
fd.write(chunk)
|
201 |
|
202 |
progress(1.0, desc="λΉλμ€ μμ± μλ£!")
|
203 |
-
return file_name, ""
|
204 |
except Exception as e:
|
205 |
-
return None, f"μ€λ₯ λ°μ: {str(e)}"
|
206 |
|
207 |
with gr.Blocks() as demo:
|
208 |
gr.Markdown("# Luma AI ν
μ€νΈ-λΉλμ€ μμ± λ°λͺ¨")
|
@@ -211,6 +211,7 @@ with gr.Blocks() as demo:
|
|
211 |
prompt = gr.Textbox(label="ν둬ννΈ (λΉλμ€μ λν μ€λͺ
μ μ
λ ₯νμΈμ)")
|
212 |
generate_btn = gr.Button("λΉλμ€ μμ±")
|
213 |
video_output = gr.Video(label="μμ±λ λΉλμ€")
|
|
|
214 |
error_output = gr.Textbox(label="μ€λ₯ λ©μμ§", visible=True)
|
215 |
|
216 |
with gr.Accordion("κ³ κΈ μ΅μ
", open=False):
|
@@ -230,7 +231,7 @@ with gr.Blocks() as demo:
|
|
230 |
generate_btn.click(
|
231 |
text_to_video,
|
232 |
inputs=[prompt, loop, aspect_ratio, camera_motion, extend_id, reverse_extend_id, interpolate_id1, interpolate_id2],
|
233 |
-
outputs=[video_output, error_output]
|
234 |
)
|
235 |
|
236 |
with gr.Tab("μ΄λ―Έμ§λ‘ λΉλμ€ λ§λ€κΈ°"):
|
@@ -238,6 +239,7 @@ with gr.Blocks() as demo:
|
|
238 |
img_url = gr.Textbox(label="μ΄λ―Έμ§ URL (λ³ννκ³ μ νλ μ΄λ―Έμ§μ μΉ μ£Όμ)")
|
239 |
img_generate_btn = gr.Button("μ΄λ―Έμ§λ‘ λΉλμ€ μμ±")
|
240 |
img_video_output = gr.Video(label="μμ±λ λΉλμ€")
|
|
|
241 |
img_error_output = gr.Textbox(label="μ€λ₯ λ©μμ§", visible=True)
|
242 |
|
243 |
with gr.Accordion("κ³ κΈ μ΅μ
", open=False):
|
@@ -252,7 +254,7 @@ with gr.Blocks() as demo:
|
|
252 |
img_generate_btn.click(
|
253 |
image_to_video,
|
254 |
inputs=[img_prompt, img_url, img_loop, img_aspect_ratio, img_camera_motion],
|
255 |
-
outputs=[img_video_output, img_error_output]
|
256 |
)
|
257 |
|
258 |
async def update_camera_motions():
|
|
|
97 |
fd.write(chunk)
|
98 |
|
99 |
progress(1.0, desc="λΉλμ€ μμ± μλ£!")
|
100 |
+
return file_name, generation.id
|
101 |
|
102 |
async def translate_prompt(prompt):
|
103 |
try:
|
|
|
127 |
if interpolate_id1 and interpolate_id2:
|
128 |
interpolate_ids = [interpolate_id1, interpolate_id2]
|
129 |
|
130 |
+
video_path, video_id = await generate_video(
|
131 |
client, translated_prompt, loop, aspect_ratio, camera_motion,
|
132 |
extend_id, reverse_extend_id, interpolate_ids, progress
|
133 |
)
|
134 |
+
return video_path, video_id, ""
|
135 |
except Exception as e:
|
136 |
+
return None, None, f"μ€λ₯ λ°μ: {str(e)}"
|
137 |
|
138 |
async def image_to_video(prompt, image_url, loop, aspect_ratio, camera_motion, progress=gr.Progress()):
|
139 |
api_key = os.getenv("LMGEN_KEY")
|
|
|
200 |
fd.write(chunk)
|
201 |
|
202 |
progress(1.0, desc="λΉλμ€ μμ± μλ£!")
|
203 |
+
return file_name, generation.id, ""
|
204 |
except Exception as e:
|
205 |
+
return None, None, f"μ€λ₯ λ°μ: {str(e)}"
|
206 |
|
207 |
with gr.Blocks() as demo:
|
208 |
gr.Markdown("# Luma AI ν
μ€νΈ-λΉλμ€ μμ± λ°λͺ¨")
|
|
|
211 |
prompt = gr.Textbox(label="ν둬ννΈ (λΉλμ€μ λν μ€λͺ
μ μ
λ ₯νμΈμ)")
|
212 |
generate_btn = gr.Button("λΉλμ€ μμ±")
|
213 |
video_output = gr.Video(label="μμ±λ λΉλμ€")
|
214 |
+
video_id_output = gr.Textbox(label="μμ±λ λΉλμ€ ID", visible=True)
|
215 |
error_output = gr.Textbox(label="μ€λ₯ λ©μμ§", visible=True)
|
216 |
|
217 |
with gr.Accordion("κ³ κΈ μ΅μ
", open=False):
|
|
|
231 |
generate_btn.click(
|
232 |
text_to_video,
|
233 |
inputs=[prompt, loop, aspect_ratio, camera_motion, extend_id, reverse_extend_id, interpolate_id1, interpolate_id2],
|
234 |
+
outputs=[video_output, video_id_output, error_output]
|
235 |
)
|
236 |
|
237 |
with gr.Tab("μ΄λ―Έμ§λ‘ λΉλμ€ λ§λ€κΈ°"):
|
|
|
239 |
img_url = gr.Textbox(label="μ΄λ―Έμ§ URL (λ³ννκ³ μ νλ μ΄λ―Έμ§μ μΉ μ£Όμ)")
|
240 |
img_generate_btn = gr.Button("μ΄λ―Έμ§λ‘ λΉλμ€ μμ±")
|
241 |
img_video_output = gr.Video(label="μμ±λ λΉλμ€")
|
242 |
+
img_video_id_output = gr.Textbox(label="μμ±λ λΉλμ€ ID", visible=True)
|
243 |
img_error_output = gr.Textbox(label="μ€λ₯ λ©μμ§", visible=True)
|
244 |
|
245 |
with gr.Accordion("κ³ κΈ μ΅μ
", open=False):
|
|
|
254 |
img_generate_btn.click(
|
255 |
image_to_video,
|
256 |
inputs=[img_prompt, img_url, img_loop, img_aspect_ratio, img_camera_motion],
|
257 |
+
outputs=[img_video_output, img_video_id_output, img_error_output]
|
258 |
)
|
259 |
|
260 |
async def update_camera_motions():
|