Update README.md
Browse files
README.md
CHANGED
|
@@ -6,8 +6,57 @@ Standalone inference pipeline for LibreFLUX-based ControlNet with classifier-fre
|
|
| 6 |
## Status
|
| 7 |
Work in progress. Not fully functional yet. Code is being transferred and adapted from my larger project repo to this inference-only repo.
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
## Status
|
| 7 |
Work in progress. Not fully functional yet. Code is being transferred and adapted from my larger project repo to this inference-only repo.
|
| 8 |
|
| 9 |
+
|
| 10 |
+
### Compatibility
|
| 11 |
+
|
| 12 |
+
- Use these specific library versions:
|
| 13 |
+
```
|
| 14 |
+
pip install -U diffusers==0.32.0
|
| 15 |
+
pip install -U "transformers @ git+https://github.com/huggingface/transformers@e15687fffe5c9d20598a19aeab721ae0a7580f8a"
|
| 16 |
+
```
|
| 17 |
+
|
| 18 |
+
### Load Pipeline
|
| 19 |
+
|
| 20 |
+
```import torch
|
| 21 |
+
from diffusers import DiffusionPipeline
|
| 22 |
+
|
| 23 |
+
model_id = "neuralvfx/LibreFlux-ControlNet"
|
| 24 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 25 |
+
|
| 26 |
+
dtype = torch.bfloat16 if device == "cuda" else torch.float32
|
| 27 |
+
|
| 28 |
+
pipe = DiffusionPipeline.from_pretrained(
|
| 29 |
+
model_id,
|
| 30 |
+
custom_pipeline=model_id,
|
| 31 |
+
trust_remote_code=True,
|
| 32 |
+
torch_dtype=dtype,
|
| 33 |
+
safety_checker=None
|
| 34 |
+
).to(device)
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
### Inference
|
| 38 |
+
|
| 39 |
+
```from PIL import Image
|
| 40 |
+
# Load Control Image
|
| 41 |
+
cond = Image.open("examples/libe_flux_control.png")
|
| 42 |
+
cond = cond.resize((1024, 1024))
|
| 43 |
+
|
| 44 |
+
# Convert PIL image to tensor and move to device with correct dtype
|
| 45 |
+
cond_tensor = ToTensor()(cond)[:3,:,:].to(pipe.device, dtype=pipe.dtype).unsqueeze(0)
|
| 46 |
+
|
| 47 |
+
out = pipe(
|
| 48 |
+
prompt="many pieces of drift wood spelling libre flux sitting casting shadow on the lumpy sandy beach with foot prints all over it",
|
| 49 |
+
negative_prompt="blurry",
|
| 50 |
+
control_image=cond_tensor, # Use the tensor here
|
| 51 |
+
num_inference_steps=75,
|
| 52 |
+
guidance_scale=4.0,
|
| 53 |
+
height =1024,
|
| 54 |
+
width=1024,
|
| 55 |
+
controlnet_conditioning_scale=1.0,
|
| 56 |
+
num_images_per_prompt=1,
|
| 57 |
+
control_mode=None,
|
| 58 |
+
generator= torch.Generator().manual_seed(32),
|
| 59 |
+
return_dict=True,
|
| 60 |
+
)
|
| 61 |
+
out.images[0]
|
| 62 |
+
```
|