Instructions to use hc0/RefRes with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use hc0/RefRes 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("Qwen/Qwen-Image-2.1-Turbo", dtype=torch.bfloat16, device_map="cuda") pipe.load_lora_weights("hc0/RefRes") 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
RefRes
One damaged photo + a few photos of the same person β the photo, restored, with the person's real face. Adapters for image-editing models β available now for Qwen-Image-2.1 and Qwen-Image-2.1-Turbo, FLUX.2 [klein] in training.
AI-generated fictional person; the photo was damaged on purpose. Qwen-Image-2.1 + RefRes, 40 steps. Bottom right: the same model, prompt, references and seed without RefRes.
Why references
A restorer without references has to guess the face. RefRes looks at other photos of the same person, so the result stays that person: on 48 restorations of unseen people, identity similarity rises from 0.73 to 0.91β0.93, and the result is about seven times closer to the real photo (LPIPS 0.42 β 0.06). One reference already works; five to nine work best.
Quick start
| Image 1 | the photo to restore |
| Images 2 β¦ | 1β9 photos of the same person |
| Model | Qwen-Image-2.1-Turbo (8 steps) or Qwen-Image-2.1 (40 steps) |
| File | qwen-image-2.1/RefRes-v5-qwen-image-2.1.safetensors |
| LoRA strength | 1.0 |
| CFG | 1, no negative prompt |
| VAE | Texture-Fix VAE recommended |
Prompt (woman, 5 references)
Restore image 1, a photo of a woman, into a sharp, clear, high-resolution photograph with crisp fine detail. Images 2 to 6 are other photos of the same woman; use them only as identity reference to recover her true facial features and fine details. Keep image 1's pose, expression, framing, clothing, background and colors unchanged. Remove every trace of low resolution and degradation: pixelation, soft or blurry upscaling, blur, all kinds of noise and film grain, JPEG and WebP compression artifacts, color banding, as well as any overlaid text, stickers, emoji or watermarks. The result must look natively high resolution: sharp, clean and detailed, with no grain, no noise and no low-resolution softness.
- For a man: replace woman with man and her with his.
- For another number of references: change only the last image number β Images 2 to 10 for nine, Images 2 to 2 for one.
Choosing the references
References are resized to about 384 Γ 384 pixels, so a small face in a wide shot carries little detail. RefRes was trained with this mix, and it works best when your set looks the same:
| 9 references | 5 references | |
|---|---|---|
| Close-up portraits β head and shoulders, face filling most of the frame, sharp | 3 | 2 |
| Other photos of the person β waist-up or wider, face clearly visible | 6 | 3 |
- Must have: only this person's face clearly visible (crop out other people), sharp, no sunglasses or masks, and taken around the same age as image 1.
- Variety helps: different days, light and angles (front, both three-quarter sides), and one with an expression close to image 1 β e.g. a smile with teeth if image 1 smiles.
- Skip: beauty filters and heavy retouching, near-duplicate shots, and photos more damaged than image 1.
- Order does not matter, and image 1 must not be one of the references.
Good to know
- Generative restoration: detail is reconstructed from the references, not recovered evidence. Not for forensic use.
- Only restore photos you have the right to edit.
- Each adapter follows its base model's license; the Qwen-Image-2.1 adapter: Qwen Research License (non-commercial). Built with Qwen. Trained on freely licensed photos from Wikimedia Commons; the photos themselves are not distributed.
- Downloads last month
- -

