Views
No views yet
pip install diffusers, accelerate, torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2+cu118 -f https://download.pytorch.org/whl/cu118/torch_stable.html1from diffusers import DiffusionPipeline
2import torch
3
4# 加載模型
5pipeline = DiffusionPipeline.from_pretrained("izzysde/hippojabe_style_image_generator")
6
7# 如果有 GPU,將模型移到 CUDA
8if torch.cuda.is_available():
9pipeline.to("cuda")
10else:
11pipeline.to("cpu")
12
13# 定義生成圖像的參數
14prompt = "show a cute bird in the style of hippojabe" # 用英文寫描述一定要用in the style of hippojabe結尾
15num_inference_steps = 100 # 控制生成質量和速度的步驟數
16guidance_scale = 9 # 控制生成圖像與文本提示的一致性
17
18# 生成圖片
19with torch.no_grad():
20image = pipeline(prompt, num_inference_steps=num_inference_steps, guidance_scale=guidance_scale)["images"][0]
21
22# 保存或顯示圖像
23image.save("generated_image.png")
24image.show()
25