diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2022-11-06 08:28:00 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-06 08:28:00 +0000 |
commit | 5302e2cdd4c8f039a68e900d739285d15d99d200 (patch) | |
tree | 4fdad803a4536cec2bd3e622c5f4cfb980f04550 /modules/api/api.py | |
parent | 6e4de5b4422dfc0d45063b2c8c78b19f00321615 (diff) | |
parent | 07d1bd426722b4c53b38ff682c5aab53177d8530 (diff) | |
download | stable-diffusion-webui-gfx803-5302e2cdd4c8f039a68e900d739285d15d99d200.tar.gz stable-diffusion-webui-gfx803-5302e2cdd4c8f039a68e900d739285d15d99d200.tar.bz2 stable-diffusion-webui-gfx803-5302e2cdd4c8f039a68e900d739285d15d99d200.zip |
Merge pull request #3810 from royshil/roy.add_simple_interrogate_api
Add a barebones CLIP interrogate API endpoint
Diffstat (limited to 'modules/api/api.py')
-rw-r--r-- | modules/api/api.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/modules/api/api.py b/modules/api/api.py index 112000b8..688469ad 100644 --- a/modules/api/api.py +++ b/modules/api/api.py @@ -63,6 +63,7 @@ class Api: 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) self.app.add_api_route("/sdapi/v1/progress", self.progressapi, methods=["GET"], response_model=ProgressResponse) + self.app.add_api_route("/sdapi/v1/interrogate", self.interrogateapi, methods=["POST"]) self.app.add_api_route("/sdapi/v1/interrupt", self.interruptapi, methods=["POST"]) self.app.add_api_route("/sdapi/v1/options", self.get_config, methods=["GET"], response_model=OptionsModel) self.app.add_api_route("/sdapi/v1/options", self.set_config, methods=["POST"]) @@ -214,6 +215,19 @@ class Api: return ProgressResponse(progress=progress, eta_relative=eta_relative, state=shared.state.dict(), current_image=current_image) + def interrogateapi(self, interrogatereq: InterrogateRequest): + image_b64 = interrogatereq.image + if image_b64 is None: + raise HTTPException(status_code=404, detail="Image not found") + + img = self.__base64_to_image(image_b64) + + # Override object param + with self.queue_lock: + processed = shared.interrogator.interrogate(img) + + return InterrogateResponse(caption=processed) + def interruptapi(self): shared.state.interrupt() |