Update README.md
Browse files
README.md
CHANGED
@@ -76,7 +76,7 @@ Contact us today to unlock the potential of BRIA 2.3 FAST-LORA! By submitting th
|
|
76 |
|
77 |
|
78 |
|
79 |
-
|
80 |
|
81 |
|
82 |
```
|
@@ -98,4 +98,42 @@ pipe.to("cuda")
|
|
98 |
prompt = "A portrait of a Beautiful and playful ethereal singer, golden designs, highly detailed, blurry background"
|
99 |
|
100 |
image = pipe(prompt, num_inference_steps=8, guidance_scale=0.0).images[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
```
|
|
|
76 |
|
77 |
|
78 |
|
79 |
+
# Code example using Diffusers
|
80 |
|
81 |
|
82 |
```
|
|
|
98 |
prompt = "A portrait of a Beautiful and playful ethereal singer, golden designs, highly detailed, blurry background"
|
99 |
|
100 |
image = pipe(prompt, num_inference_steps=8, guidance_scale=0.0).images[0]
|
101 |
+
```
|
102 |
+
|
103 |
+
|
104 |
+
# Using both LCM LORA and ControlNet
|
105 |
+
|
106 |
+
|
107 |
+
```
|
108 |
+
condition_image_path = "A_dog.png"
|
109 |
+
prompt = "A white dog"
|
110 |
+
seed = 222
|
111 |
+
w, h = 1024, 1024
|
112 |
+
|
113 |
+
controlnet = ControlNetModel.from_pretrained(
|
114 |
+
"briaai/BRIA-2.3-ControlNet-Canny",
|
115 |
+
torch_dtype=torch.float16
|
116 |
+
)
|
117 |
+
pipe = StableDiffusionXLControlNetPipeline.from_pretrained("briaai/BRIA-2.3", controlnet=controlnet, torch_dtype=torch.float16)
|
118 |
+
|
119 |
+
|
120 |
+
pipe.load_lora_weights("briaai/BRIA-2.3-FAST-LORA")
|
121 |
+
pipe.fuse_lora()
|
122 |
+
pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)
|
123 |
+
pipe.force_zeros_for_empty_prompt = False
|
124 |
+
pipe.to("cuda")
|
125 |
+
|
126 |
+
negative_prompt = "Logo,Watermark,Text,Ugly,Morbid,Extra fingers,Poorly drawn hands,Mutation,Blurry,Extra limbs,Gross proportions,Missing arms,Mutated hands,Long neck,Duplicate,Mutilated,Mutilated hands,Poorly drawn face,Deformed,Bad anatomy,Cloned face,Malformed limbs,Missing legs,Too many fingers"
|
127 |
+
generator = torch.Generator("cuda").manual_seed(seed)
|
128 |
+
|
129 |
+
# Calculate Canny image
|
130 |
+
low_threshold, high_threshold = 100, 200
|
131 |
+
input_image = cv2.imread(condition_image_path)
|
132 |
+
input_image = cv2.Canny(input_image, low_threshold, high_threshold)
|
133 |
+
input_image = input_image[:, :, None]
|
134 |
+
input_image = np.concatenate([input_image, input_image, input_image], axis=2)
|
135 |
+
condition_image = Image.fromarray(input_image)
|
136 |
+
|
137 |
+
#Generate
|
138 |
+
image = pipe(prompt, image=condition_image, controlnet_conditioning_scale=1.0, num_inference_steps=8, width=w,height=h, guidance_scale=0.0, negative_prompt=negative_prompt, generator=generator,).images[0]
|
139 |
```
|