Skip to content

Commit

Permalink
allow saving of images via api
Browse files Browse the repository at this point in the history
  • Loading branch information
vladmandic authored Mar 3, 2023
1 parent 0cc0ee1 commit 23d4fb5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
8 changes: 4 additions & 4 deletions modules/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ def text2imgapi(self, txt2imgreq: StableDiffusionTxt2ImgProcessingAPI):

populate = txt2imgreq.copy(update={ # Override __init__ params
"sampler_name": validate_sampler_name(txt2imgreq.sampler_name or txt2imgreq.sampler_index),
"do_not_save_samples": True,
"do_not_save_grid": True
"do_not_save_samples": True if not 'do_not_save_samples' in vars(txt2imgreq) else txt2imgreq.do_not_save_samples,
"do_not_save_grid": True if not 'do_not_save_grid' in vars(txt2imgreq) else txt2imgreq.do_not_save_grid,
}
)
if populate.sampler_name:
Expand Down Expand Up @@ -220,8 +220,8 @@ def img2imgapi(self, img2imgreq: StableDiffusionImg2ImgProcessingAPI):

populate = img2imgreq.copy(update={ # Override __init__ params
"sampler_name": validate_sampler_name(img2imgreq.sampler_name or img2imgreq.sampler_index),
"do_not_save_samples": True,
"do_not_save_grid": True,
"do_not_save_samples": True if not 'do_not_save_samples' in img2imgreq else img2imgreq.do_not_save_samples,
"do_not_save_grid": True if not 'do_not_save_grid' in img2imgreq else img2imgreq.do_not_save_grid,
"mask": mask
}
)
Expand Down
4 changes: 2 additions & 2 deletions modules/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"outpath_samples",
"outpath_grids",
"sampler_index",
"do_not_save_samples",
"do_not_save_grid",
# "do_not_save_samples",
# "do_not_save_grid",
"extra_generation_params",
"overlay_images",
"do_not_reload_embeddings",
Expand Down
3 changes: 3 additions & 0 deletions modules/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,9 @@ def save_image(image, path, basename, seed=None, prompt=None, extension='png', i
"""
namegen = FilenameGenerator(p, seed, prompt, image)

if path is None: # set default path to avoid errors when functions are triggered manually or via api and param is not set
path = opts.outdir_save

if save_to_dirs is None:
save_to_dirs = (grid and opts.grid_save_to_dirs) or (not grid and opts.save_to_dirs and not no_prompt)

Expand Down

0 comments on commit 23d4fb5

Please sign in to comment.