Adds precise docstrings to main func and enables MCP server mode

#2
by fffiloni - opened
Files changed (1) hide show
  1. app.py +21 -5
app.py CHANGED
@@ -146,10 +146,26 @@ def run_with_upload(
146
  cy_norm: float,
147
  ):
148
  """
149
- - upscale_option: "1x" / "2x" / "4x"
150
- - cx_norm, cy_norm: normalized center coordinates in [0,1]
151
- The underlying `recursive_multiscale_sr` expects a list of centers
152
- of length rec_num (default 4). We replicate (cx_norm, cy_norm) four times.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
  """
154
  if uploaded_image_path is None:
155
  return []
@@ -317,4 +333,4 @@ with gr.Blocks(css=css) as demo:
317
  demo.queue(default_concurrency_limit=1, # ≤ 1 worker per event
318
  max_size=20) # optional: allow 20 waiting jobs
319
 
320
- demo.launch(share=True)
 
146
  cy_norm: float,
147
  ):
148
  """
149
+ Perform chain-of-zoom super-resolution on a given image, using recursive multi-scale upscaling centered on a specific point.
150
+
151
+ This function enhances a given image by progressively zooming into a specific point, using a recursive deep super-resolution model.
152
+
153
+ Args:
154
+ uploaded_image_path (str): Path to the input image file on disk.
155
+ upscale_option (str): The desired upscale factor as a string. Valid options are "1x", "2x", and "4x".
156
+ - "1x" means no upscaling.
157
+ - "2x" means 2× enlargement per zoom step.
158
+ - "4x" means 4× enlargement per zoom step.
159
+ cx_norm (float): Normalized X-coordinate (0 to 1) of the zoom center.
160
+ cy_norm (float): Normalized Y-coordinate (0 to 1) of the zoom center.
161
+
162
+ Returns:
163
+ list[PIL.Image.Image]: A list of progressively zoomed-in and super-resolved images at each recursion step (typically 4),
164
+ centered around the user-specified point.
165
+
166
+ Note:
167
+ The center point is repeated for each recursion level to maintain consistency during zooming.
168
+ This function uses a modified version of the `recursive_multiscale_sr` pipeline for inference.
169
  """
170
  if uploaded_image_path is None:
171
  return []
 
333
  demo.queue(default_concurrency_limit=1, # ≤ 1 worker per event
334
  max_size=20) # optional: allow 20 waiting jobs
335
 
336
+ demo.launch(share=True, mcp_server=True)