hylee commited on
Commit
ec88f2e
1 Parent(s): 13a8cfb
Files changed (2) hide show
  1. app.py +2 -2
  2. modnet.py +3 -2
app.py CHANGED
@@ -134,7 +134,7 @@ def process(im):
134
 
135
  print(results)
136
 
137
- return Image.open(results[0])
138
 
139
  title = "U-2-Net"
140
  description = "Gradio demo for U-2-Net, https://github.com/xuebinqin/U-2-Net"
@@ -144,7 +144,7 @@ gr.Interface(
144
  process,
145
  [gr.inputs.Image(type="file", label="Input")
146
  ],
147
- gr.outputs.Image(type="pil", label="Output"),
148
  title=title,
149
  description=description,
150
  article=article,
 
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
  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,
modnet.py CHANGED
@@ -60,7 +60,6 @@ class ModNet:
60
  im_h, im_w, im_c = im.shape
61
  x, y = self.get_scale_factor(im_h, im_w, ref_size)
62
 
63
- image = im
64
  # resize image
65
  im = cv2.resize(im, None, fx=x, fy=y, interpolation=cv2.INTER_AREA)
66
 
@@ -78,7 +77,9 @@ class ModNet:
78
  matte = cv2.resize(matte, dsize=(im_w, im_h), interpolation=cv2.INTER_AREA)
79
 
80
  # obtain predicted foreground
81
- image = np.asarray(image)
 
 
82
  if len(image.shape) == 2:
83
  image = image[:, :, None]
84
  if image.shape[2] == 1:
 
60
  im_h, im_w, im_c = im.shape
61
  x, y = self.get_scale_factor(im_h, im_w, ref_size)
62
 
 
63
  # resize image
64
  im = cv2.resize(im, None, fx=x, fy=y, interpolation=cv2.INTER_AREA)
65
 
 
77
  matte = cv2.resize(matte, dsize=(im_w, im_h), interpolation=cv2.INTER_AREA)
78
 
79
  # obtain predicted foreground
80
+ image = cv2.imread(image_path)
81
+ image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
82
+
83
  if len(image.shape) == 2:
84
  image = image[:, :, None]
85
  if image.shape[2] == 1: