Compare commits
4 Commits
294ff694cb
...
018163fae8
Author | SHA1 | Date |
---|---|---|
Jimmy | 018163fae8 | |
Jimmy | 2f91297ff9 | |
Jimmy | 80097d995d | |
Jimmy | 76813d86ec |
|
@ -1,2 +1,3 @@
|
|||
.env
|
||||
image.png
|
||||
image.png
|
||||
images/
|
|
@ -10,10 +10,14 @@ services:
|
|||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
- ~/Downloads/sd-v1-4-full-ema.ckpt:/app/model.ckpt
|
||||
- ./images:/images
|
||||
- ./notebooks:/notebooks
|
||||
- ./models:/root/.cache/huggingface/diffusers/
|
||||
ports:
|
||||
- 8888:8888
|
||||
- 8000:8000
|
||||
|
||||
vosk:
|
||||
image: alphacep/kaldi-en-gpu
|
||||
image: alphacep/kaldi-en
|
||||
ports:
|
||||
- 2700:2700
|
||||
runtime: nvidia
|
|
@ -9,6 +9,7 @@ from os import getenv
|
|||
from fastapi import FastAPI, Response, HTTPException
|
||||
from pydantic import BaseModel
|
||||
import io
|
||||
from PIL.PngImagePlugin import PngInfo
|
||||
|
||||
load_dotenv()
|
||||
|
||||
|
@ -30,16 +31,23 @@ app = FastAPI()
|
|||
},
|
||||
response_class=Response
|
||||
)
|
||||
def root(text: Text):
|
||||
prompt = text.text
|
||||
def root(text: str):
|
||||
prompt = text.replace('+', ' ')
|
||||
print(prompt)
|
||||
try:
|
||||
image = pipe(prompt).images[0]
|
||||
generator = torch.Generator("cuda").manual_seed(1024)
|
||||
resp = pipe(prompt)
|
||||
print(resp)
|
||||
image = resp.images[0]
|
||||
except RuntimeError as e:
|
||||
raise HTTPException(status_code=202, detail="Busy")
|
||||
except:
|
||||
except:
|
||||
raise HTTPException(status_code=504)
|
||||
|
||||
metadata = PngInfo()
|
||||
metadata.add_text("text", prompt)
|
||||
image.save(f'/images/{str(uuid.uuid4())}.png', pnginfo=metadata)
|
||||
|
||||
imgByteArr = io.BytesIO()
|
||||
image.save(imgByteArr, format="PNG")
|
||||
imgByteArr = imgByteArr.getvalue()
|
||||
|
|
Loading…
Reference in New Issue