Zilong-Zhang003 commited on
Commit
b1e0bf7
·
1 Parent(s): 77811ae

readme_normalize

Browse files
Files changed (2) hide show
  1. README.md +21 -1
  2. app.py +2 -6
README.md CHANGED
@@ -10,4 +10,24 @@ pinned: false
10
  short_description: 'RAM++: Robust Representation Learning via Adaptive Mask'
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  short_description: 'RAM++: Robust Representation Learning via Adaptive Mask'
11
  ---
12
 
13
+ # RAM++
14
+
15
+ Online demo for **RAM++: Robust Representation Learning via Adaptive Mask for All-in-One Image Restoration**.
16
+ At inference we use **RestormerRFR** (restoration backbone) + **DINOv2** semantic features for robust, content-aware restoration across noise, blur, compression artifacts, low-light, and mixed degradations.
17
+
18
+ ## What you can do
19
+ - Upload a **JPEG/PNG** → click **Run (ZeroGPU)** → get the restored image.
20
+ - Use the provided **Examples** to try quickly.
21
+ - Call the **API** for batch processing.
22
+
23
+ ## Citation
24
+ ```bibtex
25
+ @misc{zhang2025ramrobustrepresentationlearning,
26
+ title = {RAM++: Robust Representation Learning via Adaptive Mask for All-in-One Image Restoration},
27
+ author = {Zilong Zhang and Chujie Qin and Chunle Guo and Yong Zhang and Chao Xue and Ming-Ming Cheng and Chongyi Li},
28
+ year = {2025},
29
+ eprint = {2509.12039},
30
+ archivePrefix= {arXiv},
31
+ primaryClass = {cs.CV},
32
+ url = {https://arxiv.org/abs/2509.12039}
33
+ }
app.py CHANGED
@@ -83,11 +83,8 @@ def get_model_and_device():
83
  return model, device
84
 
85
 
86
- @spaces.GPU(duration=60)
87
  def restore_image(pil_img: Image.Image) -> Image.Image:
88
- """
89
- 输入一张图片,输出复原后的图片(与 RAM++ RestormerRFR + DINO 特征推理一致)
90
- """
91
  try:
92
  model, device = get_model_and_device()
93
  dino_extractor = get_dino_extractor(device)
@@ -109,7 +106,6 @@ def restore_image(pil_img: Image.Image) -> Image.Image:
109
 
110
  output = normalize(output, -1 * mean / std, 1 / std)
111
  output = output.data.squeeze().float().cpu().clamp_(0, 1).numpy() # (3,H,W)
112
- output = np.transpose(output[[2, 1, 0], :, :], (1, 2, 0)) # (H,W,RGB)
113
  output = (output * 255.0).round().astype(np.uint8)
114
  out_pil = Image.fromarray(output, mode="RGB")
115
  return out_pil
@@ -117,7 +113,7 @@ def restore_image(pil_img: Image.Image) -> Image.Image:
117
  raise gr.Error(f"{e}\n{traceback.format_exc()}")
118
 
119
  DESCRIPTION = """
120
- # RAM++: Robust Representation Learning via Adaptive Mask for All-in-One Image Restoration
121
  """
122
 
123
  with gr.Blocks(title="RAM++ ZeroGPU Demo") as demo:
 
83
  return model, device
84
 
85
 
86
+ @spaces.GPU(duration=120)
87
  def restore_image(pil_img: Image.Image) -> Image.Image:
 
 
 
88
  try:
89
  model, device = get_model_and_device()
90
  dino_extractor = get_dino_extractor(device)
 
106
 
107
  output = normalize(output, -1 * mean / std, 1 / std)
108
  output = output.data.squeeze().float().cpu().clamp_(0, 1).numpy() # (3,H,W)
 
109
  output = (output * 255.0).round().astype(np.uint8)
110
  out_pil = Image.fromarray(output, mode="RGB")
111
  return out_pil
 
113
  raise gr.Error(f"{e}\n{traceback.format_exc()}")
114
 
115
  DESCRIPTION = """
116
+ # RAM++
117
  """
118
 
119
  with gr.Blocks(title="RAM++ ZeroGPU Demo") as demo: