Spaces:
Runtime error
Runtime error
Commit
·
9c26bf0
1
Parent(s):
5cd9e3b
Upload inference.py
Browse files- inference.py +11 -0
inference.py
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from diffusers import StableDiffusionPipeline
|
2 |
+
import torch
|
3 |
+
|
4 |
+
#remember to login with token before loading model
|
5 |
+
def text_to_hair(prompt, save_name, num_inference_steps=500, guidance_scale=8, model_path ="CVH-vn1210/hair-model"):
|
6 |
+
pipe = StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2",torch_dtype=torch.float16)
|
7 |
+
pipe.unet.load_attn_procs(model_path)
|
8 |
+
pipe.to("cuda")
|
9 |
+
image = pipe(prompt, num_inference_steps=num_inference_steps, guidance_scale=8).images[0]
|
10 |
+
image.save(save_name) #comment if don't want to save image
|
11 |
+
return image #PIL format
|