euiia commited on
Commit
2b8bffd
·
verified ·
1 Parent(s): bb1730c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -32
app.py CHANGED
@@ -72,7 +72,7 @@ def preprocess_base_images_wrapper(uploaded_files):
72
  processed_paths = [aduc.process_image_for_story(f.name, 480, f"ref_processed_{i}.png") for i, f in enumerate(uploaded_files)]
73
  return gr.update(value=processed_paths)
74
 
75
- def run_mode_a_wrapper(prompt, num_keyframes, ref_files, resolution_str, progress=gr.Progress()):
76
  if not ref_files:
77
  raise gr.Error("Por favor, forneça pelo menos uma imagem de referência.")
78
 
@@ -116,10 +116,8 @@ def run_mode_b_wrapper(prompt, num_keyframes, ref_files, progress=gr.Progress())
116
 
117
  return gr.update(value=storyboard), gr.update(value=selected_keyframes), gr.update(visible=True, open=True)
118
 
119
- def run_video_production_wrapper(keyframes, prompt,
120
- n_chunks_to_generate, video_end_chunk,
121
- eco_start_chunk, handler_start_chunk,
122
- handler_frame_target,
123
  handler_strength, destination_convergence_strength,
124
  video_resolution, use_cont, use_cine,
125
  progress=gr.Progress()):
@@ -134,10 +132,8 @@ def run_video_production_wrapper(keyframes, prompt,
134
  final_movie_path = None
135
 
136
  for update in aduc.task_produce_final_movie_with_feedback(
137
- keyframes, prompt,
138
- int(n_chunks_to_generate), int(video_end_chunk),
139
- int(eco_start_chunk), int(handler_start_chunk),
140
- int(handler_frame_target),
141
  handler_strength, destination_convergence_strength,
142
  resolution, use_cont, use_cine, progress
143
  ):
@@ -180,12 +176,8 @@ def update_ui_language(lang_code):
180
  continuity_director_checkbox: gr.update(label=lang_map.get('continuity_director_label')),
181
  cinematographer_checkbox: gr.update(label=lang_map.get('cinematographer_label')),
182
 
183
- n_chunks_to_generate_slider: gr.update(label=lang_map.get('n_chunks_generate_label'), info=lang_map.get('n_chunks_generate_info')),
184
- video_end_chunk_slider: gr.update(label=lang_map.get('video_end_chunk_label'), info=lang_map.get('video_end_chunk_info')),
185
- eco_start_chunk_slider: gr.update(label=lang_map.get('eco_start_chunk_label'), info=lang_map.get('eco_start_chunk_info')),
186
- handler_start_chunk_slider: gr.update(label=lang_map.get('handler_start_chunk_label'), info=lang_map.get('handler_start_chunk_info')),
187
- handler_frame_target_slider: gr.update(label=lang_map.get('handler_frame_target_label'), info=lang_map.get('handler_frame_target_info')),
188
-
189
  forca_guia_slider: gr.update(label=lang_map.get('forca_guia_label'), info=lang_map.get('forca_guia_info')),
190
  convergencia_destino_slider: gr.update(label=lang_map.get('convergencia_final_label'), info=lang_map.get('convergencia_final_info')),
191
 
@@ -211,8 +203,8 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
211
  with gr.Accordion(default_lang.get('step1_accordion'), open=True) as step1_accordion:
212
  prompt_input = gr.Textbox(label=default_lang.get('prompt_label'), value="A majestic lion walks across the savanna, sits down, and then roars at the setting sun.")
213
  with gr.Row():
214
- num_keyframes_slider = gr.Slider(minimum=3, maximum=100, value=5, step=1, label=default_lang.get('keyframes_label'), info="Mínimo de 3 para a lógica do cineasta.")
215
- duration_per_fragment_slider = gr.Slider(label=default_lang.get('duration_label'), minimum=2.0, maximum=10.0, value=4.0, step=0.1, visible=False) # Escondido, mas mantido por dependências
216
  ref_image_input = gr.File(label=default_lang.get('ref_images_label'), file_count="multiple", file_types=["image"])
217
  with gr.Row():
218
  storyboard_and_keyframes_button = gr.Button(default_lang.get('storyboard_and_keyframes_button'), variant="primary")
@@ -227,15 +219,11 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
227
  continuity_director_checkbox = gr.Checkbox(label=default_lang.get('continuity_director_label'), value=True)
228
  cinematographer_checkbox = gr.Checkbox(label=default_lang.get('cinematographer_label'), value=True, visible=False)
229
 
230
- gr.Markdown("--- \n**Controles de Geração e Continuidade (Avançado):**")
231
- with gr.Row():
232
- n_chunks_to_generate_slider = gr.Slider(minimum=7, maximum=25, value=13, step=1, label="Chunks a Gerar", info="Total de chunks a gerar em cada passo. Mais chunks = mais 'cauda' para as guias.")
233
- video_end_chunk_slider = gr.Slider(minimum=2, maximum=20, value=9, step=1, label="Fim do Clipe (Chunk)", info="O vídeo final usará os chunks de 0 até este valor. (Ex: 9 -> usa chunks 0-8).")
234
- with gr.Row():
235
- eco_start_chunk_slider = gr.Slider(minimum=2, maximum=20, value=9, step=1, label="Início do Eco (Chunk)", info="Índice do chunk onde a guia de memória (eco) começa. (Ex: 9 -> usa chunks 9 e 10).")
236
- handler_start_chunk_slider = gr.Slider(minimum=4, maximum=22, value=11, step=1, label="Início do Handler (Chunk)", info="Índice do chunk onde a guia de evolução (handler) começa. (Ex: 11 -> usa chunks 11 e 12).")
237
  with gr.Row():
238
- handler_frame_target_slider = gr.Slider(minimum=8, maximum=80, value=16, step=8, label="Alvo do Handler (Frame)", info="Frame exato onde a guia de evolução será aplicada na próxima geração.")
 
 
239
 
240
  gr.Markdown("**Controle de Influência:**")
241
  with gr.Row():
@@ -259,7 +247,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
259
 
260
  storyboard_and_keyframes_button.click(
261
  fn=run_mode_a_wrapper,
262
- inputs=[prompt_input, num_keyframes_slider, ref_image_input, resolution_selector],
263
  outputs=[storyboard_output, keyframe_gallery, step3_accordion]
264
  )
265
 
@@ -272,12 +260,8 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
272
  produce_button.click(
273
  fn=run_video_production_wrapper,
274
  inputs=[
275
- keyframe_gallery, prompt_input,
276
- n_chunks_to_generate_slider,
277
- video_end_chunk_slider,
278
- eco_start_chunk_slider,
279
- handler_start_chunk_slider,
280
- handler_frame_target_slider,
281
  forca_guia_slider,
282
  convergencia_destino_slider,
283
  resolution_selector, continuity_director_checkbox, cinematographer_checkbox
 
72
  processed_paths = [aduc.process_image_for_story(f.name, 480, f"ref_processed_{i}.png") for i, f in enumerate(uploaded_files)]
73
  return gr.update(value=processed_paths)
74
 
75
+ def run_mode_a_wrapper(prompt, num_keyframes, ref_files, resolution_str, duration_per_fragment, progress=gr.Progress()):
76
  if not ref_files:
77
  raise gr.Error("Por favor, forneça pelo menos uma imagem de referência.")
78
 
 
116
 
117
  return gr.update(value=storyboard), gr.update(value=selected_keyframes), gr.update(visible=True, open=True)
118
 
119
+ def run_video_production_wrapper(keyframes, prompt, duration,
120
+ trim_percent,
 
 
121
  handler_strength, destination_convergence_strength,
122
  video_resolution, use_cont, use_cine,
123
  progress=gr.Progress()):
 
132
  final_movie_path = None
133
 
134
  for update in aduc.task_produce_final_movie_with_feedback(
135
+ keyframes, prompt, duration,
136
+ int(trim_percent),
 
 
137
  handler_strength, destination_convergence_strength,
138
  resolution, use_cont, use_cine, progress
139
  ):
 
176
  continuity_director_checkbox: gr.update(label=lang_map.get('continuity_director_label')),
177
  cinematographer_checkbox: gr.update(label=lang_map.get('cinematographer_label')),
178
 
179
+ trim_percent_slider: gr.update(label=lang_map.get('trim_percent_label'), info=lang_map.get('trim_percent_info')),
180
+
 
 
 
 
181
  forca_guia_slider: gr.update(label=lang_map.get('forca_guia_label'), info=lang_map.get('forca_guia_info')),
182
  convergencia_destino_slider: gr.update(label=lang_map.get('convergencia_final_label'), info=lang_map.get('convergencia_final_info')),
183
 
 
203
  with gr.Accordion(default_lang.get('step1_accordion'), open=True) as step1_accordion:
204
  prompt_input = gr.Textbox(label=default_lang.get('prompt_label'), value="A majestic lion walks across the savanna, sits down, and then roars at the setting sun.")
205
  with gr.Row():
206
+ num_keyframes_slider = gr.Slider(minimum=3, maximum=100, value=3, step=1, label=default_lang.get('keyframes_label'), info="Mínimo de 3 para a lógica do cineasta.")
207
+ duration_per_fragment_slider = gr.Slider(label=default_lang.get('duration_label'), minimum=2.0, maximum=10.0, value=4.0, step=0.1)
208
  ref_image_input = gr.File(label=default_lang.get('ref_images_label'), file_count="multiple", file_types=["image"])
209
  with gr.Row():
210
  storyboard_and_keyframes_button = gr.Button(default_lang.get('storyboard_and_keyframes_button'), variant="primary")
 
219
  continuity_director_checkbox = gr.Checkbox(label=default_lang.get('continuity_director_label'), value=True)
220
  cinematographer_checkbox = gr.Checkbox(label=default_lang.get('cinematographer_label'), value=True, visible=False)
221
 
222
+ gr.Markdown("--- \n**Controles de Continuidade e Edição:**")
 
 
 
 
 
 
223
  with gr.Row():
224
+ trim_percent_slider = gr.Slider(minimum=50, maximum=90, value=60, step=5,
225
+ label=default_lang.get('trim_percent_label'),
226
+ info=default_lang.get('trim_percent_info'))
227
 
228
  gr.Markdown("**Controle de Influência:**")
229
  with gr.Row():
 
247
 
248
  storyboard_and_keyframes_button.click(
249
  fn=run_mode_a_wrapper,
250
+ inputs=[prompt_input, num_keyframes_slider, ref_image_input, resolution_selector, duration_per_fragment_slider],
251
  outputs=[storyboard_output, keyframe_gallery, step3_accordion]
252
  )
253
 
 
260
  produce_button.click(
261
  fn=run_video_production_wrapper,
262
  inputs=[
263
+ keyframe_gallery, prompt_input, duration_per_fragment_slider,
264
+ trim_percent_slider,
 
 
 
 
265
  forca_guia_slider,
266
  convergencia_destino_slider,
267
  resolution_selector, continuity_director_checkbox, cinematographer_checkbox