cosmicman commited on
Commit
26f23d8
1 Parent(s): 84cc02c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +57 -3
README.md CHANGED
@@ -1,3 +1,57 @@
1
- ---
2
- license: cc-by-4.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-4.0
3
+ ---
4
+ ![Intro Image](cosmicman_samples.png)
5
+
6
+ CosmicMan is a text-to-image foundation model specialized for generating high-fidelity human images. For more information, please refer to our research paper: [CosmicMan: A Text-to-Image Foundation Model for Humans](CosmicMan: A Text-to-Image Foundation Model for Humans). Our model is based on [stabilityai/stable-diffusion-xl-base-1.0](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0). This repository provide UNet checkpoints for CosmicMan-SDXL.
7
+
8
+
9
+ ## Requirements
10
+
11
+ ```python
12
+ conda create -n cosmicman python=3.10
13
+ source activate cosmicman
14
+ pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
15
+ pip install accelerate diffusers datasets transformers botocore invisible-watermark bitsandbytes gradio
16
+ ```
17
+
18
+ ## Inference
19
+
20
+ ```python
21
+ import torch
22
+ from diffusers import StableDiffusionXLPipeline, StableDiffusionXLImg2ImgPipeline, UNet2DConditionModel, EulerDiscreteScheduler
23
+ from huggingface_hub import hf_hub_download
24
+ from safetensors.torch import load_file
25
+
26
+ base_path = "stabilityai/stable-diffusion-xl-base-1.0"
27
+ refiner_path = "stabilityai/stable-diffusion-xl-refiner-1.0"
28
+ unet_path = "cosmicman/CosmicMan-SDXL"
29
+
30
+ # Load model.
31
+ unet = UNet2DConditionModel.from_pretrained(unet_path, torch_dtype=torch.float16)
32
+ pipe = StableDiffusionXLPipeline.from_pretrained(base_path, unet=unet, torch_dtype=torch.float16, variant="fp16").to("cuda")
33
+ pipe.scheduler = EulerDiscreteScheduler.from_pretrained(base_path, subfolder="scheduler", torch_dtype=torch.float16)
34
+
35
+ refiner = StableDiffusionXLImg2ImgPipeline.from_pretrained(refiner_path,torch_dtype=torch.float16, use_safetensors=True).to("cuda")
36
+ refiner.scheduler = EulerDiscreteScheduler.from_pretrained(base_path, subfolder="scheduler", torch_dtype=torch.float16)
37
+
38
+ # Generate image.
39
+ positive_prompt = "A fit Caucasian elderly woman, her wavy white hair above shoulders, wears a pink floral cotton long-sleeve shirt and a cotton hat against a natural landscape in an upper body shot"
40
+ negative_prompt = ""
41
+ image = pipe(positive_prompt, num_inference_steps=30,
42
+ guidance_scale=7.5, height=1024,
43
+ width=1024, negative_prompt=negative_prompt, output_type="latent").images[0]
44
+ image = refiner(positive_prompt, negative_prompt=negative_prompt, image=image[None, :]).images[0].save("output.png")
45
+ ```
46
+
47
+
48
+ ## Citation Information
49
+ ```
50
+ @article{li2024cosmicman,
51
+ title={CosmicMan: A Text-to-Image Foundation Model for Humans},
52
+ author={Li, Shikai and Fu, Jianglin and Liu, Kaiyuan and Wang, Wentao and Lin, Kwan-Yee and Wu, Wayne},
53
+ journal={arXiv preprint arXiv:2404.01294},
54
+ year={2024}
55
+ }
56
+
57
+ ```