seawolf2357 commited on
Commit
8fb3c5b
Β·
verified Β·
1 Parent(s): 8b961aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
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():