Munaza10 commited on
Commit
d8e8e04
·
verified ·
1 Parent(s): 52bfd50

Upload 4 files

Browse files
Files changed (4) hide show
  1. .gitattributes +2 -1
  2. README.md +151 -3
  3. astronaut_512.png +3 -0
  4. model_index.json +24 -0
.gitattributes CHANGED
@@ -25,7 +25,6 @@
25
  *.safetensors filter=lfs diff=lfs merge=lfs -text
26
  saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
  *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
  *.tflite filter=lfs diff=lfs merge=lfs -text
30
  *.tgz filter=lfs diff=lfs merge=lfs -text
31
  *.wasm filter=lfs diff=lfs merge=lfs -text
@@ -33,3 +32,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
25
  *.safetensors filter=lfs diff=lfs merge=lfs -text
26
  saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
  *.tar.* filter=lfs diff=lfs merge=lfs -text
 
28
  *.tflite filter=lfs diff=lfs merge=lfs -text
29
  *.tgz filter=lfs diff=lfs merge=lfs -text
30
  *.wasm filter=lfs diff=lfs merge=lfs -text
 
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
35
+ astronaut_1024.png filter=lfs diff=lfs merge=lfs -text
36
+ astronaut_512.png filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,151 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: openrail++
3
+ tags:
4
+ - stable-diffusion
5
+ inference: false
6
+ ---
7
+
8
+ # Stable Diffusion x2 latent upscaler model card
9
+
10
+ This model card focuses on the latent diffusion-based upscaler developed by [Katherine Crowson](https://github.com/crowsonkb/k-diffusion)
11
+ in collaboration with [Stability AI](https://stability.ai/).
12
+ This model was trained on a high-resolution subset of the LAION-2B dataset.
13
+ It is a diffusion model that operates in the same latent space as the Stable Diffusion model, which is decoded into a full-resolution image.
14
+ To use it with Stable Diffusion, You can take the generated latent from Stable Diffusion and pass it into the upscaler before decoding with your standard VAE.
15
+ Or you can take any image, encode it into the latent space, use the upscaler, and decode it.
16
+
17
+ **Note**:
18
+ This upscaling model is designed explicitely for **Stable Diffusion** as it can upscale Stable Diffusion's latent denoised image embeddings.
19
+ This allows for very fast text-to-image + upscaling pipelines as all intermeditate states can be kept on GPU. More for information, see example below.
20
+ This model works on all [Stable Diffusion checkpoints](https://huggingface.co/models?other=stable-diffusion)
21
+
22
+ | ![upscaler.jpg](https://pbs.twimg.com/media/FhK0YjAVUAUtBbx?format=jpg&name=4096x4096) |
23
+ |:--:|
24
+ Image by Tanishq Abraham from [Stability AI](https://stability.ai/) originating from [this tweet](https://twitter.com/StabilityAI/status/1590531958815064065)|
25
+
26
+ Original output image | 2x upscaled output image
27
+ :-------------------------:|:-------------------------:
28
+ ![](https://pbs.twimg.com/media/Fg8UijAaEAAqfvS?format=png&name=small) | ![](https://pbs.twimg.com/media/Fg8UjCmaMAAAUdS?format=jpg&name=medium)
29
+
30
+ - Use it with 🧨 [`diffusers`](https://huggingface.co/stabilityai/sd-x2-latent-upscaler#examples)
31
+
32
+
33
+ ## Model Details
34
+ - **Developed by:** Katherine Crowson
35
+ - **Model type:** Diffusion-based latent upscaler
36
+ - **Language(s):** English
37
+ - **License:** [CreativeML Open RAIL++-M License](https://huggingface.co/stabilityai/stable-diffusion-2/blob/main/LICENSE-MODEL)
38
+
39
+
40
+ ## Examples
41
+
42
+ Using the [🤗's Diffusers library](https://github.com/huggingface/diffusers) to run latent upscaler on top of any `StableDiffusionUpscalePipeline` checkpoint
43
+ to enhance its output image resolution by a factor of 2.
44
+
45
+ ```bash
46
+ pip install git+https://github.com/huggingface/diffusers.git
47
+ pip install transformers accelerate scipy safetensors
48
+ ```
49
+
50
+ ```python
51
+ from diffusers import StableDiffusionLatentUpscalePipeline, StableDiffusionPipeline
52
+ import torch
53
+
54
+ pipeline = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", torch_dtype=torch.float16)
55
+ pipeline.to("cuda")
56
+
57
+ upscaler = StableDiffusionLatentUpscalePipeline.from_pretrained("stabilityai/sd-x2-latent-upscaler", torch_dtype=torch.float16)
58
+ upscaler.to("cuda")
59
+
60
+ prompt = "a photo of an astronaut high resolution, unreal engine, ultra realistic"
61
+ generator = torch.manual_seed(33)
62
+
63
+ # we stay in latent space! Let's make sure that Stable Diffusion returns the image
64
+ # in latent space
65
+ low_res_latents = pipeline(prompt, generator=generator, output_type="latent").images
66
+
67
+ upscaled_image = upscaler(
68
+ prompt=prompt,
69
+ image=low_res_latents,
70
+ num_inference_steps=20,
71
+ guidance_scale=0,
72
+ generator=generator,
73
+ ).images[0]
74
+
75
+ # Let's save the upscaled image under "upscaled_astronaut.png"
76
+ upscaled_image.save("astronaut_1024.png")
77
+
78
+ # as a comparison: Let's also save the low-res image
79
+ with torch.no_grad():
80
+ image = pipeline.decode_latents(low_res_latents)
81
+ image = pipeline.numpy_to_pil(image)[0]
82
+
83
+ image.save("astronaut_512.png")
84
+ ```
85
+
86
+ **Result**:
87
+
88
+ *512-res Astronaut*
89
+ ![ow_res](./astronaut_512.png)
90
+
91
+ *1024-res Astronaut*
92
+ ![upscaled](./astronaut_1024.png)
93
+
94
+ **Notes**:
95
+ - Despite not being a dependency, we highly recommend you to install [xformers](https://github.com/facebookresearch/xformers) for memory efficient attention (better performance)
96
+ - If you have low GPU RAM available, make sure to add a `pipe.enable_attention_slicing()` after sending it to `cuda` for less VRAM usage (to the cost of speed)
97
+
98
+ # Uses
99
+
100
+ ## Direct Use
101
+ The model is intended for research purposes only. Possible research areas and tasks include
102
+
103
+ - Safe deployment of models which have the potential to generate harmful content.
104
+ - Probing and understanding the limitations and biases of generative models.
105
+ - Generation of artworks and use in design and other artistic processes.
106
+ - Applications in educational or creative tools.
107
+ - Research on generative models.
108
+
109
+ Excluded uses are described below.
110
+
111
+ ### Misuse, Malicious Use, and Out-of-Scope Use
112
+ _Note: This section is originally taken from the [DALLE-MINI model card](https://huggingface.co/dalle-mini/dalle-mini), was used for Stable Diffusion v1, but applies in the same way to Stable Diffusion v2_.
113
+
114
+ The model should not be used to intentionally create or disseminate images that create hostile or alienating environments for people. This includes generating images that people would foreseeably find disturbing, distressing, or offensive; or content that propagates historical or current stereotypes.
115
+
116
+ #### Out-of-Scope Use
117
+ The model was not trained to be factual or true representations of people or events, and therefore using the model to generate such content is out-of-scope for the abilities of this model.
118
+
119
+ #### Misuse and Malicious Use
120
+ Using the model to generate content that is cruel to individuals is a misuse of this model. This includes, but is not limited to:
121
+
122
+ - Generating demeaning, dehumanizing, or otherwise harmful representations of people or their environments, cultures, religions, etc.
123
+ - Intentionally promoting or propagating discriminatory content or harmful stereotypes.
124
+ - Impersonating individuals without their consent.
125
+ - Sexual content without consent of the people who might see it.
126
+ - Mis- and disinformation
127
+ - Representations of egregious violence and gore
128
+ - Sharing of copyrighted or licensed material in violation of its terms of use.
129
+ - Sharing content that is an alteration of copyrighted or licensed material in violation of its terms of use.
130
+
131
+ ## Limitations and Bias
132
+
133
+ ### Limitations
134
+
135
+ - The model does not achieve perfect photorealism
136
+ - The model cannot render legible text
137
+ - The model does not perform well on more difficult tasks which involve compositionality, such as rendering an image corresponding to “A red cube on top of a blue sphere”
138
+ - Faces and people in general may not be generated properly.
139
+ - The model was trained mainly with English captions and will not work as well in other languages.
140
+ - The autoencoding part of the model is lossy
141
+ - The model was trained on a subset of the large-scale dataset
142
+ [LAION-5B](https://laion.ai/blog/laion-5b/), which contains adult, violent and sexual content. To partially mitigate this, we have filtered the dataset using LAION's NFSW detector (see Training section).
143
+
144
+ ### Bias
145
+ While the capabilities of image generation models are impressive, they can also reinforce or exacerbate social biases.
146
+ Stable Diffusion vw was primarily trained on subsets of [LAION-2B(en)](https://laion.ai/blog/laion-5b/),
147
+ which consists of images that are limited to English descriptions.
148
+ Texts and images from communities and cultures that use other languages are likely to be insufficiently accounted for.
149
+ This affects the overall output of the model, as white and western cultures are often set as the default. Further, the
150
+ ability of the model to generate content with non-English prompts is significantly worse than with English-language prompts.
151
+ Stable Diffusion v2 mirrors and exacerbates biases to such a degree that viewer discretion must be advised irrespective of the input or its intent.
astronaut_512.png ADDED

Git LFS Details

  • SHA256: 6cfa17d6f29705958de7ab67b39673f03abd68c97de1064ed076b8752375a18c
  • Pointer size: 131 Bytes
  • Size of remote file: 429 kB
model_index.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_class_name": "StableDiffusionLatentUpscalePipeline",
3
+ "_diffusers_version": "0.13.0.dev0",
4
+ "scheduler": [
5
+ "diffusers",
6
+ "EulerDiscreteScheduler"
7
+ ],
8
+ "text_encoder": [
9
+ "transformers",
10
+ "CLIPTextModel"
11
+ ],
12
+ "tokenizer": [
13
+ "transformers",
14
+ "CLIPTokenizer"
15
+ ],
16
+ "unet": [
17
+ "diffusers",
18
+ "UNet2DConditionModel"
19
+ ],
20
+ "vae": [
21
+ "diffusers",
22
+ "AutoencoderKL"
23
+ ]
24
+ }