Sophie98 commited on
Commit
71893b8
1 Parent(s): 1ab9bc0

fixing error?

Browse files
Files changed (3) hide show
  1. app.py +1 -0
  2. segmentation.py +4 -0
  3. styleTransfer.py +0 -2
app.py CHANGED
@@ -22,6 +22,7 @@ def style_sofa(input_img: np.ndarray, style_img: np.ndarray):
22
  # generate mask for image
23
  mask = get_mask(resized_img)
24
  styled_sofa = create_styledSofa(resized_img,resized_style)
 
25
  new_sofa = replace_sofa(resized_img,mask,styled_sofa)
26
  return new_sofa
27
 
 
22
  # generate mask for image
23
  mask = get_mask(resized_img)
24
  styled_sofa = create_styledSofa(resized_img,resized_style)
25
+ print('Created styled image')
26
  new_sofa = replace_sofa(resized_img,mask,styled_sofa)
27
  return new_sofa
28
 
segmentation.py CHANGED
@@ -51,14 +51,18 @@ def replace_sofa(image,mask,styled_sofa):
51
  # print(mask.shape)
52
  # mask = cv2.cvtColor(mask, cv2.COLOR_BGR2GRAY)
53
  # print(mask.shape)
 
54
  image = np.array(image)
55
  #image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
56
  styled_sofa = cv2.cvtColor(styled_sofa, cv2.COLOR_BGR2RGB)
57
 
 
58
  _, mask = cv2.threshold(mask, 10, 255, cv2.THRESH_BINARY)
59
  mask_inv = cv2.bitwise_not(mask)
 
60
  image_bg = cv2.bitwise_and(image,image,mask = mask_inv)
61
  sofa_fg = cv2.bitwise_and(styled_sofa,styled_sofa,mask = mask)
 
62
  new_image = cv2.add(image_bg,sofa_fg)
63
  return new_image
64
 
 
51
  # print(mask.shape)
52
  # mask = cv2.cvtColor(mask, cv2.COLOR_BGR2GRAY)
53
  # print(mask.shape)
54
+ print('started function')
55
  image = np.array(image)
56
  #image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
57
  styled_sofa = cv2.cvtColor(styled_sofa, cv2.COLOR_BGR2RGB)
58
 
59
+ print('reading masks')
60
  _, mask = cv2.threshold(mask, 10, 255, cv2.THRESH_BINARY)
61
  mask_inv = cv2.bitwise_not(mask)
62
+ print('creating parts')
63
  image_bg = cv2.bitwise_and(image,image,mask = mask_inv)
64
  sofa_fg = cv2.bitwise_and(styled_sofa,styled_sofa,mask = mask)
65
+ print('combining parts')
66
  new_image = cv2.add(image_bg,sofa_fg)
67
  return new_image
68
 
styleTransfer.py CHANGED
@@ -57,8 +57,6 @@ def create_styledSofa(sofa,style):
57
  path_sofa,path_style = 'sofa.jpg','style.jpg'
58
  sofa.save(path_sofa)
59
  style.save(path_style)
60
- #newpath_sofa = resize_sofa(path_sofa)
61
- #newpath_style = resize_style(path_style)
62
  os.system("python3 test.py --content "+path_sofa+" \
63
  --style "+path_style+" \
64
  --output . \
 
57
  path_sofa,path_style = 'sofa.jpg','style.jpg'
58
  sofa.save(path_sofa)
59
  style.save(path_style)
 
 
60
  os.system("python3 test.py --content "+path_sofa+" \
61
  --style "+path_style+" \
62
  --output . \