1
0
Fork 0

test server

This commit is contained in:
Sean Sube 2023-01-04 18:25:00 -06:00
commit f966332193
2 changed files with 26 additions and 0 deletions

2
api/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
__pycache__/
venv/

24
api/serve.py Normal file
View File

@ -0,0 +1,24 @@
from diffusers import OnnxStableDiffusionPipeline
from flask import Flask
max_height = 512
max_width = 512
app = Flask(__name__)
pipe = OnnxStableDiffusionPipeline.from_pretrained("./stable_diffusion_onnx", provider="DmlExecutionProvider", safety_checker=None)
@app.route('/')
def hello():
return 'Hello, World!'
@app.route('/txt2img')
def txt2img():
height = request.args.get('height', max_height)
width = request.args.get('width', max_width)
prompt = request.args.get('prompt', "a photo of an astronaut eating a hamburger")
steps = 50
cfg = 8
image = pipe(prompt, height, width, num_inference_steps=steps, guidance_scale=cfg).images[0]
image.save("astronaut_rides_horse.png")