yizhangliu commited on
Commit
a0a768e
1 Parent(s): 0840b84

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -76,10 +76,14 @@ model = None
76
  def model_process(image, mask):
77
  global model
78
 
 
 
 
 
79
  original_shape = image.shape
80
  interpolation = cv2.INTER_CUBIC
81
 
82
- size_limit = 512 #1080 # "Original"
83
  if size_limit == "Original":
84
  size_limit = max(image.shape)
85
  else:
@@ -112,13 +116,13 @@ def model_process(image, mask):
112
  if config.sd_seed == -1:
113
  config.sd_seed = random.randint(1, 999999999)
114
 
115
- print(f"Origin image shape_0_: {original_shape} / {image[250][250]} / {size_limit}")
116
  image = resize_max_size(image, size_limit=size_limit, interpolation=interpolation)
117
- print(f"Resized image shape_1_: {image.shape} / {image[250][250]}")
118
 
119
- print(f"mask image shape_0_: {mask.shape} / {type(mask)} / {mask[250][250]}")
120
  mask = resize_max_size(mask, size_limit=size_limit, interpolation=interpolation)
121
- print(f"mask image shape_1_: {mask.shape} / {type(mask)} / {mask[250][250]}")
122
 
123
  if model is None:
124
  return None
 
76
  def model_process(image, mask):
77
  global model
78
 
79
+ if mask.shape[0] == image.shape[1] and mask.shape[1] == image.shape[0]:
80
+ # rotate image
81
+ image = np.transpose(image[::-1, ...][:, ::-1], axes=(1, 0, 2))[::-1, ...]
82
+
83
  original_shape = image.shape
84
  interpolation = cv2.INTER_CUBIC
85
 
86
+ size_limit = 1080 #1080 # "Original"
87
  if size_limit == "Original":
88
  size_limit = max(image.shape)
89
  else:
 
116
  if config.sd_seed == -1:
117
  config.sd_seed = random.randint(1, 999999999)
118
 
119
+ print(f"Origin image shape_0_: {original_shape} / {size_limit}")
120
  image = resize_max_size(image, size_limit=size_limit, interpolation=interpolation)
121
+ print(f"Resized image shape_1_: {image.shape}")
122
 
123
+ print(f"mask image shape_0_: {mask.shape} / {type(mask)}")
124
  mask = resize_max_size(mask, size_limit=size_limit, interpolation=interpolation)
125
+ print(f"mask image shape_1_: {mask.shape} / {type(mask)}")
126
 
127
  if model is None:
128
  return None