hAIrcut / src /model.py
kauabarros-24
CHORE: a
0d82919
raw
history blame contribute delete
528 Bytes
import torch
from diffusers import DiffusionPipeline
pipe = None
def load_model():
print('Loading model...')
global pipe
print('Model loaded!')
if pipe is None:
print('Loading model... 2')
pipe = DiffusionPipeline.from_pretrained(
"stablediffusionapi/deliberate-v2",
torch_dtype=torch.float16
).to("cuda")
print('Model loaded! 2')
return pipe
def generate(prompt: str):
pipe = load_model()
image = pipe(prompt).images[0]
return image