hylee commited on
Commit
23fd166
1 Parent(s): 420ecfb
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -91,9 +91,10 @@ net.eval()
91
 
92
  def process(im):
93
  image = modnet.segment(im.name)
94
- Image.fromarray(np.uint8(image)).save(im.name)
 
95
 
96
- img_name_list = [im.name]
97
  print("Number of images: ", len(img_name_list))
98
  # --------- 2. dataloader ---------
99
  # 1. dataloader
@@ -134,7 +135,7 @@ def process(im):
134
 
135
  print(results)
136
 
137
- return Image.open(results[0]), Image.open(im.name)
138
 
139
  title = "U-2-Net"
140
  description = "Gradio demo for U-2-Net, https://github.com/xuebinqin/U-2-Net"
@@ -144,7 +145,7 @@ gr.Interface(
144
  process,
145
  [gr.inputs.Image(type="file", label="Input")
146
  ],
147
- [gr.outputs.Image(type="pil", label="Output"),gr.outputs.Image(type="pil", label="Output")],
148
  title=title,
149
  description=description,
150
  article=article,
 
91
 
92
  def process(im):
93
  image = modnet.segment(im.name)
94
+ im_path = os.path.abspath(os.path.basename(im.name))
95
+ Image.fromarray(np.uint8(image)).save(im_path)
96
 
97
+ img_name_list = [im_path]
98
  print("Number of images: ", len(img_name_list))
99
  # --------- 2. dataloader ---------
100
  # 1. dataloader
 
135
 
136
  print(results)
137
 
138
+ return Image.open(results[0])
139
 
140
  title = "U-2-Net"
141
  description = "Gradio demo for U-2-Net, https://github.com/xuebinqin/U-2-Net"
 
145
  process,
146
  [gr.inputs.Image(type="file", label="Input")
147
  ],
148
+ [gr.outputs.Image(type="pil", label="Output")],
149
  title=title,
150
  description=description,
151
  article=article,