Add model card with paper link, pipeline tag, license, and code link

#1
by nielsr HF Staff - opened
Files changed (1) hide show
  1. README.md +145 -0
README.md CHANGED
@@ -1,4 +1,149 @@
 
 
 
 
 
 
1
  # OneDiffusion
2
 
 
 
 
 
 
 
3
  VAE model: SD3 VAE
4
  Text encoder: T5-xl
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-nc-4.0
3
+ pipeline_tag: any-to-any
4
+ library_name: diffusers
5
+ ---
6
+
7
  # OneDiffusion
8
 
9
+ This repository contains the OneDiffusion model presented in the paper [One Diffusion to Generate Them All](https://arxiv.org/abs/2411.16318).
10
+
11
+ [Project Page](https://lehduong.github.io/OneDiffusion-homepage/)
12
+
13
+ [Github Repository](https://github.com/lehduong/OneDiffusion)
14
+
15
  VAE model: SD3 VAE
16
  Text encoder: T5-xl
17
+
18
+ ## Installation
19
+
20
+ ```
21
+ conda create -n onediffusion_env python=3.8 &&
22
+ conda activate onediffusion_env &&
23
+ pip install torch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/cu118 &&
24
+ pip install "git+https://github.com/facebookresearch/pytorch3d.git" &&
25
+ pip install -r requirements.txt
26
+ ```
27
+
28
+ ## Quick start
29
+
30
+ Check `inference.py` for more detailed. For text-to-image, you can use below code snipe.
31
+
32
+ ```
33
+ import torch
34
+ from onediffusion.diffusion.pipelines.onediffusion import OneDiffusionPipeline
35
+
36
+ device = torch.device('cuda:0')
37
+
38
+ pipeline = OneDiffusionPipeline.from_pretrained("lehduong/OneDiffusion").to(device=device, dtype=torch.bfloat16)
39
+
40
+ NEGATIVE_PROMPT = "monochrome, greyscale, low-res, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, artist name, poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation"
41
+
42
+ output = pipeline(
43
+ prompt="[[text2image]] A bipedal black cat wearing a huge oversized witch hat, a wizards robe, casting a spell,in an enchanted forest. The scene is filled with fireflies and moss on surrounding rocks and trees",
44
+ negative_prompt=NEGATIVE_PROMPT,
45
+ num_inference_steps=50,
46
+ guidance_scale=4,
47
+ height=1024,
48
+ width=1024,
49
+ )
50
+ output.images[0].save('text2image_output.jpg')
51
+ ```
52
+
53
+ You can run the gradio demo with:
54
+ ```
55
+ python gradio_demo.py --captioner molmo # [molmo, llava, disable]
56
+ ```
57
+ The demo provides guidance and helps format the prompt properly for each task.
58
+
59
+ - By default, it loads the **quantized** Molmo for captioning source images. ~~which significantly increases memory usage. You generally need a GPU with at least $40$ GB of memory to run the demo.~~ You generally need a GPU with at least $21$ GB of memory to run the demo.
60
+
61
+ - Opting to use LLaVA can reduce this requirement to $\approx 27$ GB, though the resulting captions may be less accurate in some cases.
62
+
63
+ - You can also manually provide the caption for each input image and run with `disable` mode. In this mode, the returned caption is an empty string, but you should still press the `Generate Caption` button so that the code formats the input text properly. The memory requirement for this mode is $\approx 12$ GB.
64
+
65
+ Note that the above required memory can change if you use higher resolution or more input images.
66
+
67
+ ## Qualitative Results
68
+
69
+ ### 1. Text-to-Image
70
+ <p align="center">
71
+ <img src="assets/text2image.jpg" alt="Text-to-Image results" width="800">
72
+ </p>
73
+
74
+
75
+ ### 2. ID customization
76
+
77
+ <p align="center">
78
+ <img src="assets/onediffusion_appendix_faceid.jpg" alt="ID customization" width="800">
79
+ </p>
80
+
81
+ <p align="center">
82
+ <img src="assets/onediffusion_appendix_faceid_3.jpg" alt="ID customization non-human subject" width="800">
83
+ </p>
84
+
85
+ ### 3. Multiview generation
86
+
87
+ Single image to multiview:
88
+
89
+ <p align="center">
90
+ <img src="assets/onediffusion_appendix_multiview.jpg" alt="Image to multiview" width="800">
91
+ </p>
92
+
93
+ <p align="center">
94
+ <img src="assets/onediffusion_appendix_multiview_2.jpg" alt="image to multiview" width="800">
95
+ </p>
96
+
97
+ Text to multiview:
98
+
99
+ <p align="center">
100
+ <img src="assets/text2multiview.jpg" alt="Text to multiview image" width="800">
101
+ </p>
102
+
103
+ ### 4. Condition-to-Image and vice versa
104
+ <p align="center">
105
+ <img src="assets/cond_and_image.jpg" alt="Condition and Image" width="800">
106
+ </p>
107
+
108
+ ### 5. Subject-driven generation
109
+
110
+ We finetuned the model on [Subject-200K](https://huggingface.co/datasets/Yuanshi/Subjects200K) dataset (along with all other tasks) for additional 40k steps. The model is now capable of subject-driven generation.
111
+
112
+ <p align="center">
113
+ <img src="assets/subject_driven.jpg" alt="Subject driven generation" width="800">
114
+ </p>
115
+
116
+ ### 6. Text-guide image editing
117
+
118
+ We finetuned the model on [OmniEdit](https://huggingface.co/datasets/TIGER-Lab/OmniEdit-Filtered-1.2M) dataset for additional 30K steps.
119
+
120
+ <p align="center">
121
+ <img src="assets/onediffusion_editing.jpg" alt="Text-guide editing" width="800">
122
+ </p>
123
+
124
+ ### 7. Zero-shot Task combinations
125
+
126
+ We found that the model can handle multiple tasks in a zero-shot setting by combining condition images and task tokens without any fine-tuning, as shown in the examples below. However, its performance on these combined tasks might not be robust, and the model’s behavior may change if the order of task tokens or captions is altered. For example, when using both image inpainting and ID customization together, the target prompt and the caption of the masked image must be identical. If you plan to use such combinations, we recommend fine-tuning the model on these tasks to achieve better performance and simpler usage.
127
+
128
+
129
+ <p align="center">
130
+ <img src="assets/onediffusion_zeroshot.jpg" alt="Subject driven generation" width="800">
131
+ </p>
132
+
133
+ ## License
134
+
135
+ The model is trained on several non-commercially licensed datasets (e.g., DL3DV, Unsplash), thus, **model weights** are released under a CC BY-NC license as described in [LICENSE](https://github.com/lehduong/onediffusion/blob/main/LICENSE).
136
+
137
+ ## Citation
138
+
139
+ ```bibtex
140
+ @misc{le2024diffusiongenerate,
141
+ title={One Diffusion to Generate Them All},
142
+ author={Duong H. Le and Tuan Pham and Sangho Lee and Christopher Clark and Aniruddha Kembhavi and Stephan Mandt and Ranjay Krishna and Jiasen Lu},
143
+ year={2024},
144
+ eprint={2411.16318},
145
+ archivePrefix={arXiv},
146
+ primaryClass={cs.CV},
147
+ url={https://arxiv.org/abs/2411.16318},
148
+ }
149
+ ```