From 1a8ecf00b114006dfc26e368fa764c07dab5e793 Mon Sep 17 00:00:00 2001 From: Friday <3270939387@qq.com> Date: Wed, 20 Sep 2023 18:01:28 +0800 Subject: [PATCH] first push --- main.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..ff5dc9b --- /dev/null +++ b/main.py @@ -0,0 +1,34 @@ +# 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) + # pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config) + prompt = "an orange cat" + image = pipe(prompt).images[0] + +