logo
Browse Source

first push

main
Friday 1 year ago
parent
commit
1a8ecf00b1
  1. 34
      main.py

34
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]
Loading…
Cancel
Save