stable-diffusion
copied
Friday
1 year ago
commit
3883918a76
2 changed files with 41 additions and 0 deletions
@ -0,0 +1,40 @@ |
|||
# This is a sample Python script. |
|||
|
|||
# Press Shift+F10 to execute it or replace it with your code. |
|||
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. |
|||
|
|||
|
|||
def print_hi(name): |
|||
# Use a breakpoint in the code line below to debug your script. |
|||
print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint. |
|||
|
|||
|
|||
# Press the green button in the gutter to run the script. |
|||
if __name__ == '__main__': |
|||
print_hi('PyCharm') |
|||
|
|||
# See PyCharm help at https://www.jetbrains.com/help/pycharm/ |
|||
import logging |
|||
import torch |
|||
from diffusers import StableDiffusionPipeline, DPMSolverMultistepSchedule |
|||
from towhee.operator import PyOperator |
|||
|
|||
log = logging.getLogger(PyOperator) |
|||
|
|||
class Generation(PyOperator): |
|||
def __init__(self,model_id='stabilityai/stable-diffusion-2-1'): |
|||
self._model_id=model_id |
|||
|
|||
def __call__(self, *args, **kwargs): |
|||
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float32) |
|||
self._pipe = pipe |
|||
prompt=input("please type the prompt") |
|||
self._prompt=prompt |
|||
image = pipe(prompt).images[0] |
|||
self._image=image |
|||
return image("x.png") |
|||
|
|||
#image = pipe(prompt).images[0] |
|||
#image.save("x.png”) |
|||
|
|||
|
Loading…
Reference in new issue