Image-to-Image
Diffusers
lora
image-restoration
face-restoration
super-resolution
reference-based
qwen-image-2.1
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
Add prompts for 5/9 references (woman and man) and a guide to choosing references
Browse files
README.md
CHANGED
|
@@ -48,14 +48,54 @@ five to nine work best.
|
|
| 48 |
| CFG | 1, no negative prompt |
|
| 49 |
| VAE | [Texture-Fix VAE](https://huggingface.co/madebyollin/texture-fix-vae-for-qwen-image-2.1) recommended |
|
| 50 |
|
|
|
|
|
|
|
| 51 |
<details>
|
| 52 |
-
<summary>Prompt
|
| 53 |
|
| 54 |
```text
|
| 55 |
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.
|
| 56 |
```
|
| 57 |
</details>
|
| 58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
## Good to know
|
| 60 |
|
| 61 |
- Generative restoration: detail is reconstructed from the references, not recovered evidence. Not for forensic use.
|
|
|
|
| 48 |
| CFG | 1, no negative prompt |
|
| 49 |
| VAE | [Texture-Fix VAE](https://huggingface.co/madebyollin/texture-fix-vae-for-qwen-image-2.1) recommended |
|
| 50 |
|
| 51 |
+
Prompts for the two setups RefRes was trained on. For another count, change only the last image number (*Images 2 to N*) — with one reference that is *Images 2 to 2*, exactly as in our 1-reference tests.
|
| 52 |
+
|
| 53 |
<details>
|
| 54 |
+
<summary>Prompt · woman · 5 references (images 2–6)</summary>
|
| 55 |
|
| 56 |
```text
|
| 57 |
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.
|
| 58 |
```
|
| 59 |
</details>
|
| 60 |
|
| 61 |
+
<details>
|
| 62 |
+
<summary>Prompt · woman · 9 references (images 2–10)</summary>
|
| 63 |
+
|
| 64 |
+
```text
|
| 65 |
+
Restore image 1, a photo of a woman, into a sharp, clear, high-resolution photograph with crisp fine detail. Images 2 to 10 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.
|
| 66 |
+
```
|
| 67 |
+
</details>
|
| 68 |
+
|
| 69 |
+
<details>
|
| 70 |
+
<summary>Prompt · man · 5 references (images 2–6)</summary>
|
| 71 |
+
|
| 72 |
+
```text
|
| 73 |
+
Restore image 1, a photo of a man, into a sharp, clear, high-resolution photograph with crisp fine detail. Images 2 to 6 are other photos of the same man; use them only as identity reference to recover his 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.
|
| 74 |
+
```
|
| 75 |
+
</details>
|
| 76 |
+
|
| 77 |
+
<details>
|
| 78 |
+
<summary>Prompt · man · 9 references (images 2–10)</summary>
|
| 79 |
+
|
| 80 |
+
```text
|
| 81 |
+
Restore image 1, a photo of a man, into a sharp, clear, high-resolution photograph with crisp fine detail. Images 2 to 10 are other photos of the same man; use them only as identity reference to recover his 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.
|
| 82 |
+
```
|
| 83 |
+
</details>
|
| 84 |
+
|
| 85 |
+
## Choosing the references
|
| 86 |
+
|
| 87 |
+
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:
|
| 88 |
+
|
| 89 |
+
| | 9 references | 5 references |
|
| 90 |
+
|---|---|---|
|
| 91 |
+
| Close-up portraits — head and shoulders, face filling most of the frame, sharp | 3 | 2 |
|
| 92 |
+
| Other photos of the person — waist-up or wider, face clearly visible | 6 | 3 |
|
| 93 |
+
|
| 94 |
+
- **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.
|
| 95 |
+
- **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.
|
| 96 |
+
- **Skip:** beauty filters and heavy retouching, near-duplicate shots, and photos more damaged than image 1.
|
| 97 |
+
- Order does not matter, and image 1 must not be one of the references.
|
| 98 |
+
|
| 99 |
## Good to know
|
| 100 |
|
| 101 |
- Generative restoration: detail is reconstructed from the references, not recovered evidence. Not for forensic use.
|