Upgrade to Pro — share decks privately, control downloads, hide ads and more …

20230322 - Generative AI 小聚 ft. Happy Designer

20230322 - Generative AI 小聚 ft. Happy Designer

TLDR

蒼時弦や

March 22, 2023
Tweet

More Decks by 蒼時弦や

Other Decks in Technology

Transcript

  1. import from import = = = = = torch diffusers

    StableDiffusionPipeline pipe StableDiffusionPipeline.from_pretrained( , torch.float16) pipe pipe.to( ) prompt image pipe(prompt).images[ ] # 載入模型 # 進行運算 "runwayml/stable- diffusion-v1-5" "cuda" "a photo of an astronaut riding a horse on mars" torch_dtype 0
  2. # ... # 載入不同模型 # 多重處理 prompt image txt2image(prompt).images[ ]

    image upscale(image).images[ ] image image2image(image).images[ ] = = = = "a photo of an astronaut riding a horse on mars" 0 0 0
  3. from import import class def def = = = =

    = return cog BasePredictor, Path, Input torch ( ): (self): (self, image: Path Input( ), scale: Input( , ) ) -> Path: output Predictor BasePredictor setup predict # 初始化、載入模型 # 處理 e.g. Stable Diffusion Pipeline description description default "Image to enlarge" "Factor to scale image by" float 1.5