Skip to content

Commit

Permalink
add interrogateapi
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyongliang committed May 22, 2023
1 parent 17ea042 commit c74d4fe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion modules/api/api.py
Expand Up @@ -234,7 +234,7 @@ def __init__(self, app: FastAPI, queue_lock: Lock):
self.add_api_route("/sdapi/v1/unload-checkpoint", self.unloadapi, methods=["POST"])
self.add_api_route("/sdapi/v1/reload-checkpoint", self.reloadapi, methods=["POST"])
self.add_api_route("/sdapi/v1/scripts", self.get_scripts_list, methods=["GET"], response_model=ScriptsList)
self.add_api_route("/invocations", self.invocations, methods=["POST"], response_model=Union[TextToImageResponse, ImageToImageResponse, ExtrasSingleImageResponse, ExtrasBatchImagesResponse, InvocationsErrorResponse])
self.add_api_route("/invocations", self.invocations, methods=["POST"], response_model=Union[TextToImageResponse, ImageToImageResponse, ExtrasSingleImageResponse, ExtrasBatchImagesResponse, InvocationsErrorResponse, InterrogateResponse])
self.add_api_route("/ping", self.ping, methods=["GET"], response_model=PingResponse)

self.default_script_arg_txt2img = []
Expand Down Expand Up @@ -806,6 +806,9 @@ def invocations(self, req: InvocationsRequest):
response = self.extras_batch_images_api(req.extras_batch_payload)
response.images = self.post_invocations(response.images, quality)
return response
elif req.task == 'interrogate':
response = self.interrogateapi(req.interrogate_payload)
return response
else:
return InvocationsErrorResponse(error = f'Invalid task - {req.task}')

Expand Down
1 change: 1 addition & 0 deletions modules/api/models.py
Expand Up @@ -302,6 +302,7 @@ class InvocationsRequest(BaseModel):
img2img_payload: Optional[StableDiffusionImg2ImgProcessingAPI]
extras_single_payload: Optional[ExtrasSingleImageRequest]
extras_batch_payload: Optional[ExtrasBatchImagesRequest]
interrogate_payload: Optional[InterrogateRequest]

class InvocationsErrorResponse(BaseModel):
error: str = Field(title="Invocation error", description="Error response from invocation.")
Expand Down

0 comments on commit c74d4fe

Please sign in to comment.