ai.vietqt commited on
Commit
baae5a2
·
1 Parent(s): a38df50
Files changed (3) hide show
  1. app.py +8 -7
  2. metrics.py +6 -1
  3. utils_func.py +1 -1
app.py CHANGED
@@ -5,6 +5,7 @@ from utils_func import create_dir, main_processing
5
 
6
  create_dir("tempDir")
7
 
 
8
  def load_image(image_file):
9
  img = Image.open(image_file)
10
  return img
@@ -36,7 +37,7 @@ def streamlit_app():
36
  col1, col2, col3 = st.columns(3)
37
  with col1:
38
  st.image(image, caption="Image before processing")
39
- save_path = "tempDir\\"+ image_file.name
40
  image.save(save_path)
41
 
42
 
@@ -64,7 +65,7 @@ def streamlit_app():
64
  st.write('\n')
65
  st.write('\n')
66
 
67
- file_name = final_img_path.split("\\")[-1].split(".")[-2]
68
  if st.download_button(
69
  label="Download postprocessing image",
70
  data=file,
@@ -80,12 +81,12 @@ if __name__ == '__main__':
80
  tf.random.set_seed(42)
81
 
82
  bg_path = ""
83
- background_model_path = "weight_files\\model.h5"
84
- detection_model_path = "weight_files\\clothes_detection_model.pt"
85
 
86
- stadium_sport_bg_path = "backgrounds\\camnou_stadium.jpg"
87
- beach_swim_bg_path = "backgrounds\\beach.jpg"
88
- office_bg_path = "backgrounds\\office-bg.jpg"
89
 
90
  image_path = None
91
 
 
5
 
6
  create_dir("tempDir")
7
 
8
+
9
  def load_image(image_file):
10
  img = Image.open(image_file)
11
  return img
 
37
  col1, col2, col3 = st.columns(3)
38
  with col1:
39
  st.image(image, caption="Image before processing")
40
+ save_path = "tempDir/"+ image_file.name
41
  image.save(save_path)
42
 
43
 
 
65
  st.write('\n')
66
  st.write('\n')
67
 
68
+ file_name = save_path.split("/")[-1].split(".")[-2] +"_from_abc" + ".png"
69
  if st.download_button(
70
  label="Download postprocessing image",
71
  data=file,
 
81
  tf.random.set_seed(42)
82
 
83
  bg_path = ""
84
+ background_model_path = "weight_files/model.h5"
85
+ detection_model_path = "weight_files/clothes_detection_model.pt"
86
 
87
+ stadium_sport_bg_path = "backgrounds/camnou_stadium.jpg"
88
+ beach_swim_bg_path = "backgrounds/beach.jpg"
89
+ office_bg_path = "backgrounds/office-bg.jpg"
90
 
91
  image_path = None
92
 
metrics.py CHANGED
@@ -1,5 +1,8 @@
1
  from libs import *
2
 
 
 
 
3
  def iou(y_true, y_pred):
4
  def f(y_true, y_pred):
5
  intersection = (y_true * y_pred).sum()
@@ -9,12 +12,14 @@ def iou(y_true, y_pred):
9
  return x
10
  return tf.numpy_function(f, [y_true, y_pred], tf.float32)
11
 
12
- smooth = 1e-15
 
13
  def dice_coef(y_true, y_pred):
14
  y_true = tf.keras.layers.Flatten()(y_true)
15
  y_pred = tf.keras.layers.Flatten()(y_pred)
16
  intersection = tf.reduce_sum(y_true * y_pred)
17
  return (2. * intersection + smooth) / (tf.reduce_sum(y_true) + tf.reduce_sum(y_pred) + smooth)
18
 
 
19
  def dice_loss(y_true, y_pred):
20
  return 1.0 - dice_coef(y_true, y_pred)
 
1
  from libs import *
2
 
3
+ smooth = 1e-15
4
+
5
+
6
  def iou(y_true, y_pred):
7
  def f(y_true, y_pred):
8
  intersection = (y_true * y_pred).sum()
 
12
  return x
13
  return tf.numpy_function(f, [y_true, y_pred], tf.float32)
14
 
15
+
16
+
17
  def dice_coef(y_true, y_pred):
18
  y_true = tf.keras.layers.Flatten()(y_true)
19
  y_pred = tf.keras.layers.Flatten()(y_pred)
20
  intersection = tf.reduce_sum(y_true * y_pred)
21
  return (2. * intersection + smooth) / (tf.reduce_sum(y_true) + tf.reduce_sum(y_pred) + smooth)
22
 
23
+
24
  def dice_loss(y_true, y_pred):
25
  return 1.0 - dice_coef(y_true, y_pred)
utils_func.py CHANGED
@@ -36,7 +36,7 @@ def choose_background(col1, col2, col3):
36
 
37
  bg_image = load_image(background_file)
38
  print(type(bg_image))
39
- save_path = "backgrounds\\" + background_file.name
40
  bg_image.save(save_path)
41
 
42
  return bg_image, save_path
 
36
 
37
  bg_image = load_image(background_file)
38
  print(type(bg_image))
39
+ save_path = "backgrounds/" + background_file.name
40
  bg_image.save(save_path)
41
 
42
  return bg_image, save_path