Haoming02 commited on
Commit
0d58bef
1 Parent(s): 9d02dac
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -42,14 +42,13 @@ with gr.Blocks() as demo:
42
  # parameter name is also shown as parameter name in API #
43
  # Note: parameter type has to be manually handled when called from API #
44
  # ==================================================================== #
45
- def proc_image(
46
- image: np.ndarray | str, width: int, height: int
47
- ) -> list[str, Image.Image]:
48
-
49
- if isinstance(image, np.ndarray):
50
- image = Image.fromarray(image)
51
- elif isinstance(image, str):
52
- image = Image.open(BytesIO(base64.b64decode(image)))
53
  else:
54
  raise ValueError("Unsupported Image Type")
55
 
@@ -77,7 +76,7 @@ with gr.Blocks() as demo:
77
  value=None,
78
  image_mode="RGB",
79
  sources="upload",
80
- type="numpy",
81
  label="Input",
82
  show_label=True,
83
  show_download_button=False,
@@ -166,6 +165,8 @@ with gr.Blocks() as demo:
166
  show_progress="hidden",
167
  show_api=True,
168
  api_name="resizeImage",
 
 
169
  )
170
 
171
  demo.launch(show_error=True)
 
42
  # parameter name is also shown as parameter name in API #
43
  # Note: parameter type has to be manually handled when called from API #
44
  # ==================================================================== #
45
+ def proc_image(image: str, width: int, height: int) -> list[str, Image.Image]:
46
+
47
+ if isinstance(image, str):
48
+ if os.path.isfile(image):
49
+ image = Image.open(image)
50
+ else:
51
+ image = Image.open(BytesIO(base64.b64decode(image)))
 
52
  else:
53
  raise ValueError("Unsupported Image Type")
54
 
 
76
  value=None,
77
  image_mode="RGB",
78
  sources="upload",
79
+ type="filepath",
80
  label="Input",
81
  show_label=True,
82
  show_download_button=False,
 
165
  show_progress="hidden",
166
  show_api=True,
167
  api_name="resizeImage",
168
+ preprocess=False,
169
+ postprocess=False,
170
  )
171
 
172
  demo.launch(show_error=True)