create pipeline in request
This commit is contained in:
parent
73027bb813
commit
2e95e02ef1
10
api/serve.py
10
api/serve.py
|
@ -47,7 +47,6 @@ def setup():
|
||||||
# setup
|
# setup
|
||||||
setup()
|
setup()
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
pipe = OnnxStableDiffusionPipeline.from_pretrained(model_path, provider="DmlExecutionProvider", safety_checker=None)
|
|
||||||
|
|
||||||
# routes
|
# routes
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
|
@ -70,13 +69,18 @@ def txt2img():
|
||||||
print("txt2img from %s: %s/%s, %sx%s, %s" % (user, cfg, steps, width, height, prompt))
|
print("txt2img from %s: %s/%s, %sx%s, %s" % (user, cfg, steps, width, height, prompt))
|
||||||
image_queue.add(user)
|
image_queue.add(user)
|
||||||
|
|
||||||
|
pipe = OnnxStableDiffusionPipeline.from_pretrained(
|
||||||
|
model_path,
|
||||||
|
provider="DmlExecutionProvider",
|
||||||
|
safety_checker=None,
|
||||||
|
scheduler=scheduler
|
||||||
|
)
|
||||||
image = pipe(
|
image = pipe(
|
||||||
prompt,
|
prompt,
|
||||||
height,
|
height,
|
||||||
width,
|
width,
|
||||||
num_inference_steps=steps,
|
num_inference_steps=steps,
|
||||||
guidance_scale=cfg,
|
guidance_scale=cfg
|
||||||
scheduler=scheduler
|
|
||||||
).images[0]
|
).images[0]
|
||||||
|
|
||||||
output = '%s/txt2img-%s' % (output_path, snakecase(prompt))
|
output = '%s/txt2img-%s' % (output_path, snakecase(prompt))
|
||||||
|
|
Loading…
Reference in New Issue