izzysde commited on
Commit
2f51866
1 Parent(s): f7edcff

更新做法

Browse files
Files changed (1) hide show
  1. README.md +27 -1
README.md CHANGED
@@ -7,4 +7,30 @@ pipeline_tag: text-to-image
7
  tags:
8
  - art
9
  - hippo
10
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  tags:
8
  - art
9
  - hippo
10
+ ---
11
+
12
+
13
+ from diffusers import DiffusionPipeline
14
+ import torch
15
+
16
+ # 加載模型
17
+ pipeline = DiffusionPipeline.from_pretrained("izzysde/hippojabe_style_image_generator")
18
+
19
+ # 如果有 GPU,將模型移到 CUDA
20
+ if torch.cuda.is_available():
21
+ pipeline.to("cuda")
22
+ else:
23
+ pipeline.to("cpu")
24
+
25
+ # 定義生成圖像的參數
26
+ prompt = "show a cute bird in the style of hippojabe" # 用英文寫描述一定要用in the style of hippojabe結尾
27
+ num_inference_steps = 100 # 控制生成質量和速度的步驟數
28
+ guidance_scale = 9 # 控制生成圖像與文本提示的一致性
29
+
30
+ # 生成圖片
31
+ with torch.no_grad():
32
+ image = pipeline(prompt, num_inference_steps=num_inference_steps, guidance_scale=guidance_scale)["images"][0]
33
+
34
+ # 保存或顯示圖像
35
+ image.save("generated_image.png")
36
+ image.show()