incendies Cursor commited on
Commit
7d20112
·
1 Parent(s): 8ed828d

fix(upscaler): show_error=True + handle_file for local paths + clearer errors

Browse files

- graph.launch(show_error=True) so node exceptions show real message
- Use handle_file(path) for all paths so Phips/Upscaler receives file content (remote server cannot read local path)
- Wrap Client.predict in try/except with RuntimeError for clearer Upscaler API errors

Co-authored-by: Cursor <cursoragent@cursor.com>

Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -41,10 +41,16 @@ def run_upscaler(image, model_selection="4xBHI_dat2_real"):
41
  path = _image_to_filepath(image)
42
  if not path:
43
  return None
44
- client = Client("Phips/Upscaler")
45
- # API expects (image: filepath, model_selection: str). Use handle_file for URLs, path string for local paths.
46
- image_arg = handle_file(path) if path.startswith("http") else path
47
- result = client.predict(image_arg, model_selection, api_name="/upscale_image")
 
 
 
 
 
 
48
  # Returns tuple of 2: [comparison, filepath]; we need the upscaled image path (second element)
49
  if result and len(result) >= 2 and result[1]:
50
  return result[1]
@@ -117,5 +123,5 @@ graph = Graph(
117
  ],
118
  )
119
 
120
- # Launch the Space
121
- graph.launch()
 
41
  path = _image_to_filepath(image)
42
  if not path:
43
  return None
44
+ # Phips/Upscaler runs on a different server - send file content via handle_file so it can read the image (local path is not visible there).
45
+ try:
46
+ image_arg = handle_file(path)
47
+ except Exception as e:
48
+ raise RuntimeError(f"Upscaler: could not load image from path: {e}") from e
49
+ try:
50
+ client = Client("Phips/Upscaler")
51
+ result = client.predict(image_arg, model_selection, api_name="/upscale_image")
52
+ except Exception as e:
53
+ raise RuntimeError(f"Upscaler API error: {e}") from e
54
  # Returns tuple of 2: [comparison, filepath]; we need the upscaled image path (second element)
55
  if result and len(result) >= 2 and result[1]:
56
  return result[1]
 
123
  ],
124
  )
125
 
126
+ # Launch the Space (show_error=True so node exceptions show the real message)
127
+ graph.launch(show_error=True)