commit 3883918a7612e58a9c72a3eb9740a262d5b5e1e8 Author: Friday <3270939387@qq.com> Date: Tue Sep 19 22:27:43 2023 +0800 first push diff --git a/main.py b/main.py new file mode 100644 index 0000000..c7a82fc --- /dev/null +++ b/main.py @@ -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”) + + diff --git a/stable-diffusion b/stable-diffusion new file mode 160000 index 0000000..8b5345e --- /dev/null +++ b/stable-diffusion @@ -0,0 +1 @@ +Subproject commit 8b5345e845cbf609b030b98beb4797a90f42a94d