flux-dev
Collection
flux image models
•
5 items
•
Updated
•
1
This repository contains Real-ESRGAN upscale models for post-processing and enhancing generated images. These models can upscale images by 2x or 4x while adding fine details and improving sharpness.
Real-ESRGAN (Real Enhanced Super-Resolution Generative Adversarial Networks) models for high-quality image upscaling. These models are commonly used as post-processing steps for AI-generated images to increase resolution and enhance details.
Key Capabilities:
Total Size: ~192MB
4x-UltraSharp.pth - 64MB - 4x upscaling with ultra-sharp detail enhancementRealESRGAN-x2plus.pth - 64MB - 2x upscaling modelRealESRGAN-x4plus.pth - 64MB - 4x upscaling modelfrom basicsr.archs.rrdbnet_arch import RRDBNet
from realesrgan import RealESRGANer
import cv2
# Load the upscaler model
model = RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32)
upsampler = RealESRGANer(
scale=4,
model_path="E:\\huggingface\\flux-upscale\\upscale_models\\4x-UltraSharp.pth",
model=model,
tile=0,
tile_pad=10,
pre_pad=0,
half=True # Use FP16 for faster inference on GPU
)
# Load and upscale an image
img = cv2.imread("input.png", cv2.IMREAD_COLOR)
output, _ = upsampler.enhance(img, outscale=4)
cv2.imwrite("output_upscaled.png", output)
from diffusers import FluxPipeline
from realesrgan import RealESRGANer
from basicsr.archs.rrdbnet_arch import RRDBNet
import torch
import numpy as np
# Generate image with FLUX
pipe = FluxPipeline.from_pretrained(
"E:\\huggingface\\flux-dev-fp16",
torch_dtype=torch.float16
)
pipe.to("cuda")
image = pipe(
prompt="a beautiful landscape with mountains",
num_inference_steps=30
).images[0]
# Convert PIL to numpy/cv2 format
img_array = np.array(image)
# Initialize upscaler
model = RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32)
upsampler = RealESRGANer(
scale=4,
model_path="E:\\huggingface\\flux-upscale\\upscale_models\\4x-UltraSharp.pth",
model=model,
half=True
)
# Upscale the generated image
upscaled, _ = upsampler.enhance(img_array, outscale=4)
# Save result
import cv2
cv2.imwrite("flux_upscaled_4x.png", upscaled)
from basicsr.archs.rrdbnet_arch import RRDBNet
from realesrgan import RealESRGANer
import cv2
# Configure for large images with tiling
model = RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32)
upsampler = RealESRGANer(
scale=4,
model_path="E:\\huggingface\\flux-upscale\\upscale_models\\RealESRGAN_x4plus.pth",
model=model,
tile=512, # Process in 512x512 tiles
tile_pad=10, # Padding to avoid seams
pre_pad=0,
half=True
)
# Process large image
img = cv2.imread("large_image.png", cv2.IMREAD_COLOR)
output, _ = upsampler.enhance(img, outscale=4)
cv2.imwrite("large_upscaled.png", output)
| Model | Scale | Best For | File Size | Speed |
|---|---|---|---|---|
| 4x-UltraSharp | 4x | Sharp details, AI-generated images | 64MB | Moderate |
| RealESRGAN_x2plus | 2x | Moderate upscaling, faster processing | 64MB | Fast |
| RealESRGAN_x4plus | 4x | General purpose 4x upscaling | 64MB | Moderate |
Model Selection Guide:
.pth fileshalf=True for FP16 inference on compatible GPUs (approximately 2x faster)tile=512 to reduce VRAM usage for large imagestile_pad=10 to minimize visible seams between tilespip install realesrgan basicsr
Dependencies:
These models are released under the Apache 2.0 license.
@InProceedings{wang2021realesrgan,
author = {Xintao Wang and Liangbin Xie and Chao Dong and Ying Shan},
title = {Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data},
booktitle = {International Conference on Computer Vision Workshops (ICCVW)},
year = {2021}
}
For questions about Real-ESRGAN models, refer to the official Real-ESRGAN repository and documentation at https://github.com/xinntao/Real-ESRGAN