yizhangliu commited on
Commit
6220748
1 Parent(s): 6c51482

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -159,13 +159,14 @@ def model_process(image, mask):
159
  config.sd_seed = random.randint(1, 999999999)
160
 
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
@@ -222,15 +223,19 @@ def read_content(file_path: str) -> str:
222
  def predict(dict):
223
  # print(f'liuyz_0_', dict)
224
 
 
225
  image = dict["image"] # .convert("RGB") #.resize((512, 512))
226
  # target_size = (init_image.shape[0], init_image.shape[1])
227
  print(f'liuyz_1_', image.shape)
228
  print(f'liuyz_2_', image.convert("RGB").shape)
229
  print(f'liuyz_3_', image.convert("RGB").resize((512, 512)).shape)
230
  # mask = dict["mask"] # .convert("RGB") #.resize((512, 512))
 
231
 
232
  image = Image.fromarray(dict["image"])
233
- mask = Image.fromarray(dict["mask"])
 
 
234
  output = model_process(dict["image"], dict["mask"])
235
  # output = mask #output.images[0]
236
  # output = pipe(prompt = prompt, image=init_image, mask_image=mask,guidance_scale=7.5)
 
159
  config.sd_seed = random.randint(1, 999999999)
160
 
161
  # logger.info(f"Origin image shape: {original_shape}")
162
+ print(f"Origin image shape: {original_shape} / {type(image)}")
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} / {type(image)}")
166
 
167
  #mask, _ = load_img(input["mask"].read(), gray=True)
168
  mask = resize_max_size(mask, size_limit=size_limit, interpolation=interpolation)
169
+ print(f"mask image shape: {mask.shape} / {type(mask)}")
170
 
171
  if model is None:
172
  return None
 
223
  def predict(dict):
224
  # print(f'liuyz_0_', dict)
225
 
226
+ '''
227
  image = dict["image"] # .convert("RGB") #.resize((512, 512))
228
  # target_size = (init_image.shape[0], init_image.shape[1])
229
  print(f'liuyz_1_', image.shape)
230
  print(f'liuyz_2_', image.convert("RGB").shape)
231
  print(f'liuyz_3_', image.convert("RGB").resize((512, 512)).shape)
232
  # mask = dict["mask"] # .convert("RGB") #.resize((512, 512))
233
+ '''
234
 
235
  image = Image.fromarray(dict["image"])
236
+ mask = Image.fromarray(dict["mask"]).convert("RGB")
237
+ print(f'mask___1 = {mask.shape}')
238
+
239
  output = model_process(dict["image"], dict["mask"])
240
  # output = mask #output.images[0]
241
  # output = pipe(prompt = prompt, image=init_image, mask_image=mask,guidance_scale=7.5)