make_hair / inference.py
DiningSystem's picture
Upload inference.py
9c26bf0
raw
history blame
586 Bytes
from diffusers import StableDiffusionPipeline
import torch
#remember to login with token before loading model
def text_to_hair(prompt, save_name, num_inference_steps=500, guidance_scale=8, model_path ="CVH-vn1210/hair-model"):
pipe = StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2",torch_dtype=torch.float16)
pipe.unet.load_attn_procs(model_path)
pipe.to("cuda")
image = pipe(prompt, num_inference_steps=num_inference_steps, guidance_scale=8).images[0]
image.save(save_name) #comment if don't want to save image
return image #PIL format