Skip to content

Commit

Permalink
Update api.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ArcticFaded authored and AUTOMATIC1111 committed Oct 17, 2022
1 parent 99013ba commit 71d42bb
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions modules/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,15 @@ def __init__(self, txt2img, img2img, run_extras, run_pnginfo):
app.add_api_route("/v1/txt2img", self.text2imgapi, methods=["POST"])

def text2imgapi(self, txt2imgreq: StableDiffusionProcessingAPI ):
print(txt2imgreq)
p = StableDiffusionProcessingTxt2Img(**vars(txt2imgreq))
p.sd_model = shared.sd_model
print(p)
processed = process_images(p)

b64images = []
for i in processed.images:
buffer = io.BytesIO()
i.save(buffer, format="png")
b64images.append(base64.b64encode(buffer.getvalue()))

response = {
"images": b64images,
"info": processed.js(),
"parameters": json.dumps(vars(txt2imgreq))
}


return TextToImageResponse(images=b64images, parameters=json.dumps(vars(txt2imgreq)), info=json.dumps(processed.info))

Expand All @@ -57,4 +48,4 @@ def pnginfoendoint(self):

def launch(self, server_name, port):
app.include_router(self.router)
uvicorn.run(app, host=server_name, port=port)
uvicorn.run(app, host=server_name, port=port)

0 comments on commit 71d42bb

Please sign in to comment.