stable-diffusion
copied
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readme
Files and versions
19 lines
612 B
19 lines
612 B
1 year ago
|
import logging
|
||
|
import torch
|
||
|
from diffusers import StableDiffusionPipeline, DPMSolverMultistepSchedule
|
||
|
from towhee.operator import PyOperator
|
||
|
|
||
|
log = logging.getLogger(PyOperator)
|
||
|
|
||
1 year ago
|
class StableDiffusion(PyOperator):
|
||
1 year ago
|
def __init__(self,model_id='stabilityai/stable-diffusion-2-1',pipe='StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float32)'):
|
||
1 year ago
|
self._model_id=model_id
|
||
1 year ago
|
self.pipe = pipe
|
||
1 year ago
|
|
||
1 year ago
|
def __call__(self, prompt:str):
|
||
1 year ago
|
# pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
||
|
image = pipe(prompt).images[0]
|
||
1 year ago
|
return image
|
||
1 year ago
|
|
||
|
|