regisss HF staff commited on
Commit
4807689
·
1 Parent(s): 7946a26

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +51 -0
README.md CHANGED
@@ -1,3 +1,54 @@
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 Hugging Face Transformers and Diffusers libraries and Habana's Gaudi processor (HPU).
6
+ 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.
7
+ Learn more about how to take advantage of the power of Habana HPUs to train and deploy Transformers and Diffusers models at [hf.co/hardware/habana](https://huggingface.co/hardware/habana).
8
+
9
+ ## Stable Diffusion HPU configuration
10
+
11
+ This model only contains the `GaudiConfig` file for running **Stable Diffusion v2** (e.g. [stabilityai/stable-diffusion-2-1](https://huggingface.co/stabilityai/stable-diffusion-2-1)) on Habana's Gaudi processors (HPU).
12
+
13
+ **This model contains no model weights, only a GaudiConfig.**
14
+
15
+ This enables to specify:
16
+ - `use_habana_mixed_precision`: whether to use Habana Mixed Precision (HMP)
17
+ - `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
18
+ - `hmp_bf16_ops`: list of operators that should run in bf16
19
+ - `hmp_fp32_ops`: list of operators that should run in fp32
20
+ - `hmp_is_verbose`: verbosity
21
+
22
+ ## Usage
23
+
24
+ The `GaudiStableDiffusionPipeline` (`GaudiDDIMScheduler`) is instantiated the same way as the `StableDiffusionPipeline` (`DDIMScheduler`) in the 🤗 Diffusers library.
25
+ The only difference is that there are a few new training arguments specific to HPUs.
26
+
27
+ Here is an example with one prompt:
28
+ ```python
29
+ from optimum.habana import GaudiConfig
30
+ from optimum.habana.diffusers import GaudiDDIMScheduler, GaudiStableDiffusionPipeline
31
+
32
+
33
+ model_name = "stabilityai/stable-diffusion-2-1"
34
+
35
+ scheduler = GaudiDDIMScheduler.from_pretrained(model_name, subfolder="scheduler")
36
+
37
+ pipeline = GaudiStableDiffusionPipeline.from_pretrained(
38
+ model_name,
39
+ height=768,
40
+ width=768,
41
+ scheduler=scheduler,
42
+ use_habana=True,
43
+ use_hpu_graphs=True,
44
+ gaudi_config="Habana/stable-diffusion-v2",
45
+ )
46
+
47
+ outputs = generator(
48
+ ["An image of a squirrel in Picasso style"],
49
+ num_images_per_prompt=6,
50
+ batch_size=2,
51
+ )
52
+ ```
53
+
54
+ 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.