diff options
author | timntorres <timothynarcisotorres@gmail.com> | 2022-10-29 21:55:30 +0000 |
---|---|---|
committer | timntorres <timothynarcisotorres@gmail.com> | 2022-10-29 21:55:30 +0000 |
commit | e709afb0f774dde34a0a0f8d972a7bd2fd0f023a (patch) | |
tree | c222a84c2e92d245e2a8c736f14740d94cfae380 /modules/api/api.py | |
parent | 2c4d20388425a5e40b93eef3722e42e8d375fbb4 (diff) | |
parent | e7254746bbfbff45099db44a8d4d25dd6181877d (diff) | |
download | stable-diffusion-webui-gfx803-e709afb0f774dde34a0a0f8d972a7bd2fd0f023a.tar.gz stable-diffusion-webui-gfx803-e709afb0f774dde34a0a0f8d972a7bd2fd0f023a.tar.bz2 stable-diffusion-webui-gfx803-e709afb0f774dde34a0a0f8d972a7bd2fd0f023a.zip |
Merge commit 'e7254746bbfbff45099db44a8d4d25dd6181877d' into 3825-save-hypernet-strength-to-info
Diffstat (limited to 'modules/api/api.py')
-rw-r--r-- | modules/api/api.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/modules/api/api.py b/modules/api/api.py index 49c213ea..d0f488ca 100644 --- a/modules/api/api.py +++ b/modules/api/api.py @@ -5,7 +5,7 @@ import modules.shared as shared from modules.api.models import * from modules.processing import StableDiffusionProcessingTxt2Img, StableDiffusionProcessingImg2Img, process_images from modules.sd_samplers import all_samplers -from modules.extras import run_extras +from modules.extras import run_extras, run_pnginfo def upscaler_to_index(name: str): try: @@ -32,6 +32,7 @@ class Api: self.app.add_api_route("/sdapi/v1/img2img", self.img2imgapi, methods=["POST"], response_model=ImageToImageResponse) self.app.add_api_route("/sdapi/v1/extra-single-image", self.extras_single_image_api, methods=["POST"], response_model=ExtrasSingleImageResponse) self.app.add_api_route("/sdapi/v1/extra-batch-images", self.extras_batch_images_api, methods=["POST"], response_model=ExtrasBatchImagesResponse) + self.app.add_api_route("/sdapi/v1/png-info", self.pnginfoapi, methods=["POST"], response_model=PNGInfoResponse) def text2imgapi(self, txt2imgreq: StableDiffusionTxt2ImgProcessingAPI): sampler_index = sampler_to_index(txt2imgreq.sampler_index) @@ -125,8 +126,13 @@ class Api: return ExtrasBatchImagesResponse(images=list(map(encode_pil_to_base64, result[0])), html_info=result[1]) - def pnginfoapi(self): - raise NotImplementedError + def pnginfoapi(self, req: PNGInfoRequest): + if(not req.image.strip()): + return PNGInfoResponse(info="") + + result = run_pnginfo(decode_base64_to_image(req.image.strip())) + + return PNGInfoResponse(info=result[1]) def launch(self, server_name, port): self.app.include_router(self.router) |