jamesliu1217 commited on
Commit
e2fd487
·
verified ·
1 Parent(s): 1d6468b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -28,14 +28,13 @@ def clear_cache(transformer):
28
 
29
  # Define the Gradio interface
30
  @spaces.GPU()
31
- def single_condition_generate_image(prompt, subject_img, spatial_img, height, width, seed, control_type):
32
  # Set the control type
33
  if control_type == "Ghibli":
34
  lora_path = os.path.join(lora_base_path, "Ghibli.safetensors")
35
  set_single_lora(pipe.transformer, lora_path, lora_weights=[1], cond_size=512)
36
 
37
  # Process the image
38
- subject_imgs = [subject_img] if subject_img else []
39
  spatial_imgs = [spatial_img] if spatial_img else []
40
  image = pipe(
41
  prompt,
@@ -45,7 +44,7 @@ def single_condition_generate_image(prompt, subject_img, spatial_img, height, wi
45
  num_inference_steps=25,
46
  max_sequence_length=512,
47
  generator=torch.Generator("cpu").manual_seed(seed),
48
- subject_images=subject_imgs,
49
  spatial_images=spatial_imgs,
50
  cond_size=512,
51
  ).images[0]
@@ -84,7 +83,7 @@ with gr.Blocks() as demo:
84
  # Add examples for Single Condition Generation
85
  gr.Examples(
86
  examples=single_examples,
87
- inputs=[prompt, None, spatial_img, height, width, seed, control_type],
88
  outputs=single_output_image,
89
  fn=single_condition_generate_image,
90
  cache_examples=False, # 缓存示例结果以加快加载速度
@@ -94,7 +93,7 @@ with gr.Blocks() as demo:
94
  # Link the buttons to the functions
95
  single_generate_btn.click(
96
  single_condition_generate_image,
97
- inputs=[prompt, None, spatial_img, height, width, seed, control_type],
98
  outputs=single_output_image
99
  )
100
 
 
28
 
29
  # Define the Gradio interface
30
  @spaces.GPU()
31
+ def single_condition_generate_image(prompt, spatial_img, height, width, seed, control_type):
32
  # Set the control type
33
  if control_type == "Ghibli":
34
  lora_path = os.path.join(lora_base_path, "Ghibli.safetensors")
35
  set_single_lora(pipe.transformer, lora_path, lora_weights=[1], cond_size=512)
36
 
37
  # Process the image
 
38
  spatial_imgs = [spatial_img] if spatial_img else []
39
  image = pipe(
40
  prompt,
 
44
  num_inference_steps=25,
45
  max_sequence_length=512,
46
  generator=torch.Generator("cpu").manual_seed(seed),
47
+ subject_images=[],
48
  spatial_images=spatial_imgs,
49
  cond_size=512,
50
  ).images[0]
 
83
  # Add examples for Single Condition Generation
84
  gr.Examples(
85
  examples=single_examples,
86
+ inputs=[prompt, spatial_img, height, width, seed, control_type],
87
  outputs=single_output_image,
88
  fn=single_condition_generate_image,
89
  cache_examples=False, # 缓存示例结果以加快加载速度
 
93
  # Link the buttons to the functions
94
  single_generate_btn.click(
95
  single_condition_generate_image,
96
+ inputs=[prompt, spatial_img, height, width, seed, control_type],
97
  outputs=single_output_image
98
  )
99