udpate usage
Browse files
README.md
CHANGED
@@ -35,4 +35,40 @@ This is a Stable Diffusion model fine-tuned on `alpaca` images for the animal th
|
|
35 |
```python
|
36 |
import torch
|
37 |
from diffusers import StableDiffusionPipeline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
```
|
|
|
35 |
```python
|
36 |
import torch
|
37 |
from diffusers import StableDiffusionPipeline
|
38 |
+
```
|
39 |
+
|
40 |
+
```python
|
41 |
+
# Set device
|
42 |
+
device = (
|
43 |
+
"mps"
|
44 |
+
if torch.backends.mps.is_available()
|
45 |
+
else "cuda"
|
46 |
+
if torch.cuda.is_available()
|
47 |
+
else "cpu"
|
48 |
+
)
|
49 |
+
|
50 |
+
# Load the pipeline
|
51 |
+
model_id = "li-yan/huacaya-alpaca"
|
52 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id).to(device)
|
53 |
+
```
|
54 |
+
|
55 |
+
```python
|
56 |
+
# set prompt
|
57 |
+
prompt = "a photo of huacaya alpaca on the great wall" #@param
|
58 |
+
|
59 |
+
# Set up a generator for reproducibility
|
60 |
+
generator = torch.Generator(device=device).manual_seed(73)
|
61 |
+
|
62 |
+
# Run the pipeline, showing some of the available arguments
|
63 |
+
pipe_output = pipe(
|
64 |
+
prompt=prompt, # What to generate
|
65 |
+
negative_prompt="Oversaturated, blurry, low quality", # What NOT to generate
|
66 |
+
height=480, width=640, # Specify the image size
|
67 |
+
guidance_scale=12, # How strongly to follow the prompt
|
68 |
+
num_inference_steps=50, # How many steps to take
|
69 |
+
generator=generator # Fixed random seed
|
70 |
+
)
|
71 |
+
|
72 |
+
# View the resulting image
|
73 |
+
pipe_output.images[0]
|
74 |
```
|