mirror of
				https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
				synced 2025-10-25 23:24:45 +00:00 
			
		
		
		
	Merge pull request #8814 from catboxanon/inpaint-mask
Add ability to display and/or save inpainting mask and masked composite
This commit is contained in:
		
						commit
						90410e212f
					
				| @ -689,6 +689,22 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed: | |||||||
|                     image.info["parameters"] = text |                     image.info["parameters"] = text | ||||||
|                 output_images.append(image) |                 output_images.append(image) | ||||||
| 
 | 
 | ||||||
|  |                 if hasattr(p, 'mask_for_overlay') and p.mask_for_overlay: | ||||||
|  |                     image_mask = p.mask_for_overlay.convert('RGB') | ||||||
|  |                     image_mask_composite = Image.composite(image.convert('RGBA').convert('RGBa'), Image.new('RGBa', image.size), p.mask_for_overlay.convert('L')).convert('RGBA') | ||||||
|  | 
 | ||||||
|  |                     if opts.save_mask: | ||||||
|  |                         images.save_image(image_mask, p.outpath_samples, "", seeds[i], prompts[i], opts.samples_format, info=infotext(n, i), p=p, suffix="-mask") | ||||||
|  | 
 | ||||||
|  |                     if opts.save_mask_composite: | ||||||
|  |                         images.save_image(image_mask_composite, p.outpath_samples, "", seeds[i], prompts[i], opts.samples_format, info=infotext(n, i), p=p, suffix="-mask-composite") | ||||||
|  | 
 | ||||||
|  |                     if opts.return_mask: | ||||||
|  |                         output_images.append(image_mask) | ||||||
|  |                      | ||||||
|  |                     if opts.return_mask_composite: | ||||||
|  |                         output_images.append(image_mask_composite) | ||||||
|  | 
 | ||||||
|             del x_samples_ddim |             del x_samples_ddim | ||||||
| 
 | 
 | ||||||
|             devices.torch_gc() |             devices.torch_gc() | ||||||
|  | |||||||
| @ -333,6 +333,8 @@ options_templates.update(options_section(('saving-images', "Saving images/grids" | |||||||
|     "save_images_before_face_restoration": OptionInfo(False, "Save a copy of image before doing face restoration."), |     "save_images_before_face_restoration": OptionInfo(False, "Save a copy of image before doing face restoration."), | ||||||
|     "save_images_before_highres_fix": OptionInfo(False, "Save a copy of image before applying highres fix."), |     "save_images_before_highres_fix": OptionInfo(False, "Save a copy of image before applying highres fix."), | ||||||
|     "save_images_before_color_correction": OptionInfo(False, "Save a copy of image before applying color correction to img2img results"), |     "save_images_before_color_correction": OptionInfo(False, "Save a copy of image before applying color correction to img2img results"), | ||||||
|  |     "save_mask": OptionInfo(False, "For inpainting, save a copy of the greyscale mask"), | ||||||
|  |     "save_mask_composite": OptionInfo(False, "For inpainting, save a masked composite"), | ||||||
|     "jpeg_quality": OptionInfo(80, "Quality for saved jpeg images", gr.Slider, {"minimum": 1, "maximum": 100, "step": 1}), |     "jpeg_quality": OptionInfo(80, "Quality for saved jpeg images", gr.Slider, {"minimum": 1, "maximum": 100, "step": 1}), | ||||||
|     "webp_lossless": OptionInfo(False, "Use lossless compression for webp images"), |     "webp_lossless": OptionInfo(False, "Use lossless compression for webp images"), | ||||||
|     "export_for_4chan": OptionInfo(True, "If the saved image file size is above the limit, or its either width or height are above the limit, save a downscaled copy as JPG"), |     "export_for_4chan": OptionInfo(True, "If the saved image file size is above the limit, or its either width or height are above the limit, save a downscaled copy as JPG"), | ||||||
| @ -455,6 +457,8 @@ options_templates.update(options_section(('extra_networks', "Extra Networks"), { | |||||||
| 
 | 
 | ||||||
| options_templates.update(options_section(('ui', "User interface"), { | options_templates.update(options_section(('ui', "User interface"), { | ||||||
|     "return_grid": OptionInfo(True, "Show grid in results for web"), |     "return_grid": OptionInfo(True, "Show grid in results for web"), | ||||||
|  |     "return_mask": OptionInfo(False, "For inpainting, include the greyscale mask in results for web"), | ||||||
|  |     "return_mask_composite": OptionInfo(False, "For inpainting, include masked composite in results for web"), | ||||||
|     "do_not_show_images": OptionInfo(False, "Do not show any images in results for web"), |     "do_not_show_images": OptionInfo(False, "Do not show any images in results for web"), | ||||||
|     "add_model_hash_to_info": OptionInfo(True, "Add model hash to generation information"), |     "add_model_hash_to_info": OptionInfo(True, "Add model hash to generation information"), | ||||||
|     "add_model_name_to_info": OptionInfo(True, "Add model name to generation information"), |     "add_model_name_to_info": OptionInfo(True, "Add model name to generation information"), | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 AUTOMATIC1111
						AUTOMATIC1111