Spaces:
Build error
Build error
Sophie98
commited on
Commit
•
f2e8e46
1
Parent(s):
74b763f
more testing
Browse files- app.py +3 -3
- segmentation.py +3 -2
app.py
CHANGED
@@ -98,8 +98,8 @@ def style_sofa(input_img: np.ndarray, style_img: np.ndarray):
|
|
98 |
resized_style = resize_style(style_img)
|
99 |
#resized_style.save('resized_style.jpg')
|
100 |
# generate mask for image
|
101 |
-
|
102 |
-
|
103 |
#mask.save('mask.jpg')
|
104 |
# Created a styled sofa
|
105 |
# print('Styling sofa...')
|
@@ -110,7 +110,7 @@ def style_sofa(input_img: np.ndarray, style_img: np.ndarray):
|
|
110 |
# new_sofa = replace_sofa(resized_img,mask,styled_sofa)
|
111 |
# new_sofa = new_sofa.crop(box)
|
112 |
print('Finishing job', id)
|
113 |
-
return
|
114 |
|
115 |
demo = gr.Interface(
|
116 |
style_sofa,
|
|
|
98 |
resized_style = resize_style(style_img)
|
99 |
#resized_style.save('resized_style.jpg')
|
100 |
# generate mask for image
|
101 |
+
print('generating mask...')
|
102 |
+
mask = get_mask(resized_img)
|
103 |
#mask.save('mask.jpg')
|
104 |
# Created a styled sofa
|
105 |
# print('Styling sofa...')
|
|
|
110 |
# new_sofa = replace_sofa(resized_img,mask,styled_sofa)
|
111 |
# new_sofa = new_sofa.crop(box)
|
112 |
print('Finishing job', id)
|
113 |
+
return mask
|
114 |
|
115 |
demo = gr.Interface(
|
116 |
style_sofa,
|
segmentation.py
CHANGED
@@ -6,6 +6,7 @@ import numpy as np
|
|
6 |
import matplotlib.pyplot as plt
|
7 |
from PIL import Image
|
8 |
import segmentation_models as sm
|
|
|
9 |
|
10 |
|
11 |
def get_mask(image:Image) -> Image:
|
@@ -27,7 +28,6 @@ def get_mask(image:Image) -> Image:
|
|
27 |
# in_classes = 1 if len(CLASSES) == 1 else (len(CLASSES) + 1) # case for binary and multiclass segmentation
|
28 |
# actvation = 'sigmoid' if n_classes == 1 else 'softmax'
|
29 |
preprocess_input = sm.get_preprocessing(BACKBONE)
|
30 |
-
sm.set_framework('tf.keras')
|
31 |
# LR=0.0001
|
32 |
|
33 |
#create model architecture
|
@@ -47,9 +47,10 @@ def get_mask(image:Image) -> Image:
|
|
47 |
# #load model
|
48 |
# model.load_weights(model_path)
|
49 |
model = keras.models.load_model('model_final.h5', compile=False)
|
50 |
-
|
51 |
test_img = np.array(image)#cv2.imread(path, cv2.IMREAD_COLOR)
|
52 |
test_img = cv2.resize(test_img, (640, 640))
|
|
|
53 |
test_img = cv2.cvtColor(test_img, cv2.COLOR_RGB2BGR)
|
54 |
test_img = np.expand_dims(test_img, axis=0)
|
55 |
|
|
|
6 |
import matplotlib.pyplot as plt
|
7 |
from PIL import Image
|
8 |
import segmentation_models as sm
|
9 |
+
sm.set_framework('tf.keras')
|
10 |
|
11 |
|
12 |
def get_mask(image:Image) -> Image:
|
|
|
28 |
# in_classes = 1 if len(CLASSES) == 1 else (len(CLASSES) + 1) # case for binary and multiclass segmentation
|
29 |
# actvation = 'sigmoid' if n_classes == 1 else 'softmax'
|
30 |
preprocess_input = sm.get_preprocessing(BACKBONE)
|
|
|
31 |
# LR=0.0001
|
32 |
|
33 |
#create model architecture
|
|
|
47 |
# #load model
|
48 |
# model.load_weights(model_path)
|
49 |
model = keras.models.load_model('model_final.h5', compile=False)
|
50 |
+
|
51 |
test_img = np.array(image)#cv2.imread(path, cv2.IMREAD_COLOR)
|
52 |
test_img = cv2.resize(test_img, (640, 640))
|
53 |
+
return test_img
|
54 |
test_img = cv2.cvtColor(test_img, cv2.COLOR_RGB2BGR)
|
55 |
test_img = np.expand_dims(test_img, axis=0)
|
56 |
|