Commit 825c4b6a authored by chenpangpang's avatar chenpangpang
Browse files

feat: 新增生图模型

parent f2c2cf9b
...@@ -5,7 +5,7 @@ os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com' ...@@ -5,7 +5,7 @@ os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
model_list = [ model_list = [
"openai-community/gpt2", "openai-community/gpt2",
# "stabilityai/stable-diffusion-xl-base-1.0" "CompVis/stable-diffusion-v1-4"
] ]
os.system("pip install -U huggingface-hub") os.system("pip install -U huggingface-hub")
...@@ -14,4 +14,4 @@ for model_path in model_list: ...@@ -14,4 +14,4 @@ for model_path in model_list:
root_dir = os.path.basename(model_path) root_dir = os.path.basename(model_path)
os.system( os.system(
f"huggingface-cli download --resume-download {model_path} --local-dir ./{root_dir}/{model_path} \ f"huggingface-cli download --resume-download {model_path} --local-dir ./{root_dir}/{model_path} \
--local-dir-use-symlinks False --token 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") --local-dir-use-symlinks False")
import torch
from diffusers import StableDiffusionPipeline
model_id = "CompVis/stable-diffusion-v1-4"
device = "cuda"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe = pipe.to(device)
prompt = "a photo of an astronaut riding a horse on mars"
image = pipe(prompt).images[0]
image.save("output.png")
print("The output image has been saved as output.png")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment