Diffusers
TalHach61 commited on
Commit
b6d1407
·
verified ·
1 Parent(s): 737e60a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +42 -18
README.md CHANGED
@@ -118,38 +118,62 @@ image = pipe(
118
 
119
  # Multi-Controls Inference
120
  ```python
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  import torch
122
  from diffusers.utils import load_image
123
- from diffusers import FluxControlNetPipeline, FluxControlNetModel, FluxMultiControlNetModel
 
 
124
 
125
- base_model = 'black-forest-labs/FLUX.1-dev'
126
- controlnet_model_union = 'InstantX/FLUX.1-dev-Controlnet-Union'
127
 
128
- controlnet_union = FluxControlNetModel.from_pretrained(controlnet_model_union, torch_dtype=torch.bfloat16)
129
- controlnet = FluxMultiControlNetModel([controlnet_union]) # we always recommend loading via FluxMultiControlNetModel
130
 
131
- pipe = FluxControlNetPipeline.from_pretrained(base_model, controlnet=controlnet, torch_dtype=torch.bfloat16)
132
  pipe.to("cuda")
133
 
134
- prompt = 'A bohemian-style female travel blogger with sun-kissed skin and messy beach waves.'
135
- control_image_depth = load_image("https://huggingface.co/InstantX/FLUX.1-dev-Controlnet-Union/resolve/main/images/depth.jpg")
136
- control_mode_depth = 2
 
 
 
 
 
 
137
 
138
- control_image_canny = load_image("https://huggingface.co/InstantX/FLUX.1-dev-Controlnet-Union/resolve/main/images/canny.jpg")
139
- control_mode_canny = 0
140
 
141
- width, height = control_image.size
142
 
 
143
  image = pipe(
144
  prompt,
145
- control_image=[control_image_depth, control_image_canny],
146
- control_mode=[control_mode_depth, control_mode_canny],
147
  width=width,
148
  height=height,
149
- controlnet_conditioning_scale=[0.2, 0.4],
150
- num_inference_steps=24,
151
- guidance_scale=3.5,
152
- generator=torch.manual_seed(42),
 
153
  ).images[0]
154
 
155
  ```
 
118
 
119
  # Multi-Controls Inference
120
  ```python
121
+ from huggingface_hub import hf_hub_download
122
+ import os
123
+
124
+ try:
125
+ local_dir = os.path.dirname(__file__)
126
+ except:
127
+ local_dir = '.'
128
+
129
+ hf_hub_download(repo_id="briaai/BRIA-4B-Adapt", filename='pipeline_bria.py', local_dir=local_dir)
130
+ hf_hub_download(repo_id="briaai/BRIA-4B-Adapt", filename='transformer_bria.py', local_dir=local_dir)
131
+ hf_hub_download(repo_id="briaai/BRIA-4B-Adapt", filename='bria_utils.py', local_dir=local_dir)
132
+ hf_hub_download(repo_id="briaai/BRIA-3.0-ControlNet-Union", filename='pipeline_bria_controlnet.py', local_dir=local_dir)
133
+ hf_hub_download(repo_id="briaai/BRIA-3.0-ControlNet-Union", filename='controlnet_bria.py', local_dir=local_dir)
134
+
135
+
136
  import torch
137
  from diffusers.utils import load_image
138
+ from controlnet_bria import BriaControlNetModel, BriaMultiControlNetModel
139
+ from pipeline_bria_controlnet import BriaControlNetPipeline
140
+ import PIL.Image as Image
141
 
142
+ base_model = 'briaai/BRIA-4B-Adapt'
143
+ controlnet_model = 'briaai/BRIA-3.0-ControlNet-Union'
144
 
145
+ controlnet = BriaControlNetModel.from_pretrained(controlnet_model, torch_dtype=torch.bfloat16)
146
+ controlnet = BriaMultiControlNetModel([controlnet])
147
 
148
+ pipe = BriaControlNetPipeline.from_pretrained(base_model, controlnet=controlnet, torch_dtype=torch.bfloat16, trust_remote_code=True)
149
  pipe.to("cuda")
150
 
151
+ # control_image_colorgrid = load_image("https://huggingface.co/briaai/BRIA-3.0-ControlNet-Union/resolve/main/colorgrid.jpg")
152
+ # control_image_pose = load_image("https://huggingface.co/briaai/BRIA-3.0-ControlNet-Union/resolve/main/pose.jpg")
153
+
154
+ control_image_colorgrid = Image.open("/home/ubuntu/spring/Infra/sd3/eval_results/control_images/colorgrid/38.jpg").convert("RGB")
155
+ control_image_pose = Image.open("/home/ubuntu/spring/Infra/sd3/eval_results/control_images/pose/38.jpg").convert("RGB")
156
+
157
+ control_image = [control_image_colorgrid, control_image_pose]
158
+ controlnet_conditioning_scale = [0.5, 0.5]
159
+ control_mode = [2, 5]
160
 
161
+ width, height = control_image[0].size
 
162
 
163
+ prompt = 'Two kids in jackets play near a tent in a forest with trees.'
164
 
165
+ generator = torch.Generator(device="cuda").manual_seed(555)
166
  image = pipe(
167
  prompt,
168
+ control_image=control_image,
169
+ control_mode=control_mode,
170
  width=width,
171
  height=height,
172
+ controlnet_conditioning_scale=controlnet_conditioning_scale,
173
+ num_inference_steps=50,
174
+ max_sequence_length=128,
175
+ guidance_scale=5,
176
+ generator=generator
177
  ).images[0]
178
 
179
  ```