yizhangliu commited on
Commit
7372fa3
1 Parent(s): bba2454

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -105,7 +105,7 @@ def preprocess_mask(mask):
105
  return mask
106
 
107
  model = None
108
- def model_process(init_image, mask):
109
  global model
110
 
111
  # input = request.files
@@ -117,11 +117,12 @@ def model_process(init_image, mask):
117
 
118
  # image, alpha_channel = load_img(origin_image_bytes)
119
  # Origin image shape: (512, 512, 3)
120
- original_shape = init_image.shape
121
  interpolation = cv2.INTER_CUBIC
122
 
123
  # form = request.form
124
-
 
125
  size_limit = 1080 # : Union[int, str] = form.get("sizeLimit", "1080")
126
  if size_limit == "Original":
127
  size_limit = max(image.shape)
@@ -151,22 +152,24 @@ def model_process(init_image, mask):
151
  cv2_flag='INPAINT_NS',
152
  cv2_radius=5,
153
  )
 
154
 
155
- if config.sd_seed == -1:
156
- config.sd_seed = random.randint(1, 999999999)
157
-
 
158
  # logger.info(f"Origin image shape: {original_shape}")
159
  print(f"Origin image shape: {original_shape}")
160
  image = resize_max_size(image, size_limit=size_limit, interpolation=interpolation)
161
  # logger.info(f"Resized image shape: {image.shape}")
162
  print(f"Resized image shape: {image.shape}")
163
 
 
 
 
164
  if model is None:
165
  return None
166
 
167
- mask, _ = load_img(input["mask"].read(), gray=True)
168
- mask = resize_max_size(mask, size_limit=size_limit, interpolation=interpolation)
169
-
170
  start = time.time()
171
  res_np_img = model(image, mask, config)
172
  logger.info(f"process time: {(time.time() - start) * 1000}ms")
 
105
  return mask
106
 
107
  model = None
108
+ def model_process(image, mask):
109
  global model
110
 
111
  # input = request.files
 
117
 
118
  # image, alpha_channel = load_img(origin_image_bytes)
119
  # Origin image shape: (512, 512, 3)
120
+ original_shape = image.shape
121
  interpolation = cv2.INTER_CUBIC
122
 
123
  # form = request.form
124
+ print(f'liuyz_3_here_', original_shape)
125
+
126
  size_limit = 1080 # : Union[int, str] = form.get("sizeLimit", "1080")
127
  if size_limit == "Original":
128
  size_limit = max(image.shape)
 
152
  cv2_flag='INPAINT_NS',
153
  cv2_radius=5,
154
  )
155
+ print(f'config = {config}')
156
 
157
+ # if config.sd_seed == -1:
158
+ # config.sd_seed = random.randint(1, 999999999)
159
+
160
+ config.sd_seed = 42
161
  # logger.info(f"Origin image shape: {original_shape}")
162
  print(f"Origin image shape: {original_shape}")
163
  image = resize_max_size(image, size_limit=size_limit, interpolation=interpolation)
164
  # logger.info(f"Resized image shape: {image.shape}")
165
  print(f"Resized image shape: {image.shape}")
166
 
167
+ #mask, _ = load_img(input["mask"].read(), gray=True)
168
+ mask = resize_max_size(mask, size_limit=size_limit, interpolation=interpolation)
169
+
170
  if model is None:
171
  return None
172
 
 
 
 
173
  start = time.time()
174
  res_np_img = model(image, mask, config)
175
  logger.info(f"process time: {(time.time() - start) * 1000}ms")