Tonioesparza commited on
Commit
dbe0fc1
·
verified ·
1 Parent(s): b894dac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -14
app.py CHANGED
@@ -59,7 +59,7 @@ refiner.to("cuda")
59
  MAX_SEED = np.iinfo(np.int32).max
60
  MAX_IMAGE_SIZE = 1024
61
 
62
- def ourhood_inference(prompt=str,num_inference_steps=int,scaffold=int,fracc=float):
63
 
64
  ###pro_encode = pipe_cn.encode_text(prompt)
65
 
@@ -70,10 +70,10 @@ def ourhood_inference(prompt=str,num_inference_steps=int,scaffold=int,fracc=floa
70
  'canny_image':"https://huggingface.co/Tonioesparza/ourhood_training_dreambooth_lora_2_0/resolve/main/mask_depth_solo_square.png"},
71
  2:{'mask1':"https://huggingface.co/Tonioesparza/ourhood_training_dreambooth_lora_2_0/resolve/main/mask_in_C.png",
72
  'depth_image':"https://huggingface.co/Tonioesparza/ourhood_training_dreambooth_lora_2_0/resolve/main/depth_C.png",
73
- 'canny_image':"https://huggingface.co/Tonioesparza/ourhood_training_dreambooth_lora_2_0/resolve/main/canny_C.png"},
74
  3:{'mask1':"https://huggingface.co/Tonioesparza/ourhood_training_dreambooth_lora_2_0/resolve/main/mask_in_B.png",
75
  'depth_image':"https://huggingface.co/Tonioesparza/ourhood_training_dreambooth_lora_2_0/resolve/main/depth_B.png",
76
- 'canny_image':"https://huggingface.co/Tonioesparza/ourhood_training_dreambooth_lora_2_0/resolve/main/canny_B.png"}}
77
  ### mask init
78
 
79
  output_height = 1024
@@ -100,26 +100,34 @@ def ourhood_inference(prompt=str,num_inference_steps=int,scaffold=int,fracc=floa
100
 
101
  images_CN = [depth_image, canny_image]
102
 
 
 
103
  ### inference
104
 
 
 
105
  results = pipe_CN(
106
  prompt=prompt,
107
  ip_adapter_image=ip_images,
108
  negative_prompt="deformed, ugly, wrong proportion, low res, worst quality, low quality,text,watermark",
 
109
  num_inference_steps=n_steps,
110
  num_images_per_prompt=1,
111
- denoising_end=fracc,
112
  image=images_CN,
113
  output_type="latent",
114
- controlnet_conditioning_scale=[0.3, 0.45],
 
 
115
  cross_attention_kwargs={"ip_adapter_masks": masks}
116
  ).images[0]
117
 
118
 
119
  image = refiner(
120
  prompt=prompt,
 
121
  num_inference_steps=num_inference_steps,
122
- denoising_start=fracc,
123
  image=results,
124
  ).images[0]
125
 
@@ -184,13 +192,6 @@ with gr.Blocks(css=css) as demo:
184
 
185
  with gr.Row():
186
 
187
- fracc = gr.Slider(
188
- label="refinement_scale",
189
- minimum=0.8,
190
- maximum=0.95,
191
- step=0.01,
192
- value=0.8, #Replace with defaults that work for your model
193
- )
194
 
195
  num_inference_steps = gr.Slider(
196
  label="Number of inference steps",
@@ -207,7 +208,7 @@ with gr.Blocks(css=css) as demo:
207
  gr.on(
208
  triggers=[run_button.click, prompt.submit],
209
  fn = ourhood_inference,
210
- inputs = [prompt, num_inference_steps, perspective, fracc],
211
  outputs = [result]
212
  )
213
 
 
59
  MAX_SEED = np.iinfo(np.int32).max
60
  MAX_IMAGE_SIZE = 1024
61
 
62
+ def ourhood_inference(prompt=str,num_inference_steps=int,scaffold=int,seed):
63
 
64
  ###pro_encode = pipe_cn.encode_text(prompt)
65
 
 
70
  'canny_image':"https://huggingface.co/Tonioesparza/ourhood_training_dreambooth_lora_2_0/resolve/main/mask_depth_solo_square.png"},
71
  2:{'mask1':"https://huggingface.co/Tonioesparza/ourhood_training_dreambooth_lora_2_0/resolve/main/mask_in_C.png",
72
  'depth_image':"https://huggingface.co/Tonioesparza/ourhood_training_dreambooth_lora_2_0/resolve/main/depth_C.png",
73
+ 'canny_image':"https://huggingface.co/Tonioesparza/ourhood_training_dreambooth_lora_2_0/resolve/main/canny_C_solo.png"},
74
  3:{'mask1':"https://huggingface.co/Tonioesparza/ourhood_training_dreambooth_lora_2_0/resolve/main/mask_in_B.png",
75
  'depth_image':"https://huggingface.co/Tonioesparza/ourhood_training_dreambooth_lora_2_0/resolve/main/depth_B.png",
76
+ 'canny_image':"https://huggingface.co/Tonioesparza/ourhood_training_dreambooth_lora_2_0/resolve/main/canny_B_solo.png"}}
77
  ### mask init
78
 
79
  output_height = 1024
 
100
 
101
  images_CN = [depth_image, canny_image]
102
 
103
+
104
+
105
  ### inference
106
 
107
+ generator = torch.Generator(device="cuda").manual_seed(seed)
108
+
109
  results = pipe_CN(
110
  prompt=prompt,
111
  ip_adapter_image=ip_images,
112
  negative_prompt="deformed, ugly, wrong proportion, low res, worst quality, low quality,text,watermark",
113
+ generator=generator,
114
  num_inference_steps=n_steps,
115
  num_images_per_prompt=1,
116
+ denoising_end=0.95,
117
  image=images_CN,
118
  output_type="latent",
119
+ control_guidance_start=[0.0, 0.35],
120
+ control_guidance_end=[0.35, 1.0],
121
+ controlnet_conditioning_scale=[0.5, 1.0],
122
  cross_attention_kwargs={"ip_adapter_masks": masks}
123
  ).images[0]
124
 
125
 
126
  image = refiner(
127
  prompt=prompt,
128
+ generator=generator,
129
  num_inference_steps=num_inference_steps,
130
+ denoising_start=0.95,
131
  image=results,
132
  ).images[0]
133
 
 
192
 
193
  with gr.Row():
194
 
 
 
 
 
 
 
 
195
 
196
  num_inference_steps = gr.Slider(
197
  label="Number of inference steps",
 
208
  gr.on(
209
  triggers=[run_button.click, prompt.submit],
210
  fn = ourhood_inference,
211
+ inputs = [prompt, num_inference_steps, perspective, seed],
212
  outputs = [result]
213
  )
214