-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathText2Img_LoRA.py
More file actions
22 lines (19 loc) · 801 Bytes
/
Copy pathText2Img_LoRA.py
File metadata and controls
22 lines (19 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from diffusers import AutoPipelineForText2Image
import torch
import argparse
from matplotlib import pyplot as plt
def parse_args():
parser = argparse.ArgumentParser(description="Text2Img LoRA")
parser.add_argument("--lora_model_path", type=str, default="./../../models/Text2Img_Lora/naruto/checkpoint-60", help="Path to LoRA model")
args = parser.parse_args()
return args
args = parse_args()
pipeline = AutoPipelineForText2Image.from_pretrained("stabilityai/stable-diffusion-2-1", torch_dtype=torch.float16).to("cuda")
pipeline.load_lora_weights(args.lora_model_path, weight_name="pytorch_lora_weights.safetensors")
while True:
text = input("Enter prompt (0 to exit): ")
if text == "0":
break
image = pipeline(text).images[0]
plt.imshow(image)
plt.show()