dream2589632147 commited on
Commit
44a46c9
·
verified ·
1 Parent(s): ad6722d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +70 -85
app.py CHANGED
@@ -1,7 +1,6 @@
1
  import spaces
2
  import torch
3
- from diffusers.pipelines.wan.pipeline_wan_i2v import WanImageToVideoPipeline
4
- from diffusers.models.transformers.transformer_wan import WanTransformer3DModel
5
  from diffusers.utils.export_utils import export_to_video
6
  import gradio as gr
7
  import tempfile
@@ -14,6 +13,7 @@ from torchao.quantization import Float8DynamicActivationFloat8WeightConfig
14
  from torchao.quantization import Int8WeightOnlyConfig
15
  import aoti
16
  from typing import Optional, Tuple, List
 
17
 
18
  MODEL_ID = "Wan-AI/Wan2.2-I2V-A14B-Diffusers"
19
  MAX_DIM = 832
@@ -31,13 +31,13 @@ MAX_DURATION = round(MAX_FRAMES_MODEL / FIXED_FPS, 1)
31
  pipe = WanImageToVideoPipeline.from_pretrained(
32
  MODEL_ID,
33
  transformer=WanTransformer3DModel.from_pretrained(
34
- 'cbensimon/Wan2.2-I2V-A14B-bf16-Diffusers',
35
  subfolder='transformer',
36
  torch_dtype=torch.bfloat16,
37
  device_map='cuda',
38
  ),
39
  transformer_2=WanTransformer3DModel.from_pretrained(
40
- 'cbensimon/Wan2.2-I2V-A14B-bf16-Diffusers',
41
  subfolder='transformer_2',
42
  torch_dtype=torch.bfloat16,
43
  device_map='cuda',
@@ -45,13 +45,13 @@ pipe = WanImageToVideoPipeline.from_pretrained(
45
  torch_dtype=torch.bfloat16,
46
  ).to('cuda')
47
 
48
- # تحميل LoRA مع تحسينات للجودة العالية
49
  pipe.load_lora_weights(
50
  "Kijai/WanVideo_comfy",
51
  weight_name="Lightx2v/lightx2v_I2V_14B_480p_cfg_step_distill_rank128_bf16.safetensors",
52
  adapter_name="lightx2v"
53
  )
54
- kwargs_lora = {"load_into_transformer_2": True}
55
  pipe.load_lora_weights(
56
  "Kijai/WanVideo_comfy",
57
  weight_name="Lightx2v/lightx2v_I2V_14B_480p_cfg_step_distill_rank128_bf16.safetensors",
@@ -60,8 +60,8 @@ pipe.load_lora_weights(
60
  pipe.set_adapters(["lightx2v", "lightx2v_2"], adapter_weights=[1., 1.])
61
 
62
  # دمج LoRA مع مقاييس مخصصة لتعزيز الاستقرار والاحترافية
63
- pipe.fuse_lora(adapter_names=["lightx2v"], lora_scale=3.5, components=["transformer"]) # زيادة طفيفة لتعزيز التفاصيل
64
- pipe.fuse_lora(adapter_names=["lightx2v_2"], lora_scale=1.2, components=["transformer_2"]) # تحسين للمرحلة المنخفضة الضوضاء
65
  pipe.unload_lora_weights()
66
 
67
  # الكمية لتوفير الذاكرة مع الحفاظ على الدقة
@@ -73,7 +73,7 @@ quantize_(pipe.transformer_2, Float8DynamicActivationFloat8WeightConfig())
73
  aoti.aoti_blocks_load(pipe.transformer, 'zerogpu-aoti/Wan2', variant='fp8da')
74
  aoti.aoti_blocks_load(pipe.transformer_2, 'zerogpu-aoti/Wan2', variant='fp8da')
75
 
76
- # تحسين الـ Prompt الافتراضي للاحترافية الفائقة: إضافة تفاصيل سينمائية عميقة واستقرار إطارات محسن
77
  default_prompt_i2v = (
78
  "ultra realistic cinematic footage shot on Arri Alexa LF with Panavision anamorphic lenses, "
79
  "perfectly preserved facial identity, micro-expressions, and body structure across all frames, "
@@ -96,7 +96,6 @@ default_prompt_i2v = (
96
  "frame-to-frame stability with advanced optical flow preservation"
97
  )
98
 
99
- # تحسين الـ Negative Prompt لتجنب أي عيوب عميقة
100
  default_negative_prompt = (
101
  "low quality, low resolution, low contrast, poor lighting, underexposed, overexposed, bad composition, "
102
  "bad framing, bad perspective, flat lighting, washed out colors, jpeg artifacts, noise, static, grain, "
@@ -120,12 +119,10 @@ def enhance_image(image: Image.Image) -> Image.Image:
120
  """
121
  تحسين الصورة المدخلة لتعزيز الجودة والواقعية قبل التمرير.
122
  """
123
- # تعزيز التباين والحدة بلطف
124
  enhancer = ImageEnhance.Contrast(image)
125
  image = enhancer.enhance(1.05)
126
  enhancer = ImageEnhance.Sharpness(image)
127
  image = enhancer.enhance(1.1)
128
- # إضافة فلتر خفيف لتقليل الضوضاء
129
  image = image.filter(ImageFilter.UnsharpMask(radius=1, percent=150, threshold=3))
130
  return image
131
 
@@ -133,17 +130,16 @@ def resize_image(image: Image.Image) -> Image.Image:
133
  """
134
  تحسين دالة التمرير للحفاظ على الجودة العالية مع الالتزام بالأبعاد.
135
  """
136
- # تعزيز الصورة أولاً
137
  enhanced_image = enhance_image(image)
138
-
139
  width, height = enhanced_image.size
140
  if width == height:
141
  return enhanced_image.resize((SQUARE_DIM, SQUARE_DIM), Image.LANCZOS)
142
-
143
  aspect_ratio = width / height
144
  MAX_ASPECT_RATIO = MAX_DIM / MIN_DIM
145
  MIN_ASPECT_RATIO = MIN_DIM / MAX_DIM
146
-
147
  image_to_resize = enhanced_image
148
  if aspect_ratio > MAX_ASPECT_RATIO:
149
  target_w, target_h = MAX_DIM, MIN_DIM
@@ -162,13 +158,12 @@ def resize_image(image: Image.Image) -> Image.Image:
162
  else:
163
  target_h = MAX_DIM
164
  target_w = int(round(target_h * aspect_ratio))
165
-
166
  final_w = round(target_w / MULTIPLE_OF) * MULTIPLE_OF
167
  final_h = round(target_h / MULTIPLE_OF) * MULTIPLE_OF
168
  final_w = max(MIN_DIM, min(MAX_DIM, final_w))
169
  final_h = max(MIN_DIM, min(MAX_DIM, final_h))
170
-
171
- # استخدام LANCZOS للحفاظ على التفاصيل العالية
172
  return image_to_resize.resize((final_w, final_h), Image.LANCZOS)
173
 
174
  def get_num_frames(duration_seconds: float) -> int:
@@ -203,25 +198,22 @@ def generate_video(
203
  """
204
  if input_image is None:
205
  raise gr.Error("يرجى تحميل صورة مدخلة.")
206
-
207
- # تنظيف الذاكرة قبل التشغيل
208
  gc.collect()
209
  torch.cuda.empty_cache()
210
-
211
  num_frames = get_num_frames(duration_seconds)
212
  current_seed = random.randint(0, MAX_SEED) if randomize_seed else int(seed)
213
-
214
- # تحسين وتمرير الصورة
215
  resized_image = resize_image(input_image)
216
-
217
  progress(0, desc="بدء التوليد...")
218
-
219
- # تشغيل النموذج مع progress updates
220
  with progress():
221
  output_frames_list = pipe(
222
  image=resized_image,
223
- prompt=prompt,
224
- negative_prompt=negative_prompt,
225
  height=resized_image.height,
226
  width=resized_image.width,
227
  num_frames=num_frames,
@@ -230,20 +222,18 @@ def generate_video(
230
  num_inference_steps=int(steps),
231
  generator=torch.Generator(device="cuda").manual_seed(current_seed),
232
  ).frames[0]
233
-
234
  progress(1, desc="تصدير الفيديو...")
235
-
236
- # تصدير الفيديو مع FPS محسن
237
  with tempfile.NamedTemporaryFile(suffix=".mp4", delete=False) as tmpfile:
238
  video_path = tmpfile.name
239
-
240
  export_to_video(output_frames_list, video_path, fps=FIXED_FPS)
241
-
242
- # تنظيف إضافي
243
  del output_frames_list
244
  gc.collect()
245
  torch.cuda.empty_cache()
246
-
247
  return video_path, current_seed
248
 
249
  # ================================
@@ -264,116 +254,111 @@ with gr.Blocks(theme="gradio/soft", title="Dream-wan2-2-faster-Pro - Ultra Profe
264
  - 🔍 تحسين تلقائي للصورة المدخلة لجودة 8K افتراضية
265
  🔗 *جرب الآن وشارك إبداعاتك على Reddit أو Hugging Face!*
266
  """)
267
-
268
  gr.Markdown("# Wan 2.2 I2V سريع في 4 خطوات مع Lightning LoRA محسن")
269
  gr.Markdown(
270
  "شغل Wan 2.2 في 4-8 خطوات فقط، مع [Lightning LoRA](https://huggingface.co/Kijai/WanVideo_comfy/tree/main/Wan22-Lightning)، "
271
  "كمية fp8، وترجمة AoT — متوافق مع 🧨 diffusers و ZeroGPU⚡️. "
272
  "مُحسّن للاحترافية الفائقة: استقرار إطارات، إضاءة سينمائية، وتفاصيل واقعية عميقة."
273
  )
274
-
275
  with gr.Row():
276
  with gr.Column(scale=1):
277
  input_image_component = gr.Image(type="pil", label="الصورة المدخلة", image_mode="RGB")
278
  prompt_input = gr.Textbox(
279
- label="الوصف (Prompt)",
280
- value=default_prompt_i2v,
281
  lines=4,
282
  placeholder="اكتب وصفًا سينمائيًا واقعيًا..."
283
  )
284
  duration_seconds_input = gr.Slider(
285
- minimum=MIN_DURATION,
286
- maximum=MAX_DURATION,
287
- step=0.1,
288
  value=3.5,
289
  label="المدة (ثوانٍ)",
290
  info=f"محدود بـ {MIN_FRAMES_MODEL}-{MAX_FRAMES_MODEL} إطار عند {FIXED_FPS} إطار/ثانية."
291
  )
292
  with gr.Accordion("الإعدادات المتقدمة", open=False):
293
  negative_prompt_input = gr.Textbox(
294
- label="الوصف السلبي (Negative Prompt)",
295
- value=default_negative_prompt,
296
  lines=4
297
  )
298
  seed_input = gr.Slider(
299
- label="البذرة (Seed)",
300
- minimum=0,
301
- maximum=MAX_SEED,
302
- step=1,
303
- value=42,
304
  interactive=True
305
  )
306
  randomize_seed_checkbox = gr.Checkbox(
307
- label="توليد بذرة عشوائية",
308
- value=True,
309
  interactive=True
310
  )
311
  steps_slider = gr.Slider(
312
- minimum=1,
313
- maximum=30,
314
- step=1,
315
- value=6,
316
  label="عدد الخطوات (Inference Steps)"
317
  )
318
  guidance_scale_input = gr.Slider(
319
- minimum=0.0,
320
- maximum=10.0,
321
- step=0.1,
322
- value=1.2, # قيمة محسنة قليلاً للاستقرار
323
  label="مقياس التوجيه - مرحلة الضوضاء العالية"
324
  )
325
  guidance_scale_2_input = gr.Slider(
326
- minimum=0.0,
327
- maximum=10.0,
328
- step=0.1,
329
- value=1.2, # قيمة محسنة
330
  label="مقياس التوجيه 2 - مرحلة الضوضاء المنخفضة"
331
  )
332
- # إضافة خيار جديد لتعزيز الجودة
333
  enhance_image_checkbox = gr.Checkbox(
334
- label="تعزيز الصورة المدخلة تلقائيًا (للواقعية العميقة)",
335
  value=True
336
  )
337
  generate_button = gr.Button("توليد الفيديو", variant="primary", size="lg")
338
-
339
  with gr.Column(scale=1):
340
  video_output = gr.Video(
341
- label="الفيديو المُولّد",
342
- autoplay=True,
343
  interactive=False,
344
- show_share_button=True # إضافة زر مشاركة للاحترافية
345
  )
346
  seed_output = gr.Textbox(label="البذرة المستخدمة", interactive=False)
347
-
348
- # قائمة المدخلات مع الإضافة الجديدة
349
  ui_inputs = [
350
  input_image_component, prompt_input, steps_slider,
351
  negative_prompt_input, duration_seconds_input,
352
  guidance_scale_input, guidance_scale_2_input,
353
  seed_input, randomize_seed_checkbox, enhance_image_checkbox
354
  ]
355
-
356
- # تعديل الدالة لاستخدام الخيار الجديد (إذا كان مفعلاً، قم بتعزيز الصورة في resize_image)
357
  def wrapped_generate(*args):
358
- enhance = args[-1] # آخر معامل هو enhance_checkbox
359
- # يمكن تعديل resize_image لاستخدام enhance إذا لزم، لكنها مفعلة افتراضيًا الآن
360
- return generate_video(*args[:-1]) # تمرير بدون الخيار الأخير
361
-
362
  generate_button.click(
363
- fn=wrapped_generate,
364
- inputs=ui_inputs,
365
  outputs=[video_output, seed_output]
366
  )
367
-
368
- # إضافة أمثلة للاحترافية
369
  gr.Examples(
370
  examples=[
371
  ["path/to/example_image.jpg", "A professional portrait in cinematic lighting", 4, "", 2.0, 1.0, 1.0, 42, False],
372
- # أضف المزيد حسب الحاجة
373
  ],
374
- inputs=ui_inputs[:-1], # بدون الخيار الجديد
375
  label="أمثلة سريعة"
376
  )
377
 
378
  if __name__ == "__main__":
379
- demo.queue().launch(mcp_server=True, share=True)
 
1
  import spaces
2
  import torch
3
+ from diffusers import WanImageToVideoPipeline, WanTransformer3DModel # الاستيراد الصحيح
 
4
  from diffusers.utils.export_utils import export_to_video
5
  import gradio as gr
6
  import tempfile
 
13
  from torchao.quantization import Int8WeightOnlyConfig
14
  import aoti
15
  from typing import Optional, Tuple, List
16
+ import ftfy # إضافة لمعالجة النصوص
17
 
18
  MODEL_ID = "Wan-AI/Wan2.2-I2V-A14B-Diffusers"
19
  MAX_DIM = 832
 
31
  pipe = WanImageToVideoPipeline.from_pretrained(
32
  MODEL_ID,
33
  transformer=WanTransformer3DModel.from_pretrained(
34
+ MODEL_ID, # استخدم MODEL_ID الرئيسي إذا لم يكن cbensimon متاحًا
35
  subfolder='transformer',
36
  torch_dtype=torch.bfloat16,
37
  device_map='cuda',
38
  ),
39
  transformer_2=WanTransformer3DModel.from_pretrained(
40
+ MODEL_ID,
41
  subfolder='transformer_2',
42
  torch_dtype=torch.bfloat16,
43
  device_map='cuda',
 
45
  torch_dtype=torch.bfloat16,
46
  ).to('cuda')
47
 
48
+ # تحميل LoRA مع تحسينات للجودة العالية (مع دعم transformer_2)
49
  pipe.load_lora_weights(
50
  "Kijai/WanVideo_comfy",
51
  weight_name="Lightx2v/lightx2v_I2V_14B_480p_cfg_step_distill_rank128_bf16.safetensors",
52
  adapter_name="lightx2v"
53
  )
54
+ kwargs_lora = {"load_into_transformer_2": True} # لـ Wan2.2
55
  pipe.load_lora_weights(
56
  "Kijai/WanVideo_comfy",
57
  weight_name="Lightx2v/lightx2v_I2V_14B_480p_cfg_step_distill_rank128_bf16.safetensors",
 
60
  pipe.set_adapters(["lightx2v", "lightx2v_2"], adapter_weights=[1., 1.])
61
 
62
  # دمج LoRA مع مقاييس مخصصة لتعزيز الاستقرار والاحترافية
63
+ pipe.fuse_lora(adapter_names=["lightx2v"], lora_scale=3.5, components=["transformer"])
64
+ pipe.fuse_lora(adapter_names=["lightx2v_2"], lora_scale=1.2, components=["transformer_2"])
65
  pipe.unload_lora_weights()
66
 
67
  # الكمية لتوفير الذاكرة مع الحفاظ على الدقة
 
73
  aoti.aoti_blocks_load(pipe.transformer, 'zerogpu-aoti/Wan2', variant='fp8da')
74
  aoti.aoti_blocks_load(pipe.transformer_2, 'zerogpu-aoti/Wan2', variant='fp8da')
75
 
76
+ # تحسين الـ Prompt الافتراضي... (يبقى كما هو)
77
  default_prompt_i2v = (
78
  "ultra realistic cinematic footage shot on Arri Alexa LF with Panavision anamorphic lenses, "
79
  "perfectly preserved facial identity, micro-expressions, and body structure across all frames, "
 
96
  "frame-to-frame stability with advanced optical flow preservation"
97
  )
98
 
 
99
  default_negative_prompt = (
100
  "low quality, low resolution, low contrast, poor lighting, underexposed, overexposed, bad composition, "
101
  "bad framing, bad perspective, flat lighting, washed out colors, jpeg artifacts, noise, static, grain, "
 
119
  """
120
  تحسين الصورة المدخلة لتعزيز الجودة والواقعية قبل التمرير.
121
  """
 
122
  enhancer = ImageEnhance.Contrast(image)
123
  image = enhancer.enhance(1.05)
124
  enhancer = ImageEnhance.Sharpness(image)
125
  image = enhancer.enhance(1.1)
 
126
  image = image.filter(ImageFilter.UnsharpMask(radius=1, percent=150, threshold=3))
127
  return image
128
 
 
130
  """
131
  تحسين دالة التمرير للحفاظ على الجودة العالية مع الالتزام بالأبعاد.
132
  """
 
133
  enhanced_image = enhance_image(image)
134
+
135
  width, height = enhanced_image.size
136
  if width == height:
137
  return enhanced_image.resize((SQUARE_DIM, SQUARE_DIM), Image.LANCZOS)
138
+
139
  aspect_ratio = width / height
140
  MAX_ASPECT_RATIO = MAX_DIM / MIN_DIM
141
  MIN_ASPECT_RATIO = MIN_DIM / MAX_DIM
142
+
143
  image_to_resize = enhanced_image
144
  if aspect_ratio > MAX_ASPECT_RATIO:
145
  target_w, target_h = MAX_DIM, MIN_DIM
 
158
  else:
159
  target_h = MAX_DIM
160
  target_w = int(round(target_h * aspect_ratio))
161
+
162
  final_w = round(target_w / MULTIPLE_OF) * MULTIPLE_OF
163
  final_h = round(target_h / MULTIPLE_OF) * MULTIPLE_OF
164
  final_w = max(MIN_DIM, min(MAX_DIM, final_w))
165
  final_h = max(MIN_DIM, min(MAX_DIM, final_h))
166
+
 
167
  return image_to_resize.resize((final_w, final_h), Image.LANCZOS)
168
 
169
  def get_num_frames(duration_seconds: float) -> int:
 
198
  """
199
  if input_image is None:
200
  raise gr.Error("يرجى تحميل صورة مدخلة.")
201
+
 
202
  gc.collect()
203
  torch.cuda.empty_cache()
204
+
205
  num_frames = get_num_frames(duration_seconds)
206
  current_seed = random.randint(0, MAX_SEED) if randomize_seed else int(seed)
207
+
 
208
  resized_image = resize_image(input_image)
209
+
210
  progress(0, desc="بدء التوليد...")
211
+
 
212
  with progress():
213
  output_frames_list = pipe(
214
  image=resized_image,
215
+ prompt=ftfy.fix_text(prompt), # إضافة ftfy للنصوص
216
+ negative_prompt=ftfy.fix_text(negative_prompt),
217
  height=resized_image.height,
218
  width=resized_image.width,
219
  num_frames=num_frames,
 
222
  num_inference_steps=int(steps),
223
  generator=torch.Generator(device="cuda").manual_seed(current_seed),
224
  ).frames[0]
225
+
226
  progress(1, desc="تصدير الفيديو...")
227
+
 
228
  with tempfile.NamedTemporaryFile(suffix=".mp4", delete=False) as tmpfile:
229
  video_path = tmpfile.name
230
+
231
  export_to_video(output_frames_list, video_path, fps=FIXED_FPS)
232
+
 
233
  del output_frames_list
234
  gc.collect()
235
  torch.cuda.empty_cache()
236
+
237
  return video_path, current_seed
238
 
239
  # ================================
 
254
  - 🔍 تحسين تلقائي للصورة المدخلة لجودة 8K افتراضية
255
  🔗 *جرب الآن وشارك إبداعاتك على Reddit أو Hugging Face!*
256
  """)
257
+
258
  gr.Markdown("# Wan 2.2 I2V سريع في 4 خطوات مع Lightning LoRA محسن")
259
  gr.Markdown(
260
  "شغل Wan 2.2 في 4-8 خطوات فقط، مع [Lightning LoRA](https://huggingface.co/Kijai/WanVideo_comfy/tree/main/Wan22-Lightning)، "
261
  "كمية fp8، وترجمة AoT — متوافق مع 🧨 diffusers و ZeroGPU⚡️. "
262
  "مُحسّن للاحترافية الفائقة: استقرار إطارات، إضاءة سينمائية، وتفاصيل واقعية عميقة."
263
  )
264
+
265
  with gr.Row():
266
  with gr.Column(scale=1):
267
  input_image_component = gr.Image(type="pil", label="الصورة المدخلة", image_mode="RGB")
268
  prompt_input = gr.Textbox(
269
+ label="الوصف (Prompt)",
270
+ value=default_prompt_i2v,
271
  lines=4,
272
  placeholder="اكتب وصفًا سينمائيًا واقعيًا..."
273
  )
274
  duration_seconds_input = gr.Slider(
275
+ minimum=MIN_DURATION,
276
+ maximum=MAX_DURATION,
277
+ step=0.1,
278
  value=3.5,
279
  label="المدة (ثوانٍ)",
280
  info=f"محدود بـ {MIN_FRAMES_MODEL}-{MAX_FRAMES_MODEL} إطار عند {FIXED_FPS} إطار/ثانية."
281
  )
282
  with gr.Accordion("الإعدادات المتقدمة", open=False):
283
  negative_prompt_input = gr.Textbox(
284
+ label="الوصف السلبي (Negative Prompt)",
285
+ value=default_negative_prompt,
286
  lines=4
287
  )
288
  seed_input = gr.Slider(
289
+ label="البذرة (Seed)",
290
+ minimum=0,
291
+ maximum=MAX_SEED,
292
+ step=1,
293
+ value=42,
294
  interactive=True
295
  )
296
  randomize_seed_checkbox = gr.Checkbox(
297
+ label="توليد بذرة عشوائية",
298
+ value=True,
299
  interactive=True
300
  )
301
  steps_slider = gr.Slider(
302
+ minimum=1,
303
+ maximum=30,
304
+ step=1,
305
+ value=6,
306
  label="عدد الخطوات (Inference Steps)"
307
  )
308
  guidance_scale_input = gr.Slider(
309
+ minimum=0.0,
310
+ maximum=10.0,
311
+ step=0.1,
312
+ value=1.2,
313
  label="مقياس التوجيه - مرحلة الضوضاء العالية"
314
  )
315
  guidance_scale_2_input = gr.Slider(
316
+ minimum=0.0,
317
+ maximum=10.0,
318
+ step=0.1,
319
+ value=1.2,
320
  label="مقياس التوجيه 2 - مرحلة الضوضاء المنخفضة"
321
  )
 
322
  enhance_image_checkbox = gr.Checkbox(
323
+ label="تعزيز الصورة المدخلة تلقائيًا (للواقعية العميقة)",
324
  value=True
325
  )
326
  generate_button = gr.Button("توليد الفيديو", variant="primary", size="lg")
327
+
328
  with gr.Column(scale=1):
329
  video_output = gr.Video(
330
+ label="الفيديو المُولّد",
331
+ autoplay=True,
332
  interactive=False,
333
+ show_share_button=True
334
  )
335
  seed_output = gr.Textbox(label="البذرة المستخدمة", interactive=False)
336
+
 
337
  ui_inputs = [
338
  input_image_component, prompt_input, steps_slider,
339
  negative_prompt_input, duration_seconds_input,
340
  guidance_scale_input, guidance_scale_2_input,
341
  seed_input, randomize_seed_checkbox, enhance_image_checkbox
342
  ]
343
+
 
344
  def wrapped_generate(*args):
345
+ enhance = args[-1]
346
+ # إذا كان enhance مفعلاً، قم بتعزيز في resize_image (مُفعَّل افتراضيًا)
347
+ return generate_video(*args[:-1])
348
+
349
  generate_button.click(
350
+ fn=wrapped_generate,
351
+ inputs=ui_inputs,
352
  outputs=[video_output, seed_output]
353
  )
354
+
 
355
  gr.Examples(
356
  examples=[
357
  ["path/to/example_image.jpg", "A professional portrait in cinematic lighting", 4, "", 2.0, 1.0, 1.0, 42, False],
 
358
  ],
359
+ inputs=ui_inputs[:-1],
360
  label="أمثلة سريعة"
361
  )
362
 
363
  if __name__ == "__main__":
364
+ demo.queue().launch(mcp_server=True, share=True)