Spaces:
Running
Running
ciover2024
commited on
Commit
•
377f8fb
1
Parent(s):
6b98e01
Update app.py
Browse files
app.py
CHANGED
@@ -110,10 +110,10 @@ def resize_to_match(input_image, output_image):
|
|
110 |
|
111 |
return output_image.resize(input_image.size, Image.BICUBIC) # Use BILINEAR for faster resizing
|
112 |
|
113 |
-
def
|
114 |
result = client.predict(
|
115 |
-
|
116 |
-
|
117 |
["Fooocus V2","Fooocus Enhance","Fooocus Sharp"], # List[str] in 'Selected Styles' Checkboxgroup component
|
118 |
"Quality", # str in 'Performance' Radio component
|
119 |
'704×1408 <span style="color: grey;"> ∣ 1:2</span>', # str in 'Aspect Ratios' Radio component
|
@@ -164,6 +164,165 @@ def generate_image(image_path, mask_path, text_prompt="undress"):
|
|
164 |
fn_index=33
|
165 |
)
|
166 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
# Function to generate the mask using Florence SAM Masking API (Replicate)
|
168 |
def generate_mask(image_path, text_prompt="clothing"):
|
169 |
client_sam = Client("SkalskiP/florence-sam-masking")
|
|
|
110 |
|
111 |
return output_image.resize(input_image.size, Image.BICUBIC) # Use BILINEAR for faster resizing
|
112 |
|
113 |
+
def generate_image_old(image_path, mask_path, text_prompt="undress", negative_prompt=""):
|
114 |
result = client.predict(
|
115 |
+
text_prompt, # str in 'parameter_10' Textbox component
|
116 |
+
negative_prompt, # str in 'Negative Prompt' Textbox component
|
117 |
["Fooocus V2","Fooocus Enhance","Fooocus Sharp"], # List[str] in 'Selected Styles' Checkboxgroup component
|
118 |
"Quality", # str in 'Performance' Radio component
|
119 |
'704×1408 <span style="color: grey;"> ∣ 1:2</span>', # str in 'Aspect Ratios' Radio component
|
|
|
164 |
fn_index=33
|
165 |
)
|
166 |
|
167 |
+
|
168 |
+
def generate_image(image_path, mask_path, text_prompt="undress", negative_prompt=""):
|
169 |
+
client = Client("https://fooocus-ui.emcdn.ru/")
|
170 |
+
result = client.predict(
|
171 |
+
False, # bool in 'Generate Image Grid for Each Batch' Checkbox component
|
172 |
+
text_prompt, # str in 'parameter_12' Textbox component
|
173 |
+
negative_prompt, # str in 'Negative Prompt' Textbox component
|
174 |
+
["Fooocus V2"], # List[str] in 'Selected Styles' Checkboxgroup component from: ["Fooocus V2","Fooocus Enhance","Fooocus Sharp"]
|
175 |
+
"Quality", # str in 'Performance' Radio component
|
176 |
+
"704×1408 <span style="color: grey;"> ∣ 1:2</span>", # str in 'Aspect Ratios' Radio component
|
177 |
+
1, # int | float (numeric value between 1 and 32) in 'Image Number' Slider component
|
178 |
+
"png", # str in 'Output Format' Radio component
|
179 |
+
"-1", # str in 'Seed' Textbox component
|
180 |
+
True, # bool in 'Read wildcards in order' Checkbox component
|
181 |
+
0, # int | float (numeric value between 0.0 and 30.0) in 'Image Sharpness' Slider component
|
182 |
+
1, # int | float (numeric value between 1.0 and 30.0) in 'Guidance Scale' Slider component
|
183 |
+
"juggernautXL_version8Rundiffusion.safetensors", # str (Option from: ['animaPencilXL_v500.safetensors', 'juggernautXL_v8Rundiffusion.safetensors', 'playground-v2.5-1024px-aesthetic.fp16.safetensors', 'ponyDiffusionV6XL.safetensors', 'realisticStockPhoto_v20.safetensors', 'sd_xl_base_1.0_0.9vae.safetensors', 'sd_xl_refiner_1.0_0.9vae.safetensors']) in 'Base Model (SDXL only)' Dropdown component
|
184 |
+
"None", # str (Option from: ['None', 'animaPencilXL_v500.safetensors', 'juggernautXL_v8Rundiffusion.safetensors', 'playground-v2.5-1024px-aesthetic.fp16.safetensors', 'ponyDiffusionV6XL.safetensors', 'realisticStockPhoto_v20.safetensors', 'sd_xl_base_1.0_0.9vae.safetensors', 'sd_xl_refiner_1.0_0.9vae.safetensors']) in 'Refiner (SDXL or SD 1.5)' Dropdown component
|
185 |
+
0.1, # int | float (numeric value between 0.1 and 1.0) in 'Refiner Switch At' Slider component
|
186 |
+
True, # bool in 'Enable' Checkbox component
|
187 |
+
"None", # str (Option from: ['None', 'sd_xl_offset_example-lora_1.0.safetensors', 'SDXL_FILM_PHOTOGRAPHY_STYLE_V1.safetensors', 'sdxl_hyper_sd_4step_lora.safetensors', 'sdxl_lcm_lora.safetensors', 'sdxl_lightning_4step_lora.safetensors']) in 'LoRA 1' Dropdown component
|
188 |
+
-2, # int | float (numeric value between -2 and 2) in 'Weight' Slider component
|
189 |
+
True, # bool in 'Enable' Checkbox component
|
190 |
+
"None", # str (Option from: ['None', 'sd_xl_offset_example-lora_1.0.safetensors', 'SDXL_FILM_PHOTOGRAPHY_STYLE_V1.safetensors', 'sdxl_hyper_sd_4step_lora.safetensors', 'sdxl_lcm_lora.safetensors', 'sdxl_lightning_4step_lora.safetensors']) in 'LoRA 2' Dropdown component
|
191 |
+
-2, # int | float (numeric value between -2 and 2) in 'Weight' Slider component
|
192 |
+
True, # bool in 'Enable' Checkbox component
|
193 |
+
"None", # str (Option from: ['None', 'sd_xl_offset_example-lora_1.0.safetensors', 'SDXL_FILM_PHOTOGRAPHY_STYLE_V1.safetensors', 'sdxl_hyper_sd_4step_lora.safetensors', 'sdxl_lcm_lora.safetensors', 'sdxl_lightning_4step_lora.safetensors']) in 'LoRA 3' Dropdown component
|
194 |
+
-2, # int | float (numeric value between -2 and 2) in 'Weight' Slider component
|
195 |
+
True, # bool in 'Enable' Checkbox component
|
196 |
+
"None", # str (Option from: ['None', 'sd_xl_offset_example-lora_1.0.safetensors', 'SDXL_FILM_PHOTOGRAPHY_STYLE_V1.safetensors', 'sdxl_hyper_sd_4step_lora.safetensors', 'sdxl_lcm_lora.safetensors', 'sdxl_lightning_4step_lora.safetensors']) in 'LoRA 4' Dropdown component
|
197 |
+
-2, # int | float (numeric value between -2 and 2) in 'Weight' Slider component
|
198 |
+
True, # bool in 'Enable' Checkbox component
|
199 |
+
"None", # str (Option from: ['None', 'sd_xl_offset_example-lora_1.0.safetensors', 'SDXL_FILM_PHOTOGRAPHY_STYLE_V1.safetensors', 'sdxl_hyper_sd_4step_lora.safetensors', 'sdxl_lcm_lora.safetensors', 'sdxl_lightning_4step_lora.safetensors']) in 'LoRA 5' Dropdown component
|
200 |
+
-2, # int | float (numeric value between -2 and 2) in 'Weight' Slider component
|
201 |
+
True, # bool in 'Input Image' Checkbox component
|
202 |
+
"-1", # str in 'parameter_212' Textbox component
|
203 |
+
"Disabled", # str in 'Upscale or Variation:' Radio component
|
204 |
+
"https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png", # str (filepath or URL to image) in 'Image' Image component
|
205 |
+
["Left"], # List[str] in 'Outpaint Direction' Checkboxgroup component
|
206 |
+
"https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png", # str (filepath or URL to image) in 'Image' Image component
|
207 |
+
"Howdy!", # str in 'Inpaint Additional Prompt' Textbox component
|
208 |
+
"https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png", # str (filepath or URL to image) in 'Mask Upload' Image component
|
209 |
+
True, # bool in 'Disable Preview' Checkbox component
|
210 |
+
True, # bool in 'Disable Intermediate Results' Checkbox component
|
211 |
+
True, # bool in 'Disable seed increment' Checkbox component
|
212 |
+
True, # bool in 'Black Out NSFW' Checkbox component
|
213 |
+
0.1, # int | float (numeric value between 0.1 and 3.0) in 'Positive ADM Guidance Scaler' Slider component
|
214 |
+
0.1, # int | float (numeric value between 0.1 and 3.0) in 'Negative ADM Guidance Scaler' Slider component
|
215 |
+
0, # int | float (numeric value between 0.0 and 1.0) in 'ADM Guidance End At Step' Slider component
|
216 |
+
1, # int | float (numeric value between 1.0 and 30.0) in 'CFG Mimicking from TSNR' Slider component
|
217 |
+
1, # int | float (numeric value between 1 and 12) in 'CLIP Skip' Slider component
|
218 |
+
"euler", # str (Option from: ['euler', 'euler_ancestral', 'heun', 'heunpp2', 'dpm_2', 'dpm_2_ancestral', 'lms', 'dpm_fast', 'dpm_adaptive', 'dpmpp_2s_ancestral', 'dpmpp_sde', 'dpmpp_sde_gpu', 'dpmpp_2m', 'dpmpp_2m_sde', 'dpmpp_2m_sde_gpu', 'dpmpp_3m_sde', 'dpmpp_3m_sde_gpu', 'ddpm', 'lcm', 'tcd', 'restart', 'ddim', 'uni_pc', 'uni_pc_bh2']) in 'Sampler' Dropdown component
|
219 |
+
"normal", # str (Option from: ['normal', 'karras', 'exponential', 'sgm_uniform', 'simple', 'ddim_uniform', 'lcm', 'turbo', 'align_your_steps', 'tcd', 'edm_playground_v2.5']) in 'Scheduler' Dropdown component
|
220 |
+
"Default (model)", # str (Option from: ['Default (model)', 'ponyDiffusionV6XL_vae.safetensors']) in 'VAE' Dropdown component
|
221 |
+
-1, # int | float (numeric value between -1 and 200) in 'Forced Overwrite of Sampling Step' Slider component
|
222 |
+
-1, # int | float (numeric value between -1 and 200) in 'Forced Overwrite of Refiner Switch Step' Slider component
|
223 |
+
-1, # int | float (numeric value between -1 and 2048) in 'Forced Overwrite of Generating Width' Slider component
|
224 |
+
-1, # int | float (numeric value between -1 and 2048) in 'Forced Overwrite of Generating Height' Slider component
|
225 |
+
-1, # int | float (numeric value between -1 and 1.0) in 'Forced Overwrite of Denoising Strength of "Vary"' Slider component
|
226 |
+
-1, # int | float (numeric value between -1 and 1.0) in 'Forced Overwrite of Denoising Strength of "Upscale"' Slider component
|
227 |
+
True, # bool in 'Mixing Image Prompt and Vary/Upscale' Checkbox component
|
228 |
+
True, # bool in 'Mixing Image Prompt and Inpaint' Checkbox component
|
229 |
+
True, # bool in 'Debug Preprocessors' Checkbox component
|
230 |
+
True, # bool in 'Skip Preprocessors' Checkbox component
|
231 |
+
1, # int | float (numeric value between 1 and 255) in 'Canny Low Threshold' Slider component
|
232 |
+
1, # int | float (numeric value between 1 and 255) in 'Canny High Threshold' Slider component
|
233 |
+
"joint", # str (Option from: ['joint', 'separate', 'vae']) in 'Refiner swap method' Dropdown component
|
234 |
+
0, # int | float (numeric value between 0.0 and 1.0) in 'Softness of ControlNet' Slider component
|
235 |
+
True, # bool in 'Enabled' Checkbox component
|
236 |
+
0, # int | float (numeric value between 0 and 2) in 'B1' Slider component
|
237 |
+
0, # int | float (numeric value between 0 and 2) in 'B2' Slider component
|
238 |
+
0, # int | float (numeric value between 0 and 4) in 'S1' Slider component
|
239 |
+
0, # int | float (numeric value between 0 and 4) in 'S2' Slider component
|
240 |
+
True, # bool in 'Debug Inpaint Preprocessing' Checkbox component
|
241 |
+
True, # bool in 'Disable initial latent in inpaint' Checkbox component
|
242 |
+
"None", # str (Option from: ['None', 'v1', 'v2.5', 'v2.6']) in 'Inpaint Engine' Dropdown component
|
243 |
+
0, # int | float (numeric value between 0.0 and 1.0) in 'Inpaint Denoising Strength' Slider component
|
244 |
+
0, # int | float (numeric value between 0.0 and 1.0) in 'Inpaint Respective Field' Slider component
|
245 |
+
True, # bool in 'Enable Advanced Masking Features' Checkbox component
|
246 |
+
True, # bool in 'Invert Mask When Generating' Checkbox component
|
247 |
+
-64, # int | float (numeric value between -64 and 64) in 'Mask Erode or Dilate' Slider component
|
248 |
+
True, # bool in 'Save only final enhanced image' Checkbox component
|
249 |
+
True, # bool in 'Save Metadata to Images' Checkbox component
|
250 |
+
"fooocus", # str in 'Metadata Scheme' Radio component
|
251 |
+
"https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png", # str (filepath or URL to image) in 'Image' Image component
|
252 |
+
0, # int | float (numeric value between 0.0 and 1.0) in 'Stop At' Slider component
|
253 |
+
0, # int | float (numeric value between 0.0 and 2.0) in 'Weight' Slider component
|
254 |
+
"ImagePrompt", # str in 'Type' Radio component
|
255 |
+
"https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png", # str (filepath or URL to image) in 'Image' Image component
|
256 |
+
0, # int | float (numeric value between 0.0 and 1.0) in 'Stop At' Slider component
|
257 |
+
0, # int | float (numeric value between 0.0 and 2.0) in 'Weight' Slider component
|
258 |
+
"ImagePrompt", # str in 'Type' Radio component
|
259 |
+
"https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png", # str (filepath or URL to image) in 'Image' Image component
|
260 |
+
0, # int | float (numeric value between 0.0 and 1.0) in 'Stop At' Slider component
|
261 |
+
0, # int | float (numeric value between 0.0 and 2.0) in 'Weight' Slider component
|
262 |
+
"ImagePrompt", # str in 'Type' Radio component
|
263 |
+
"https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png", # str (filepath or URL to image) in 'Image' Image component
|
264 |
+
0, # int | float (numeric value between 0.0 and 1.0) in 'Stop At' Slider component
|
265 |
+
0, # int | float (numeric value between 0.0 and 2.0) in 'Weight' Slider component
|
266 |
+
"ImagePrompt", # str in 'Type' Radio component
|
267 |
+
True, # bool in 'Debug GroundingDINO' Checkbox component
|
268 |
+
-64, # int | float (numeric value between -64 and 64) in 'GroundingDINO Box Erode or Dilate' Slider component
|
269 |
+
True, # bool in 'Debug Enhance Masks' Checkbox component
|
270 |
+
"https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png", # str (filepath or URL to image) in 'Use with Enhance, skips image generation' Image component
|
271 |
+
True, # bool in 'Enhance' Checkbox component
|
272 |
+
"Disabled", # str in 'Upscale or Variation:' Radio component
|
273 |
+
"Before First Enhancement", # str in 'Order of Processing' Radio component
|
274 |
+
"Original Prompts", # str in 'Prompt' Radio component
|
275 |
+
True, # bool in 'Enable' Checkbox component
|
276 |
+
"Howdy!", # str in 'Detection prompt' Textbox component
|
277 |
+
"Howdy!", # str in 'Enhancement positive prompt' Textbox component
|
278 |
+
"Howdy!", # str in 'Enhancement negative prompt' Textbox component
|
279 |
+
"u2net", # str (Option from: ['u2net', 'u2netp', 'u2net_human_seg', 'u2net_cloth_seg', 'silueta', 'isnet-general-use', 'isnet-anime', 'sam']) in 'Mask generation model' Dropdown component
|
280 |
+
"full", # str (Option from: ['full', 'upper', 'lower']) in 'Cloth category' Dropdown component
|
281 |
+
"vit_b", # str (Option from: ['vit_b', 'vit_l', 'vit_h']) in 'SAM model' Dropdown component
|
282 |
+
0, # int | float (numeric value between 0.0 and 1.0) in 'Text Threshold' Slider component
|
283 |
+
0, # int | float (numeric value between 0.0 and 1.0) in 'Box Threshold' Slider component
|
284 |
+
0, # int | float (numeric value between 0 and 10) in 'Maximum number of detections' Slider component
|
285 |
+
True, # bool in 'Disable initial latent in inpaint' Checkbox component
|
286 |
+
"None", # str (Option from: ['None', 'v1', 'v2.5', 'v2.6']) in 'Inpaint Engine' Dropdown component
|
287 |
+
0, # int | float (numeric value between 0.0 and 1.0) in 'Inpaint Denoising Strength' Slider component
|
288 |
+
0, # int | float (numeric value between 0.0 and 1.0) in 'Inpaint Respective Field' Slider component
|
289 |
+
-64, # int | float (numeric value between -64 and 64) in 'Mask Erode or Dilate' Slider component
|
290 |
+
True, # bool in 'Invert Mask' Checkbox component
|
291 |
+
True, # bool in 'Enable' Checkbox component
|
292 |
+
"Howdy!", # str in 'Detection prompt' Textbox component
|
293 |
+
"Howdy!", # str in 'Enhancement positive prompt' Textbox component
|
294 |
+
"Howdy!", # str in 'Enhancement negative prompt' Textbox component
|
295 |
+
"u2net", # str (Option from: ['u2net', 'u2netp', 'u2net_human_seg', 'u2net_cloth_seg', 'silueta', 'isnet-general-use', 'isnet-anime', 'sam']) in 'Mask generation model' Dropdown component
|
296 |
+
"full", # str (Option from: ['full', 'upper', 'lower']) in 'Cloth category' Dropdown component
|
297 |
+
"vit_b", # str (Option from: ['vit_b', 'vit_l', 'vit_h']) in 'SAM model' Dropdown component
|
298 |
+
0, # int | float (numeric value between 0.0 and 1.0) in 'Text Threshold' Slider component
|
299 |
+
0, # int | float (numeric value between 0.0 and 1.0) in 'Box Threshold' Slider component
|
300 |
+
0, # int | float (numeric value between 0 and 10) in 'Maximum number of detections' Slider component
|
301 |
+
True, # bool in 'Disable initial latent in inpaint' Checkbox component
|
302 |
+
"None", # str (Option from: ['None', 'v1', 'v2.5', 'v2.6']) in 'Inpaint Engine' Dropdown component
|
303 |
+
0, # int | float (numeric value between 0.0 and 1.0) in 'Inpaint Denoising Strength' Slider component
|
304 |
+
0, # int | float (numeric value between 0.0 and 1.0) in 'Inpaint Respective Field' Slider component
|
305 |
+
-64, # int | float (numeric value between -64 and 64) in 'Mask Erode or Dilate' Slider component
|
306 |
+
True, # bool in 'Invert Mask' Checkbox component True, # bool in 'Enable' Checkbox component
|
307 |
+
"Howdy!", # str in 'Detection prompt' Textbox component
|
308 |
+
"Howdy!", # str in 'Enhancement positive prompt' Textbox component
|
309 |
+
"Howdy!", # str in 'Enhancement negative prompt' Textbox component
|
310 |
+
"u2net", # str (Option from: ['u2net', 'u2netp', 'u2net_human_seg', 'u2net_cloth_seg', 'silueta', 'isnet-general-use', 'isnet-anime', 'sam']) in 'Mask generation model' Dropdown component
|
311 |
+
"full", # str (Option from: ['full', 'upper', 'lower']) in 'Cloth category' Dropdown component
|
312 |
+
"vit_b", # str (Option from: ['vit_b', 'vit_l', 'vit_h']) in 'SAM model' Dropdown component
|
313 |
+
0, # int | float (numeric value between 0.0 and 1.0) in 'Text Threshold' Slider component
|
314 |
+
0, # int | float (numeric value between 0.0 and 1.0) in 'Box Threshold' Slider component
|
315 |
+
0, # int | float (numeric value between 0 and 10) in 'Maximum number of detections' Slider component
|
316 |
+
True, # bool in 'Disable initial latent in inpaint' Checkbox component
|
317 |
+
"None", # str (Option from: ['None', 'v1', 'v2.5', 'v2.6']) in 'Inpaint Engine' Dropdown component
|
318 |
+
0, # int | float (numeric value between 0.0 and 1.0) in 'Inpaint Denoising Strength' Slider component
|
319 |
+
0, # int | float (numeric value between 0.0 and 1.0) in 'Inpaint Respective Field' Slider component
|
320 |
+
-64, # int | float (numeric value between -64 and 64) in 'Mask Erode or Dilate' Slider component
|
321 |
+
True, # bool in 'Invert Mask' Checkbox component
|
322 |
+
fn_index=67
|
323 |
+
)
|
324 |
+
print(result)
|
325 |
+
|
326 |
# Function to generate the mask using Florence SAM Masking API (Replicate)
|
327 |
def generate_mask(image_path, text_prompt="clothing"):
|
328 |
client_sam = Client("SkalskiP/florence-sam-masking")
|