seawolf2357 commited on
Commit
28e12ad
ยท
verified ยท
1 Parent(s): 1592a76

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -28
app.py CHANGED
@@ -82,12 +82,17 @@ def generate_image_from_text(prompt, seed=0):
82
  return image
83
 
84
  @spaces.GPU(duration=300)
85
- def infer(image, prompt, steps=50, cfg_scale=7.5, eta=1.0, fs=3, seed=123, video_length=2):
86
  # ํ•œ๊ธ€ ์ž…๋ ฅ ๊ฐ์ง€ ๋ฐ ๋ฒˆ์—ญ
87
  if any('\u3131' <= char <= '\u318E' or '\uAC00' <= char <= '\uD7A3' for char in prompt):
88
  translated = translator(prompt, max_length=512)[0]['translation_text']
89
  prompt = translated
90
- print(f"Translated prompt: {prompt}")
 
 
 
 
 
91
 
92
  resolution = (576, 1024)
93
  save_fps = 8
@@ -157,7 +162,35 @@ i2v_examples = [
157
  css = """#input_img {max-width: 1024px !important} #output_vid {max-width: 1024px; max-height: 576px}"""
158
 
159
  with gr.Blocks(analytics_enabled=False, css=css) as dynamicrafter_iface:
160
- gr.Markdown("์ด๋ฏธ์ง€๋กœ ์˜์ƒ ์ƒ์„ฑ ํ…Œ์ŠคํŠธ (ํ•œ๊ธ€ ํ”„๋กฌํ”„ํŠธ ์ง€์›)")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  with gr.Tab(label='ImageAnimation_576x1024'):
162
  with gr.Column():
163
  with gr.Row():
@@ -190,31 +223,6 @@ with gr.Blocks(analytics_enabled=False, css=css) as dynamicrafter_iface:
190
  fn = infer
191
  )
192
 
193
- with gr.Tab(label='T2V'):
194
- with gr.Column():
195
- with gr.Row():
196
- with gr.Column():
197
- with gr.Row():
198
- t2v_input_text = gr.Text(label='Image Generation Prompt')
199
- with gr.Row():
200
- t2v_video_prompt = gr.Text(label='Video Generation Prompt')
201
- with gr.Row():
202
- t2v_seed = gr.Slider(label='Random Seed', minimum=0, maximum=10000, step=1, value=123)
203
- t2v_eta = gr.Slider(minimum=0.0, maximum=1.0, step=0.1, label='ETA', value=1.0)
204
- t2v_cfg_scale = gr.Slider(minimum=1.0, maximum=15.0, step=0.5, label='CFG Scale', value=7.5)
205
- with gr.Row():
206
- t2v_steps = gr.Slider(minimum=1, maximum=50, step=1, label="Sampling steps", value=30)
207
- t2v_motion = gr.Slider(minimum=5, maximum=20, step=1, label="FPS", value=8)
208
- with gr.Row():
209
- t2v_video_length = gr.Slider(minimum=2, maximum=8, step=1, label="Video Length (seconds)", value=2)
210
- t2v_end_btn = gr.Button("Generate")
211
- with gr.Row():
212
- t2v_output_video = gr.Video(label="Generated Video", autoplay=True, show_share_button=True)
213
 
214
- t2v_end_btn.click(
215
- inputs=[t2v_input_text, t2v_video_prompt, t2v_steps, t2v_cfg_scale, t2v_eta, t2v_motion, t2v_seed, t2v_video_length],
216
- outputs=[t2v_output_video],
217
- fn=infer_t2v
218
- )
219
 
220
  dynamicrafter_iface.queue(max_size=12).launch(show_api=True)
 
82
  return image
83
 
84
  @spaces.GPU(duration=300)
85
+ def infer_t2v(prompt, video_prompt, steps=50, cfg_scale=7.5, eta=1.0, fs=3, seed=123, video_length=2):
86
  # ํ•œ๊ธ€ ์ž…๋ ฅ ๊ฐ์ง€ ๋ฐ ๋ฒˆ์—ญ
87
  if any('\u3131' <= char <= '\u318E' or '\uAC00' <= char <= '\uD7A3' for char in prompt):
88
  translated = translator(prompt, max_length=512)[0]['translation_text']
89
  prompt = translated
90
+ print(f"Translated image prompt: {prompt}")
91
+ if any('\u3131' <= char <= '\u318E' or '\uAC00' <= char <= '\uD7A3' for char in video_prompt):
92
+ translated_video_prompt = translator(video_prompt, max_length=512)[0]['translation_text']
93
+ video_prompt = translated_video_prompt
94
+ print(f"Translated video prompt: {video_prompt}")
95
+
96
 
97
  resolution = (576, 1024)
98
  save_fps = 8
 
162
  css = """#input_img {max-width: 1024px !important} #output_vid {max-width: 1024px; max-height: 576px}"""
163
 
164
  with gr.Blocks(analytics_enabled=False, css=css) as dynamicrafter_iface:
165
+ gr.Markdown("kAI ๋ฌด๋น„ ์ŠคํŠœ๋””์˜ค")
166
+
167
+ with gr.Tab(label='T2V'):
168
+ with gr.Column():
169
+ with gr.Row():
170
+ with gr.Column():
171
+ with gr.Row():
172
+ t2v_input_text = gr.Text(label='Image Generation Prompt')
173
+ with gr.Row():
174
+ t2v_video_prompt = gr.Text(label='Video Generation Prompt')
175
+ with gr.Row():
176
+ t2v_seed = gr.Slider(label='Random Seed', minimum=0, maximum=10000, step=1, value=123)
177
+ t2v_eta = gr.Slider(minimum=0.0, maximum=1.0, step=0.1, label='ETA', value=1.0)
178
+ t2v_cfg_scale = gr.Slider(minimum=1.0, maximum=15.0, step=0.5, label='CFG Scale', value=7.5)
179
+ with gr.Row():
180
+ t2v_steps = gr.Slider(minimum=1, maximum=50, step=1, label="Sampling steps", value=30)
181
+ t2v_motion = gr.Slider(minimum=5, maximum=20, step=1, label="FPS", value=8)
182
+ with gr.Row():
183
+ t2v_video_length = gr.Slider(minimum=2, maximum=8, step=1, label="Video Length (seconds)", value=2)
184
+ t2v_end_btn = gr.Button("Generate")
185
+ with gr.Row():
186
+ t2v_output_video = gr.Video(label="Generated Video", autoplay=True, show_share_button=True)
187
+
188
+ t2v_end_btn.click(
189
+ inputs=[t2v_input_text, t2v_video_prompt, t2v_steps, t2v_cfg_scale, t2v_eta, t2v_motion, t2v_seed, t2v_video_length],
190
+ outputs=[t2v_output_video],
191
+ fn=infer_t2v
192
+ )
193
+
194
  with gr.Tab(label='ImageAnimation_576x1024'):
195
  with gr.Column():
196
  with gr.Row():
 
223
  fn = infer
224
  )
225
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
 
 
 
 
 
 
227
 
228
  dynamicrafter_iface.queue(max_size=12).launch(show_api=True)