mingyi456 commited on
Commit
ddf3c80
·
verified ·
1 Parent(s): c4590c7

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +48 -1
README.md CHANGED
@@ -10,4 +10,51 @@ pipeline_tag: text-to-image
10
  library_name: diffusers
11
  tags:
12
  - diffusion-single-file
13
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  library_name: diffusers
11
  tags:
12
  - diffusion-single-file
13
+ ---
14
+
15
+ ```python
16
+ import torch
17
+ from diffusers import LongCatImagePipeline, LongCatImageTransformer2DModel
18
+ from transformers.modeling_utils import no_init_weights
19
+
20
+ with no_init_weights():
21
+ transformer = LongCatImageTransformer2DModel.from_config(
22
+ LongCatImageTransformer2DModel.load_config(
23
+ "meituan-longcat/LongCat-Image", subfolder="transformer"
24
+ ),
25
+ torch_dtype=torch.bfloat16
26
+ ).to(torch.bfloat16)
27
+
28
+ DFloat11Model.from_pretrained(
29
+ "mingyi456/LongCat-Image-DF11",
30
+ device="cpu",
31
+ bfloat16_model=transformer,
32
+ )
33
+
34
+ pipe = LongCatImagePipeline.from_pretrained(
35
+ "meituan-longcat/LongCat-Image",
36
+ transformer=transformer,
37
+ torch_dtype=torch.bfloat16
38
+ )
39
+ DFloat11Model.from_pretrained(
40
+ "mingyi456/Qwen2.5-VL-7B-Instruct-DF11",
41
+ device="cpu",
42
+ bfloat16_model=pipe.text_encoder,
43
+ )
44
+
45
+ pipe.enable_model_cpu_offload()
46
+ prompt = '一个年轻的亚裔女性,身穿黄色针织衫,搭配白色项链。她的双手放在膝盖上,表情恬静。背景是一堵粗糙的砖墙,午后的阳光温暖地洒在她身上,营造出一种宁静而温馨的氛围。镜头采用中距离视角,突出她的神态和服饰的细节。光线柔和地打在她的脸上,强调她的五官和饰品的质感,增加画面的层次感与亲和力。整个画面构图简洁,砖墙的纹理与阳光的光影效果相得益彰,突显出人物的优雅与从容。'
47
+
48
+ image = pipe(
49
+ prompt,
50
+ height=768,
51
+ width=1344,
52
+ guidance_scale=4.0,
53
+ num_inference_steps=50,
54
+ num_images_per_prompt=1,
55
+ generator=torch.Generator("cpu").manual_seed(43),
56
+ enable_cfg_renorm=True,
57
+ enable_prompt_rewrite=True
58
+ ).images[0]
59
+ image.save('image longcat-image.png')
60
+ ```