regisss HF staff commited on
Commit
ef3d7c5
1 Parent(s): 7794430

Create model card

Browse files
Files changed (1) hide show
  1. README.md +48 -0
README.md CHANGED
@@ -1,3 +1,51 @@
1
  ---
2
  license: apache-2.0
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
  ---
4
+
5
+ [Optimum Habana](https://github.com/huggingface/optimum-habana) is the interface between the 🤗 Transformers and 🤗 Diffusers libraries and Habana's Gaudi processor (HPU). It provides a set of tools enabling easy and fast model loading, training and inference on single- and multi-HPU settings for different downstream tasks.
6
+ Learn more about how to take advantage of the power of Habana HPUs to train Transformers models at [hf.co/hardware/habana](https://huggingface.co/hardware/habana).
7
+
8
+ ## Stable Diffusion HPU configuration
9
+
10
+ This model only contains the `GaudiConfig` file for running **Stable Diffusion 1** (e.g. [CompVis/stable-diffusion-v1-4](https://huggingface.co/CompVis/stable-diffusion-v1-4)) or **Stable Diffusion 2** (e.g. [stabilityai/stable-diffusion-2](https://huggingface.co/stabilityai/stable-diffusion-2)) on Habana's Gaudi processors (HPU).
11
+
12
+ **This model contains no model weights, only a GaudiConfig.**
13
+
14
+ This enables to specify:
15
+ - `use_habana_mixed_precision`: whether to use Habana Mixed Precision (HMP)
16
+ - `hmp_opt_level`: optimization level for HMP, see [here](https://docs.habana.ai/en/latest/PyTorch/PyTorch_Mixed_Precision/PT_Mixed_Precision.html#configuration-options) for a detailed explanation
17
+ - `hmp_bf16_ops`: list of operators that should run in bf16
18
+ - `hmp_fp32_ops`: list of operators that should run in fp32
19
+ - `hmp_is_verbose`: verbosity
20
+
21
+ ## Usage
22
+
23
+ The `GaudiStableDiffusionPipeline` (`GaudiDDIMScheduler`) is instantiated the same way as the `StableDiffusionPipeline` (`DDIMScheduler`) in the 🤗 Diffusers library.
24
+ The only difference is that there are a few new training arguments specific to HPUs.
25
+
26
+ Here is an example with one prompt:
27
+ ```python
28
+ from optimum.habana import GaudiConfig
29
+ from optimum.habana.diffusers import GaudiDDIMScheduler, GaudiStableDiffusionPipeline
30
+
31
+
32
+ model_name = "stabilityai/stable-diffusion-2"
33
+
34
+ scheduler = GaudiDDIMScheduler.from_pretrained(model_name, subfolder="scheduler")
35
+
36
+ pipeline = GaudiStableDiffusionPipeline.from_pretrained(
37
+ model_name,
38
+ scheduler=scheduler,
39
+ use_habana=True,
40
+ use_hpu_graphs=True,
41
+ gaudi_config="Habana/stable-diffusion",
42
+ )
43
+
44
+ outputs = generator(
45
+ ["An image of a squirrel in Picasso style"],
46
+ num_images_per_prompt=16,
47
+ batch_size=4,
48
+ )
49
+ ```
50
+
51
+ Check out the [documentation](https://huggingface.co/docs/optimum/habana/usage_guides/stable_diffusion) and [this example](https://github.com/huggingface/optimum-habana/tree/main/examples/stable-diffusion) for more advanced usage.