TBurdairon commited on
Commit
a4196d6
·
verified ·
1 Parent(s): ba91d35

Upload folder using huggingface_hub

Browse files
.DS_Store ADDED
Binary file (6.15 kB). View file
 
README.md ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ ---
3
+ pipeline_tag: image-to-image
4
+ tags:
5
+ - ESRGAN
6
+ - super-resolution
7
+ - enhancer
8
+ ---
9
+
10
+ # Finegrain Image Enhancer (ESRGAN-based)
11
+
12
+ This model enhances image quality using ESRGAN and custom ControlNet/LoRA techniques.
13
+
14
+ ## Usage
15
+
16
+ ```python
17
+ from huggingface_hub import InferenceClient
18
+
19
+ client = InferenceClient("your-username/finegrain-image-enhancer", token="hf_xxx")
20
+ result = client.post(json={"inputs": {"image": "<base64 image>"}})
21
+ ```
checkpoints/4x-UltraSharp.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7bf14a0e758e545859068257e7138a0536f5c8ed6643a0fd66d9e72198a60b64
3
+ size 35
checkpoints/JuggernautNegative-neg.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:73989087e53cedffc98a052820411d256a1e140d8e3845ff736b57961f82130d
3
+ size 28
checkpoints/SDXLrender_v2.0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4522278873e3b6b0a8c064218bba4524be2e50911e66e187c9193019aeb46e27
3
+ size 23
checkpoints/autoencoder_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:592ff7a3041445f7ff7e599894dcb53d1c23aa30e00bc1201f649e6bed7f1c00
3
+ size 51
checkpoints/controlnet_tile_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b60f28e776a8d38e2eae2efe01b491f542eec0a0ce4fd3709a5668b4a46cd5db
3
+ size 37
checkpoints/more_details.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4522278873e3b6b0a8c064218bba4524be2e50911e66e187c9193019aeb46e27
3
+ size 23
checkpoints/text_encoder_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ec6e6f9bc20a82042f59928440f5ff4ecd921122a59cf351f93bd991d3d1a36e
3
+ size 52
checkpoints/unet_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4fca60ff0bfa80e223bd08941f24117784ae87d2eaffebb55b54248fd32822a6
3
+ size 44
config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+
2
+ {
3
+ "pipeline_tag": "image-to-image",
4
+ "model_type": "esrgan",
5
+ "base_model": "philz1337x/upscaler"
6
+ }
enhancer.py ADDED
@@ -0,0 +1 @@
 
 
1
+ <copied from uploaded enhancer.py>
esrgan_model.py ADDED
@@ -0,0 +1 @@
 
 
1
+ <copied from uploaded esrgan_model.py>
inference.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ from pathlib import Path
3
+ import torch
4
+ from PIL import Image
5
+ import base64
6
+ import io
7
+ from enhancer import ESRGANUpscaler, ESRGANUpscalerCheckpoints
8
+
9
+ checkpoints = ESRGANUpscalerCheckpoints(
10
+ esrgan=Path("checkpoints/4x-UltraSharp.pth")
11
+ )
12
+
13
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
14
+ dtype = torch.bfloat16 if torch.cuda.is_bf16_supported() else torch.float32
15
+
16
+ enhancer = ESRGANUpscaler(
17
+ checkpoints=checkpoints,
18
+ device=device,
19
+ dtype=dtype
20
+ )
21
+
22
+ def inference(inputs: dict) -> dict:
23
+ if "image" not in inputs:
24
+ return {"error": "No image provided"}
25
+
26
+ image_data = inputs["image"]
27
+ if image_data.startswith("data:image"):
28
+ image_data = image_data.split(",")[1]
29
+ image_bytes = base64.b64decode(image_data)
30
+ input_image = Image.open(io.BytesIO(image_bytes)).convert("RGB")
31
+
32
+ enhanced_image = enhancer.upscale(input_image)
33
+
34
+ buf = io.BytesIO()
35
+ enhanced_image.save(buf, format="PNG")
36
+ b64 = base64.b64encode(buf.getvalue()).decode("utf-8")
37
+
38
+ return {
39
+ "enhanced_image": b64,
40
+ "original_size": input_image.size,
41
+ "enhanced_size": enhanced_image.size
42
+ }
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+
2
+ git+https://github.com/finegrain-ai/refiners@cfe8b66ba4f8a906583850ac25e9e89cb83a44b9
3
+ numpy<2.0.0
4
+ pillow>=10.4.0
5
+ pillow-heif>=0.18.0
6
+ torch>=2.0.0
7
+ transformers>=4.21.0
8
+ huggingface-hub>=0.16.0