multimodalart HF Staff commited on
Commit
932647d
·
verified ·
1 Parent(s): 3bceb05

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +267 -73
app.py CHANGED
@@ -102,8 +102,8 @@ def _generate_video_segment(input_image_path: str, output_image_path: str, promp
102
  )
103
  return result[0]["video"]
104
 
105
- def build_relight_prompt(light_type, light_direction, light_intensity, prompt):
106
- """Build the relighting prompt based on user selections."""
107
 
108
  # Priority 1: User's prompt (translated to Chinese if needed)
109
  if prompt and prompt.strip():
@@ -116,38 +116,129 @@ def build_relight_prompt(light_type, light_direction, light_intensity, prompt):
116
  # Priority 2: Build from controls
117
  prompt_parts = ["重新照明"]
118
 
119
- # Light type descriptions
120
  light_descriptions = {
121
- "soft_window": "使用窗帘透光(柔和漫射)的光线", # Soft diffuse light from curtains
122
- "golden_hour": "使用金色黄昏的温暖光线", # Warm golden hour light
123
- "studio": "使用专业摄影棚的均匀光线", # Professional studio lighting
124
- "dramatic": "使用戏剧性的高对比度光线", # Dramatic high-contrast lighting
125
- "natural": "使用自然日光", # Natural daylight
126
- "neon": "使用霓虹灯光效果", # Neon lighting effect
127
- "candlelight": "使用烛光的温暖氛围", # Warm candlelight ambiance
128
- "moonlight": "使用月光的冷色调", # Cool-toned moonlight
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  }
130
 
131
- # Direction descriptions
132
  direction_descriptions = {
133
- "front": "从正面照射", # From the front
134
- "side": "从侧面照射", # From the side
135
- "back": "从背后照射", # From behind (backlight)
136
- "top": "从上方照射", # From above
137
- "bottom": "从下方照射", # From below
 
 
 
 
138
  }
139
 
140
  # Intensity descriptions
141
  intensity_descriptions = {
142
- "soft": "柔和强度", # Soft intensity
143
- "medium": "中等强度", # Medium intensity
144
- "strong": "强烈强度", # Strong intensity
 
145
  }
146
 
147
- # Build the prompt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  if light_type != "none":
149
  prompt_parts.append(light_descriptions.get(light_type, ""))
150
 
 
 
 
151
  if light_direction != "none":
152
  prompt_parts.append(direction_descriptions.get(light_direction, ""))
153
 
@@ -158,7 +249,7 @@ def build_relight_prompt(light_type, light_direction, light_intensity, prompt):
158
 
159
  # Add instruction if we have settings
160
  if len(prompt_parts) > 1:
161
- final_prompt += "对图片进行重新照明" # Relight the image
162
 
163
  return final_prompt if len(prompt_parts) > 1 else "重新照明,使用自然光线对图片进行重新照明"
164
 
@@ -169,6 +260,7 @@ def infer_relight(
169
  light_type,
170
  light_direction,
171
  light_intensity,
 
172
  prompt,
173
  seed,
174
  randomize_seed,
@@ -179,7 +271,7 @@ def infer_relight(
179
  prev_output = None,
180
  progress=gr.Progress(track_tqdm=True)
181
  ):
182
- final_prompt = build_relight_prompt(light_type, light_direction, light_intensity, prompt)
183
  print(f"Generated Prompt: {final_prompt}")
184
 
185
  if randomize_seed:
@@ -240,12 +332,15 @@ def create_video_between_images(input_image, output_image, prompt: str, request:
240
 
241
 
242
  # --- UI ---
243
- css = '''#col-container { max-width: 800px; margin: 0 auto; }
 
244
  .dark .progress-text{color: white !important}
245
- #examples{max-width: 800px; margin: 0 auto; }'''
 
 
246
 
247
  def reset_all():
248
- return ["none", "none", "none", "", False, True]
249
 
250
  def end_reset():
251
  return False
@@ -278,56 +373,153 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=css) as demo:
278
  gr.Markdown("""
279
  Qwen Image Edit 2509 for Image Relighting ✨
280
  Using [dx8152's Qwen-Image-Edit-2509-Relight LoRA](https://huggingface.co/dx8152/Qwen-Image-Edit-2509-Relight) and [linoyts/Qwen-Image-Edit-Rapid-AIO](https://huggingface.co/linoyts/Qwen-Image-Edit-Rapid-AIO) for 4-step inference 💨
 
 
281
  """
282
  )
283
  with gr.Row():
284
- with gr.Column():
285
  image = gr.Image(label="Input Image", type="pil")
286
  prev_output = gr.Image(value=None, visible=False)
287
  is_reset = gr.Checkbox(value=False, visible=False)
288
 
289
- with gr.Tab("Lighting Controls"):
290
- light_type = gr.Dropdown(
291
- label="Light Type",
292
  choices=[
293
  ("None", "none"),
294
- ("Soft Window Light (柔和窗光)", "soft_window"),
295
- ("Golden Hour (金色黄昏)", "golden_hour"),
296
- ("Studio Lighting (摄影棚灯光)", "studio"),
297
- ("Dramatic (戏剧性)", "dramatic"),
298
- ("Natural Daylight (自然日光)", "natural"),
299
- ("Neon (霓虹灯)", "neon"),
300
- ("Candlelight (烛光)", "candlelight"),
301
- ("Moonlight (月光)", "moonlight"),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
302
  ],
303
- value="none"
 
304
  )
305
-
306
- light_direction = gr.Dropdown(
307
- label="Light Direction",
 
308
  choices=[
309
  ("None", "none"),
310
- ("Front (正面)", "front"),
311
- ("Side (侧面)", "side"),
312
- ("Back (背光)", "back"),
313
- ("Top (上方)", "top"),
314
- ("Bottom (下方)", "bottom"),
 
 
 
315
  ],
316
- value="none"
 
317
  )
318
-
319
- light_intensity = gr.Dropdown(
320
- label="Light Intensity",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
321
  choices=[
322
  ("None", "none"),
323
- ("Soft (柔和)", "soft"),
324
- ("Medium (中等)", "medium"),
325
- ("Strong (强烈)", "strong"),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
326
  ],
327
- value="none"
 
328
  )
329
 
330
- with gr.Tab("Custom Prompt"):
331
  prompt = gr.Textbox(
332
  label="Relighting Prompt",
333
  placeholder="Example: Add warm sunset lighting from the right",
@@ -335,10 +527,10 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=css) as demo:
335
  )
336
 
337
  with gr.Row():
338
- reset_btn = gr.Button("Reset")
339
- run_btn = gr.Button("Generate", variant="primary")
340
 
341
- with gr.Accordion("Advanced Settings", open=False):
342
  seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0)
343
  randomize_seed = gr.Checkbox(label="Randomize Seed", value=True)
344
  true_guidance_scale = gr.Slider(label="True Guidance Scale", minimum=1.0, maximum=10.0, step=0.1, value=1.0)
@@ -346,7 +538,7 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=css) as demo:
346
  height = gr.Slider(label="Height", minimum=256, maximum=2048, step=8, value=1024)
347
  width = gr.Slider(label="Width", minimum=256, maximum=2048, step=8, value=1024)
348
 
349
- with gr.Column():
350
  result = gr.Image(label="Output Image", interactive=False)
351
  prompt_preview = gr.Textbox(label="Processed Prompt", interactive=False)
352
  create_video_button = gr.Button("🎥 Create Video Between Images", variant="secondary", visible=False)
@@ -354,7 +546,7 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=css) as demo:
354
  video_output = gr.Video(label="Generated Video", show_download_button=True, autoplay=True)
355
 
356
  inputs = [
357
- image, light_type, light_direction, light_intensity, prompt,
358
  seed, randomize_seed, true_guidance_scale, num_inference_steps, height, width, prev_output
359
  ]
360
  outputs = [result, seed, prompt_preview]
@@ -363,7 +555,7 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=css) as demo:
363
  reset_btn.click(
364
  fn=reset_all,
365
  inputs=None,
366
- outputs=[light_type, light_direction, light_intensity, prompt, is_reset],
367
  queue=False
368
  ).then(fn=end_reset, inputs=None, outputs=[is_reset], queue=False)
369
 
@@ -392,16 +584,18 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=css) as demo:
392
  api_name=False
393
  )
394
 
395
- # Examples - You'll need to add your own example images
396
  gr.Examples(
397
  examples=[
398
- [None, "soft_window", "side", "soft", "", 0, True, 1.0, 4, 1024, 1024],
399
- [None, "golden_hour", "front", "medium", "", 0, True, 1.0, 4, 1024, 1024],
400
- [None, "dramatic", "side", "strong", "", 0, True, 1.0, 4, 1024, 1024],
401
- [None, "neon", "front", "medium", "", 0, True, 1.0, 4, 1024, 1024],
402
- [None, "candlelight", "front", "soft", "", 0, True, 1.0, 4, 1024, 1024],
 
 
403
  ],
404
- inputs=[image, light_type, light_direction, light_intensity, prompt,
405
  seed, randomize_seed, true_guidance_scale, num_inference_steps, height, width],
406
  outputs=outputs,
407
  fn=infer_relight,
@@ -417,7 +611,7 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=css) as demo:
417
  ).then(
418
  fn=reset_all,
419
  inputs=None,
420
- outputs=[light_type, light_direction, light_intensity, prompt, is_reset],
421
  queue=False
422
  ).then(
423
  fn=end_reset,
@@ -438,14 +632,14 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=css) as demo:
438
  return result_img, result_seed, result_prompt, gr.update(visible=show_button)
439
 
440
  control_inputs = [
441
- image, light_type, light_direction, light_intensity, prompt,
442
  seed, randomize_seed, true_guidance_scale, num_inference_steps, height, width, prev_output
443
  ]
444
  control_inputs_with_flag = [is_reset] + control_inputs
445
 
446
- for control in [light_type, light_direction, light_intensity]:
447
  control.input(fn=maybe_infer, inputs=control_inputs_with_flag, outputs=outputs + [create_video_button])
448
 
449
  run_event.then(lambda img, *_: img, inputs=[result], outputs=[prev_output])
450
 
451
- demo.launch()
 
102
  )
103
  return result[0]["video"]
104
 
105
+ def build_relight_prompt(light_type, light_direction, light_intensity, illumination_env, prompt):
106
+ """Build the relighting prompt based on user selections - Qwen style."""
107
 
108
  # Priority 1: User's prompt (translated to Chinese if needed)
109
  if prompt and prompt.strip():
 
116
  # Priority 2: Build from controls
117
  prompt_parts = ["重新照明"]
118
 
119
+ # Light type descriptions (expanded from IC-Light style but in Chinese)
120
  light_descriptions = {
121
+ "none": "",
122
+ "soft_window": "窗帘透光(柔和漫射)",
123
+ "golden_hour": "金色黄昏的温暖光线",
124
+ "studio": "专业摄影棚的均匀光线",
125
+ "dramatic": "戏剧性的高对比度光线",
126
+ "natural": "自然日光",
127
+ "neon": "霓虹灯光效果",
128
+ "candlelight": "烛光的温暖氛围",
129
+ "moonlight": "月光的冷色调",
130
+ "sunrise": "日出的柔和光线",
131
+ "sunset_sea": "海面日落光线",
132
+ "overcast": "阴天的柔和漫射光",
133
+ "harsh_sun": "强烈的正午阳光",
134
+ "twilight": "黄昏时分的神秘光线",
135
+ "aurora": "极光般的多彩光线",
136
+ "firelight": "篝火的跳动光线",
137
+ "lightning": "闪电的瞬间强光",
138
+ "underwater": "水下的柔和蓝光",
139
+ "foggy": "雾气中的柔和扩散光",
140
+ "magic": "魔法般的神秘光芒",
141
+ "cyberpunk": "赛博朋克风格的RGB霓虹光",
142
+ "warm_home": "家庭温馨的暖色光",
143
+ "cold_industrial": "冷酷的工业照明",
144
+ "spotlight": "聚光灯效果",
145
+ "rim_light": "边缘光效果",
146
  }
147
 
148
+ # Direction descriptions (from IC-Light)
149
  direction_descriptions = {
150
+ "none": "",
151
+ "front": "正面照射",
152
+ "side": "侧面照射",
153
+ "left": "左侧照射",
154
+ "right": "右侧照射",
155
+ "back": "背后照射(逆光)",
156
+ "top": "上方照射",
157
+ "bottom": "下方照射",
158
+ "diagonal": "对角线照射",
159
  }
160
 
161
  # Intensity descriptions
162
  intensity_descriptions = {
163
+ "none": "",
164
+ "soft": "柔和强度",
165
+ "medium": "中等强度",
166
+ "strong": "强烈强度",
167
  }
168
 
169
+ # Illumination environments (from IC-Light vary, translated)
170
+ illumination_envs = {
171
+ "none": "",
172
+ "sunshine_window": "阳光从窗户透入",
173
+ "neon_city": "霓虹夜景,城市灯光",
174
+ "sci_fi_rgb": "科幻RGB发光,赛博朋克风格",
175
+ "warm_bedroom": "温暖氛围,家中,卧室",
176
+ "magic_lit": "魔法照明",
177
+ "gothic_cave": "邪恶哥特风格,洞穴中",
178
+ "light_shadow": "光影交错",
179
+ "window_shadow": "窗户投影",
180
+ "soft_studio": "柔和摄影棚灯光",
181
+ "cozy_bedroom": "家庭氛围,温馨卧室照明",
182
+ "wong_kar_wai": "王家卫风格霓虹灯,温暖色调",
183
+ "moonlight_curtains": "月光透过窗帘",
184
+ "stormy_sky": "暴风雨天空照明",
185
+ "underwater_glow": "水下发光,深海",
186
+ "foggy_forest": "雾中森林黎明",
187
+ "meadow_golden": "草地上的黄金时刻",
188
+ "rainbow_neon": "彩虹反射,霓虹",
189
+ "apocalyptic": "末日烟雾氛围",
190
+ "emergency_red": "红色紧急灯光",
191
+ "mystical_forest": "神秘发光,魔法森林",
192
+ "campfire": "篝火光芒",
193
+ "industrial_harsh": "严酷工业照明",
194
+ "mountain_sunrise": "山中日出",
195
+ "desert_evening": "沙漠黄昏",
196
+ "dark_alley": "黑暗小巷的月光",
197
+ "fairground": "游乐场的金色光芒",
198
+ "forest_midnight": "森林深夜",
199
+ "twilight_purple": "黄昏的紫粉色调",
200
+ "foggy_morning": "雾蒙蒙的早晨",
201
+ "rustic_candle": "乡村风格烛光",
202
+ "office_fluorescent": "办公室荧光灯",
203
+ "storm_lightning": "暴风雨中的闪电",
204
+ "fireplace_night": "夜晚壁炉的温暖光芒",
205
+ "ethereal_magic": "空灵发光,魔法森林",
206
+ "beach_dusky": "海滩的黄昏",
207
+ "trees_afternoon": "树林中的午后光线",
208
+ "urban_blue_neon": "蓝色霓虹灯,城市街道",
209
+ "rain_police": "雨中红蓝警灯",
210
+ "aurora_arctic": "极光,北极景观",
211
+ "foggy_mountains": "雾中山峦日出",
212
+ "city_skyline": "城市天际线的黄金时刻",
213
+ "twilight_mist": "神秘黄昏,浓雾",
214
+ "forest_rays": "森林空地的清晨光线",
215
+ "festival_lantern": "节日多彩灯笼光",
216
+ "stained_glass": "彩色玻璃的柔和光芒",
217
+ "dark_spotlight": "黑暗房间的强烈聚光",
218
+ "lake_evening": "湖面柔和的黄昏光",
219
+ "cave_crystal": "洞穴水晶反射",
220
+ "autumn_forest": "秋林中的鲜艳光线",
221
+ "snowfall_dusk": "黄昏轻柔降雪",
222
+ "winter_hazy": "冬日清晨的朦胧光",
223
+ "rain_city": "雨中城市灯光倒影",
224
+ "trees_golden_sun": "金色阳光穿过树林",
225
+ "fireflies_summer": "萤火虫点亮夏夜",
226
+ "forge_embers": "锻造炉的发光余烬",
227
+ "gothic_castle": "哥特城堡的昏暗烛光",
228
+ "starlight_midnight": "午夜明亮星光",
229
+ "rural_sunset": "乡村的温暖日落",
230
+ "haunted_flicker": "闹鬼房屋的闪烁灯光",
231
+ "desert_mirage": "沙漠日落海市蜃楼般的光",
232
+ "storm_beams": "风暴云中穿透的金色光束",
233
+ }
234
+
235
+ # Build the prompt - Qwen style (comma-separated, Chinese)
236
  if light_type != "none":
237
  prompt_parts.append(light_descriptions.get(light_type, ""))
238
 
239
+ if illumination_env != "none":
240
+ prompt_parts.append(illumination_envs.get(illumination_env, ""))
241
+
242
  if light_direction != "none":
243
  prompt_parts.append(direction_descriptions.get(light_direction, ""))
244
 
 
249
 
250
  # Add instruction if we have settings
251
  if len(prompt_parts) > 1:
252
+ final_prompt += ",对图片进行重新照明"
253
 
254
  return final_prompt if len(prompt_parts) > 1 else "重新照明,使用自然光线对图片进行重新照明"
255
 
 
260
  light_type,
261
  light_direction,
262
  light_intensity,
263
+ illumination_env,
264
  prompt,
265
  seed,
266
  randomize_seed,
 
271
  prev_output = None,
272
  progress=gr.Progress(track_tqdm=True)
273
  ):
274
+ final_prompt = build_relight_prompt(light_type, light_direction, light_intensity, illumination_env, prompt)
275
  print(f"Generated Prompt: {final_prompt}")
276
 
277
  if randomize_seed:
 
332
 
333
 
334
  # --- UI ---
335
+ css = '''
336
+ #col-container { max-width: 1200px; margin: 0 auto; }
337
  .dark .progress-text{color: white !important}
338
+ #examples{max-width: 1200px; margin: 0 auto; }
339
+ .radio-group {display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px;}
340
+ '''
341
 
342
  def reset_all():
343
+ return ["none", "none", "none", "none", "", False, True]
344
 
345
  def end_reset():
346
  return False
 
373
  gr.Markdown("""
374
  Qwen Image Edit 2509 for Image Relighting ✨
375
  Using [dx8152's Qwen-Image-Edit-2509-Relight LoRA](https://huggingface.co/dx8152/Qwen-Image-Edit-2509-Relight) and [linoyts/Qwen-Image-Edit-Rapid-AIO](https://huggingface.co/linoyts/Qwen-Image-Edit-Rapid-AIO) for 4-step inference 💨
376
+
377
+ Expanded lighting options inspired by IC-Light v2 🎨
378
  """
379
  )
380
  with gr.Row():
381
+ with gr.Column(scale=1):
382
  image = gr.Image(label="Input Image", type="pil")
383
  prev_output = gr.Image(value=None, visible=False)
384
  is_reset = gr.Checkbox(value=False, visible=False)
385
 
386
+ with gr.Accordion("💡 Light Type", open=True):
387
+ light_type = gr.Radio(
388
+ label="Select Light Source",
389
  choices=[
390
  ("None", "none"),
391
+ ("Soft Window Light", "soft_window"),
392
+ ("Golden Hour", "golden_hour"),
393
+ ("Studio Lighting", "studio"),
394
+ ("Dramatic", "dramatic"),
395
+ ("Natural Daylight", "natural"),
396
+ ("Neon", "neon"),
397
+ ("Candlelight", "candlelight"),
398
+ ("Moonlight", "moonlight"),
399
+ ("Sunrise", "sunrise"),
400
+ ("Sunset over Sea", "sunset_sea"),
401
+ ("Overcast", "overcast"),
402
+ ("Harsh Sunlight", "harsh_sun"),
403
+ ("Twilight", "twilight"),
404
+ ("Aurora", "aurora"),
405
+ ("Firelight", "firelight"),
406
+ ("Lightning", "lightning"),
407
+ ("Underwater", "underwater"),
408
+ ("Foggy", "foggy"),
409
+ ("Magic Light", "magic"),
410
+ ("Cyberpunk", "cyberpunk"),
411
+ ("Warm Home", "warm_home"),
412
+ ("Cold Industrial", "cold_industrial"),
413
+ ("Spotlight", "spotlight"),
414
+ ("Rim Light", "rim_light"),
415
  ],
416
+ value="none",
417
+ elem_classes="radio-group"
418
  )
419
+
420
+ with gr.Accordion("🧭 Light Direction", open=True):
421
+ light_direction = gr.Radio(
422
+ label="Select Direction",
423
  choices=[
424
  ("None", "none"),
425
+ ("Front", "front"),
426
+ ("Side", "side"),
427
+ ("Left", "left"),
428
+ ("Right", "right"),
429
+ ("Back (Backlight)", "back"),
430
+ ("Top", "top"),
431
+ ("Bottom", "bottom"),
432
+ ("Diagonal", "diagonal"),
433
  ],
434
+ value="none",
435
+ elem_classes="radio-group"
436
  )
437
+
438
+ with gr.Accordion("⚡ Light Intensity", open=True):
439
+ light_intensity = gr.Radio(
440
+ label="Select Intensity",
441
+ choices=[
442
+ ("None", "none"),
443
+ ("Soft", "soft"),
444
+ ("Medium", "medium"),
445
+ ("Strong", "strong"),
446
+ ],
447
+ value="none",
448
+ elem_classes="radio-group"
449
+ )
450
+
451
+ with gr.Accordion("🌍 Illumination Environment", open=False):
452
+ illumination_env = gr.Radio(
453
+ label="Select Environment",
454
  choices=[
455
  ("None", "none"),
456
+ ("Sunshine from Window", "sunshine_window"),
457
+ ("Neon Night, City", "neon_city"),
458
+ ("Sci-Fi RGB Glowing, Cyberpunk", "sci_fi_rgb"),
459
+ ("Warm Atmosphere, at Home, Bedroom", "warm_bedroom"),
460
+ ("Magic Lit", "magic_lit"),
461
+ ("Evil, Gothic, in a Cave", "gothic_cave"),
462
+ ("Light and Shadow", "light_shadow"),
463
+ ("Shadow from Window", "window_shadow"),
464
+ ("Soft Studio Lighting", "soft_studio"),
465
+ ("Home Atmosphere, Cozy Bedroom", "cozy_bedroom"),
466
+ ("Neon, Wong Kar-wai, Warm", "wong_kar_wai"),
467
+ ("Moonlight through Curtains", "moonlight_curtains"),
468
+ ("Stormy Sky Lighting", "stormy_sky"),
469
+ ("Underwater Glow, Deep Sea", "underwater_glow"),
470
+ ("Foggy Forest at Dawn", "foggy_forest"),
471
+ ("Golden Hour in a Meadow", "meadow_golden"),
472
+ ("Rainbow Reflections, Neon", "rainbow_neon"),
473
+ ("Apocalyptic, Smoky Atmosphere", "apocalyptic"),
474
+ ("Red Glow, Emergency Lights", "emergency_red"),
475
+ ("Mystical Glow, Enchanted Forest", "mystical_forest"),
476
+ ("Campfire Light", "campfire"),
477
+ ("Harsh, Industrial Lighting", "industrial_harsh"),
478
+ ("Sunrise in the Mountains", "mountain_sunrise"),
479
+ ("Evening Glow in the Desert", "desert_evening"),
480
+ ("Moonlight in a Dark Alley", "dark_alley"),
481
+ ("Golden Glow at a Fairground", "fairground"),
482
+ ("Midnight in the Forest", "forest_midnight"),
483
+ ("Purple and Pink Hues at Twilight", "twilight_purple"),
484
+ ("Foggy Morning, Muted Light", "foggy_morning"),
485
+ ("Candle-lit Room, Rustic Vibe", "rustic_candle"),
486
+ ("Fluorescent Office Lighting", "office_fluorescent"),
487
+ ("Lightning Flash in Storm", "storm_lightning"),
488
+ ("Night, Cozy Warm Light from Fireplace", "fireplace_night"),
489
+ ("Ethereal Glow, Magical Forest", "ethereal_magic"),
490
+ ("Dusky Evening on a Beach", "beach_dusky"),
491
+ ("Afternoon Light Filtering through Trees", "trees_afternoon"),
492
+ ("Blue Neon Light, Urban Street", "urban_blue_neon"),
493
+ ("Red and Blue Police Lights in Rain", "rain_police"),
494
+ ("Aurora Borealis Glow, Arctic Landscape", "aurora_arctic"),
495
+ ("Sunrise through Foggy Mountains", "foggy_mountains"),
496
+ ("Golden Hour on a City Skyline", "city_skyline"),
497
+ ("Mysterious Twilight, Heavy Mist", "twilight_mist"),
498
+ ("Early Morning Rays, Forest Clearing", "forest_rays"),
499
+ ("Colorful Lantern Light at Festival", "festival_lantern"),
500
+ ("Soft Glow through Stained Glass", "stained_glass"),
501
+ ("Harsh Spotlight in Dark Room", "dark_spotlight"),
502
+ ("Mellow Evening Glow on a Lake", "lake_evening"),
503
+ ("Crystal Reflections in a Cave", "cave_crystal"),
504
+ ("Vibrant Autumn Lighting in a Forest", "autumn_forest"),
505
+ ("Gentle Snowfall at Dusk", "snowfall_dusk"),
506
+ ("Hazy Light of a Winter Morning", "winter_hazy"),
507
+ ("Rain-soaked Reflections in City Lights", "rain_city"),
508
+ ("Golden Sunlight Streaming through Trees", "trees_golden_sun"),
509
+ ("Fireflies Lighting up a Summer Night", "fireflies_summer"),
510
+ ("Glowing Embers from a Forge", "forge_embers"),
511
+ ("Dim Candlelight in a Gothic Castle", "gothic_castle"),
512
+ ("Midnight Sky with Bright Starlight", "starlight_midnight"),
513
+ ("Warm Sunset in a Rural Village", "rural_sunset"),
514
+ ("Flickering Light in a Haunted House", "haunted_flicker"),
515
+ ("Desert Sunset with Mirage-like Glow", "desert_mirage"),
516
+ ("Golden Beams Piercing through Storm Clouds", "storm_beams"),
517
  ],
518
+ value="none",
519
+ elem_classes="radio-group"
520
  )
521
 
522
+ with gr.Accordion("✍️ Custom Prompt", open=False):
523
  prompt = gr.Textbox(
524
  label="Relighting Prompt",
525
  placeholder="Example: Add warm sunset lighting from the right",
 
527
  )
528
 
529
  with gr.Row():
530
+ reset_btn = gr.Button("🔄 Reset")
531
+ run_btn = gr.Button("Generate", variant="primary")
532
 
533
+ with gr.Accordion("⚙️ Advanced Settings", open=False):
534
  seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0)
535
  randomize_seed = gr.Checkbox(label="Randomize Seed", value=True)
536
  true_guidance_scale = gr.Slider(label="True Guidance Scale", minimum=1.0, maximum=10.0, step=0.1, value=1.0)
 
538
  height = gr.Slider(label="Height", minimum=256, maximum=2048, step=8, value=1024)
539
  width = gr.Slider(label="Width", minimum=256, maximum=2048, step=8, value=1024)
540
 
541
+ with gr.Column(scale=1):
542
  result = gr.Image(label="Output Image", interactive=False)
543
  prompt_preview = gr.Textbox(label="Processed Prompt", interactive=False)
544
  create_video_button = gr.Button("🎥 Create Video Between Images", variant="secondary", visible=False)
 
546
  video_output = gr.Video(label="Generated Video", show_download_button=True, autoplay=True)
547
 
548
  inputs = [
549
+ image, light_type, light_direction, light_intensity, illumination_env, prompt,
550
  seed, randomize_seed, true_guidance_scale, num_inference_steps, height, width, prev_output
551
  ]
552
  outputs = [result, seed, prompt_preview]
 
555
  reset_btn.click(
556
  fn=reset_all,
557
  inputs=None,
558
+ outputs=[light_type, light_direction, light_intensity, illumination_env, prompt, is_reset],
559
  queue=False
560
  ).then(fn=end_reset, inputs=None, outputs=[is_reset], queue=False)
561
 
 
584
  api_name=False
585
  )
586
 
587
+ # Examples
588
  gr.Examples(
589
  examples=[
590
+ [None, "soft_window", "side", "soft", "none", "", 0, True, 1.0, 4, 1024, 1024],
591
+ [None, "golden_hour", "front", "medium", "none", "", 0, True, 1.0, 4, 1024, 1024],
592
+ [None, "dramatic", "side", "strong", "none", "", 0, True, 1.0, 4, 1024, 1024],
593
+ [None, "neon", "front", "medium", "neon_city", "", 0, True, 1.0, 4, 1024, 1024],
594
+ [None, "candlelight", "front", "soft", "cozy_bedroom", "", 0, True, 1.0, 4, 1024, 1024],
595
+ [None, "moonlight", "top", "soft", "moonlight_curtains", "", 0, True, 1.0, 4, 1024, 1024],
596
+ [None, "cyberpunk", "side", "strong", "sci_fi_rgb", "", 0, True, 1.0, 4, 1024, 1024],
597
  ],
598
+ inputs=[image, light_type, light_direction, light_intensity, illumination_env, prompt,
599
  seed, randomize_seed, true_guidance_scale, num_inference_steps, height, width],
600
  outputs=outputs,
601
  fn=infer_relight,
 
611
  ).then(
612
  fn=reset_all,
613
  inputs=None,
614
+ outputs=[light_type, light_direction, light_intensity, illumination_env, prompt, is_reset],
615
  queue=False
616
  ).then(
617
  fn=end_reset,
 
632
  return result_img, result_seed, result_prompt, gr.update(visible=show_button)
633
 
634
  control_inputs = [
635
+ image, light_type, light_direction, light_intensity, illumination_env, prompt,
636
  seed, randomize_seed, true_guidance_scale, num_inference_steps, height, width, prev_output
637
  ]
638
  control_inputs_with_flag = [is_reset] + control_inputs
639
 
640
+ for control in [light_type, light_direction, light_intensity, illumination_env]:
641
  control.input(fn=maybe_infer, inputs=control_inputs_with_flag, outputs=outputs + [create_video_button])
642
 
643
  run_event.then(lambda img, *_: img, inputs=[result], outputs=[prev_output])
644
 
645
+ demo.launch()