Views
No views yet
[0, 1] range, arbitrary H×W size[0, 1] rangesrc/model.py in the main repository.1from huggingface_hub import hf_hub_download
2import sys, numpy as np
3from PIL import Image
4
5# Download weights and architecture code
6weights_path = hf_hub_download(repo_id="<your-username>/attention-residual-image-denoiser",
7 filename="weights/best_model_weights4.weights.h5")
8model_py_path = hf_hub_download(repo_id="<your-username>/attention-residual-image-denoiser",
9 filename="src/model.py")
10
11sys.path.append(model_py_path.rsplit("/", 1)[0])
12from model import load_pretrained
13
14model = load_pretrained(weights_path=weights_path)
15
16img = Image.open("noisy.png").convert("L")
17x = (np.asarray(img, dtype=np.float32) / 255.0)[np.newaxis, ..., np.newaxis]
18y = model.predict(x)[0, ..., 0]
19
20Image.fromarray((y * 255).astype(np.uint8), mode="L").save("denoised.png")weights/final_model4.keras directly with tf.keras.models.load_model(..., compile=False) (for 128×128 inputs only).[0,1] normalization.HybridLoss — a weighted average of SSIM, PSNR, Blur Loss, Perceptual Loss, and Color Loss components; 17 different weight combinations were tried and the best was used.final_model4.keras was saved with a fixed 128×128 input size; use the weights-only loading path (weights/best_model_weights4.weights.h5) for different sizes.