Image-to-Image
Diffusers
blind-face-restoration
face-restoration
flux
lora
diffusion
text-guided-image-restoration
Instructions to use thetrigger/A2BFR with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use thetrigger/A2BFR with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline from diffusers.utils import load_image # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", dtype=torch.bfloat16, device_map="cuda") pipe.load_lora_weights("thetrigger/A2BFR") prompt = "Turn this cat into a dog" input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png") image = pipe(image=input_image, prompt=prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: black-forest-labs/FLUX.1-dev
|
| 4 |
+
tags:
|
| 5 |
+
- image-to-image
|
| 6 |
+
- blind-face-restoration
|
| 7 |
+
- face-restoration
|
| 8 |
+
- flux
|
| 9 |
+
- lora
|
| 10 |
+
- diffusion
|
| 11 |
+
- text-guided-image-restoration
|
| 12 |
+
library_name: diffusers
|
| 13 |
+
pipeline_tag: image-to-image
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# A<sup>2</sup>BFR: Attribute-Aware Blind Face Restoration
|
| 17 |
+
|
| 18 |
+
A<sup>2</sup>BFR is an attribute-aware blind face restoration model built on **FLUX.1-dev**. It restores low-quality face images while allowing text prompts to guide facial attributes such as smiling, eyeglasses, hairstyle, and other semantic changes.
|
| 19 |
+
|
| 20 |
+
This repository hosts the released A<sup>2</sup>BFR **LoRA checkpoint** for inference.
|
| 21 |
+
|
| 22 |
+
- Code: [MediaX-SJTU/A2BFR](https://github.com/MediaX-SJTU/A2BFR)
|
| 23 |
+
- Base model: [black-forest-labs/FLUX.1-dev](https://huggingface.co/black-forest-labs/FLUX.1-dev)
|
| 24 |
+
- Checkpoint: `default.safetensors`
|
| 25 |
+
|
| 26 |
+
## Model Details
|
| 27 |
+
|
| 28 |
+
A<sup>2</sup>BFR injects the low-resolution face image as a visual condition and uses text prompts for attribute-aware restoration. The model is trained as a LoRA on top of FLUX.1-dev, so users must prepare the FLUX.1-dev base model separately and comply with its license and usage terms.
|
| 29 |
+
|
| 30 |
+
Key features:
|
| 31 |
+
|
| 32 |
+
- Blind face restoration from low-quality face inputs.
|
| 33 |
+
- Text-guided attribute control during restoration.
|
| 34 |
+
- LoRA checkpoint for efficient loading and sharing.
|
| 35 |
+
- Inference code released in the GitHub repository.
|
| 36 |
+
|
| 37 |
+
## Installation
|
| 38 |
+
|
| 39 |
+
Clone the code repository and install dependencies:
|
| 40 |
+
|
| 41 |
+
```bash
|
| 42 |
+
git clone https://github.com/MediaX-SJTU/A2BFR.git
|
| 43 |
+
cd A2BFR
|
| 44 |
+
conda create -n a2bfr python=3.10 -y
|
| 45 |
+
conda activate a2bfr
|
| 46 |
+
pip install -r requirements.txt
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
Install a CUDA-compatible PyTorch build for your GPU environment if needed.
|
| 50 |
+
|
| 51 |
+
## Download Weights
|
| 52 |
+
|
| 53 |
+
```bash
|
| 54 |
+
hf download thetrigger/A2BFR default.safetensors --local-dir checkpoints/A2BFR
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
## Inference
|
| 58 |
+
|
| 59 |
+
Single image inference:
|
| 60 |
+
|
| 61 |
+
```bash
|
| 62 |
+
python infer.py \
|
| 63 |
+
--base-model /path/to/FLUX.1-dev \
|
| 64 |
+
--lora checkpoints/A2BFR/default.safetensors \
|
| 65 |
+
--condition-image /path/to/lq_face.png \
|
| 66 |
+
--output-dir outputs/demo \
|
| 67 |
+
--prompt "A photo of a human face" \
|
| 68 |
+
--guidance-scale 3.0 \
|
| 69 |
+
--seed 0 \
|
| 70 |
+
--concat
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
Batch inference:
|
| 74 |
+
|
| 75 |
+
```bash
|
| 76 |
+
python infer.py \
|
| 77 |
+
--base-model /path/to/FLUX.1-dev \
|
| 78 |
+
--lora checkpoints/A2BFR/default.safetensors \
|
| 79 |
+
--input-dir /path/to/lq_faces \
|
| 80 |
+
--output-dir outputs/batch \
|
| 81 |
+
--prompt "A high-quality, high-resolution, realistic, and extremely detailed image of a human face" \
|
| 82 |
+
--guidance-scale 3.0 \
|
| 83 |
+
--seed 0
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
Useful options:
|
| 87 |
+
|
| 88 |
+
- `--prompt`: controls the target facial attributes and restoration semantics.
|
| 89 |
+
- `--width` / `--height`: output resolution; default is `512 x 512`.
|
| 90 |
+
- `--dtype`: defaults to `bfloat16`; use `float16` if needed.
|
| 91 |
+
- `--preprocess deblurring`: creates a degraded condition image from a clean input. For already low-quality inputs, keep the default `--preprocess none`.
|
| 92 |
+
- `--concat`: saves a side-by-side condition/result image.
|
| 93 |
+
|
| 94 |
+
## Intended Use
|
| 95 |
+
|
| 96 |
+
This model is intended for research on blind face restoration, text-guided image restoration, and controllable face image generation. It can be used to restore degraded face images and explore attribute-aware restoration behavior.
|
| 97 |
+
|
| 98 |
+
## Limitations
|
| 99 |
+
|
| 100 |
+
- The model requires FLUX.1-dev as the base model.
|
| 101 |
+
- The released checkpoint is a LoRA and is not a standalone full model.
|
| 102 |
+
- Results may vary with input quality, prompt wording, guidance scale, and random seed.
|
| 103 |
+
- The model may fail on extreme degradations, heavy occlusions, non-face images, or images far outside the training distribution.
|
| 104 |
+
- Generated facial attributes should not be treated as factual identity or biometric evidence.
|
| 105 |
+
|
| 106 |
+
## Ethical Considerations
|
| 107 |
+
|
| 108 |
+
Face restoration and attribute editing can be misused for impersonation, misleading media, or privacy-invasive applications. Users should obtain proper consent for face images, avoid deceptive use, and clearly disclose generated or restored content where appropriate.
|
| 109 |
+
|
| 110 |
+
## Training
|
| 111 |
+
|
| 112 |
+
Training code will be released.
|
| 113 |
+
|
| 114 |
+
## Citation
|
| 115 |
+
|
| 116 |
+
If A<sup>2</sup>BFR is useful for your work, please cite the project once the paper/citation is available.
|
| 117 |
+
|
| 118 |
+
## License
|
| 119 |
+
|
| 120 |
+
This checkpoint is released under the Apache 2.0 license. Users must also follow the license and acceptable use terms of the FLUX.1-dev base model.
|
| 121 |
+
|
| 122 |
+
## Acknowledgement
|
| 123 |
+
|
| 124 |
+
This project is based on [OminiControl](https://github.com/Yuanshi9815/OminiControl). We also leveraged [facer](https://github.com/FacePerceiver/facer)'s code in our project. Thanks for these awesome works.
|