import gradio as gr from diffusers import StableDiffusionPipeline import torch import huggingface_hub as hf import os hf.login(token=os.environ['model_token']) #remember to login with token before loading model def text_to_hair(prompt, num_inference_steps=200, guidance_scale=6, model_path ="CVH-vn1210/hair-model"): pipe = StableDiffusionPipeline.from_pretrained(os.environ['bmd'], 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=guidance_scale).images[0] #image.save(save_name) #comment if don't want to save image return image #PIL format demo = gr.Interface(fn=text_to_hair, inputs="text", outputs="image") demo.launch()