File size: 2,510 Bytes
e60886c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Ultimate Upscaler Models Collection

<div align="center">
  <img src="assets/white_tiger.jpg" alt="White Tiger - Upscaled with 4xNomos2_hq_dat2.pth" width="500px">
  <p><i>White Tiger - Upscaled with 4xNomos2_hq_dat2.pth</i></p>
</div>

This repository contains a comprehensive collection of upscaler models organized by their primary purpose. The models are compatible with ComfyUI's Ultimate Upscaler node and other popular frameworks.

## Directory Structure

| Directory | Description |
|-----------|-------------|
| ESRGAN/ | ESRGAN architecture models |
| SwinIR/ | SwinIR architecture models |
| LDSR/ | LDSR architecture models |
| photo-realistic/ | Models optimized for photorealistic content |
| anime-cartoon/ | Models for anime, manga, and cartoon content |
| text-documents/ | Models for text and document upscaling |
| special-purpose/ | Models for specific artistic styles |
| general-purpose/ | Versatile models for various content types |

## Using with ComfyUI Ultimate Upscaler

These models are compatible with ComfyUI's Ultimate Upscaler node. When using them:

1. Select the appropriate model based on your content type
2. Adjust the denoise strength based on the content:
   - Lower (0.2-0.4) for preserving details, line art, and textures
   - Moderate (0.4-0.6) for general content
   - Higher (0.6-0.8) for smoother results and noise removal
3. Enable tile processing for large images with appropriate overlap (64-128 pixels)

## Using with Hugging Face

```python
from huggingface_hub import hf_hub_download
import torch
from basicsr.archs.rrdbnet_arch import RRDBNet
from PIL import Image
import numpy as np
import torchvision.transforms as transforms

# Download a model from this collection
model_path = hf_hub_download(
    repo_id="ABDALLALSWAITI/Upscalers",
    filename="ESRGAN/4xNomos2_hq_dat2.pth"
)

# Load the model (example for ESRGAN architecture)
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
model = RRDBNet(3, 3, 64, 23, gc=32)
model.load_state_dict(torch.load(model_path), strict=True)
model.eval()
model = model.to(device)

# Load and preprocess image
img = Image.open('input.jpg').convert('RGB')
img = transforms.ToTensor()(img).unsqueeze(0).to(device)

# Upscale
with torch.no_grad():
    output = model(img)

# Convert to image
output = output.squeeze().float().cpu().clamp_(0, 1).numpy()
output = np.transpose(output[[2, 1, 0], :, :], (1, 2, 0)) * 255.0
output = Image.fromarray(output.astype(np.uint8))
output.save('output.jpg')
```