Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,22 @@ from lumaai import AsyncLumaAI
|
|
4 |
import asyncio
|
5 |
import aiohttp
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
async def generate_video(client, prompt, loop=False, aspect_ratio="16:9", camera_motion=None, extend_id=None, reverse_extend_id=None, interpolate_ids=None, progress=gr.Progress()):
|
8 |
generation_params = {
|
9 |
"prompt": prompt,
|
@@ -160,15 +176,6 @@ async def image_to_video(prompt, image_url, loop, aspect_ratio, camera_motion, p
|
|
160 |
except Exception as e:
|
161 |
return None, f"An error occurred: {str(e)}"
|
162 |
|
163 |
-
async def get_camera_motions():
|
164 |
-
api_key = os.getenv("LMGEN_KEY")
|
165 |
-
if not api_key:
|
166 |
-
raise gr.Error("LMGEN_KEY environment variable is not set.")
|
167 |
-
|
168 |
-
client = AsyncLumaAI(auth_token=api_key)
|
169 |
-
motions = await client.generations.camera_motion.list()
|
170 |
-
return [motion.name for motion in motions]
|
171 |
-
|
172 |
with gr.Blocks() as demo:
|
173 |
gr.Markdown("# Luma AI Text-to-Video Demo")
|
174 |
|
@@ -181,7 +188,7 @@ with gr.Blocks() as demo:
|
|
181 |
with gr.Accordion("Advanced Options", open=False):
|
182 |
loop = gr.Checkbox(label="Loop", value=False)
|
183 |
aspect_ratio = gr.Dropdown(label="Aspect Ratio", choices=["16:9", "1:1", "9:16", "4:3", "3:4"], value="16:9")
|
184 |
-
camera_motion = gr.Dropdown(label="Camera Motion", choices=
|
185 |
extend_id = gr.Textbox(label="Extend Video ID (optional)")
|
186 |
reverse_extend_id = gr.Textbox(label="Reverse Extend Video ID (optional)")
|
187 |
with gr.Row():
|
@@ -204,7 +211,7 @@ with gr.Blocks() as demo:
|
|
204 |
with gr.Accordion("Advanced Options", open=False):
|
205 |
img_loop = gr.Checkbox(label="Loop", value=False)
|
206 |
img_aspect_ratio = gr.Dropdown(label="Aspect Ratio", choices=["16:9", "1:1", "9:16", "4:3", "3:4"], value="16:9")
|
207 |
-
img_camera_motion = gr.Dropdown(label="Camera Motion", choices=
|
208 |
|
209 |
img_generate_btn.click(
|
210 |
image_to_video,
|
|
|
4 |
import asyncio
|
5 |
import aiohttp
|
6 |
|
7 |
+
# 전역 변수로 카메라 모션 목록을 저장합니다.
|
8 |
+
camera_motions = []
|
9 |
+
|
10 |
+
async def get_camera_motions():
|
11 |
+
global camera_motions
|
12 |
+
api_key = os.getenv("LMGEN_KEY")
|
13 |
+
if not api_key:
|
14 |
+
raise gr.Error("LMGEN_KEY environment variable is not set.")
|
15 |
+
|
16 |
+
client = AsyncLumaAI(auth_token=api_key)
|
17 |
+
motions = await client.generations.camera_motion.list()
|
18 |
+
camera_motions = [motion.name for motion in motions]
|
19 |
+
|
20 |
+
# 앱 시작 시 카메라 모션 목록을 가져옵니다.
|
21 |
+
asyncio.run(get_camera_motions())
|
22 |
+
|
23 |
async def generate_video(client, prompt, loop=False, aspect_ratio="16:9", camera_motion=None, extend_id=None, reverse_extend_id=None, interpolate_ids=None, progress=gr.Progress()):
|
24 |
generation_params = {
|
25 |
"prompt": prompt,
|
|
|
176 |
except Exception as e:
|
177 |
return None, f"An error occurred: {str(e)}"
|
178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
with gr.Blocks() as demo:
|
180 |
gr.Markdown("# Luma AI Text-to-Video Demo")
|
181 |
|
|
|
188 |
with gr.Accordion("Advanced Options", open=False):
|
189 |
loop = gr.Checkbox(label="Loop", value=False)
|
190 |
aspect_ratio = gr.Dropdown(label="Aspect Ratio", choices=["16:9", "1:1", "9:16", "4:3", "3:4"], value="16:9")
|
191 |
+
camera_motion = gr.Dropdown(label="Camera Motion", choices=camera_motions)
|
192 |
extend_id = gr.Textbox(label="Extend Video ID (optional)")
|
193 |
reverse_extend_id = gr.Textbox(label="Reverse Extend Video ID (optional)")
|
194 |
with gr.Row():
|
|
|
211 |
with gr.Accordion("Advanced Options", open=False):
|
212 |
img_loop = gr.Checkbox(label="Loop", value=False)
|
213 |
img_aspect_ratio = gr.Dropdown(label="Aspect Ratio", choices=["16:9", "1:1", "9:16", "4:3", "3:4"], value="16:9")
|
214 |
+
img_camera_motion = gr.Dropdown(label="Camera Motion", choices=camera_motions)
|
215 |
|
216 |
img_generate_btn.click(
|
217 |
image_to_video,
|