Spaces:
Build error
Build error
Sophie98
commited on
Commit
•
2ca996f
1
Parent(s):
c6213c8
try find error
Browse files- segmentation.py +4 -2
segmentation.py
CHANGED
@@ -33,16 +33,18 @@ def get_mask(image):
|
|
33 |
# compile keras model with defined optimozer, loss and metrics
|
34 |
model.compile(optim, total_loss, metrics)
|
35 |
|
|
|
36 |
#load model
|
37 |
model.load_weights(model_path)
|
38 |
|
39 |
-
|
40 |
test_img = np.array(image)#cv2.imread(path, cv2.IMREAD_COLOR)
|
41 |
test_img = cv2.resize(test_img, (640, 640))
|
42 |
test_img = cv2.cvtColor(test_img, cv2.COLOR_RGB2BGR)
|
43 |
test_img = np.expand_dims(test_img, axis=0)
|
44 |
|
45 |
-
prediction = model.predict(test_img).round()
|
|
|
46 |
mask = Image.fromarray(prediction[...,0].squeeze()*255).convert("L")
|
47 |
#mask.save("masks/sofa.jpg")
|
48 |
return np.array(mask)
|
|
|
33 |
# compile keras model with defined optimozer, loss and metrics
|
34 |
model.compile(optim, total_loss, metrics)
|
35 |
|
36 |
+
print('loading model weights')
|
37 |
#load model
|
38 |
model.load_weights(model_path)
|
39 |
|
40 |
+
print('processing image')
|
41 |
test_img = np.array(image)#cv2.imread(path, cv2.IMREAD_COLOR)
|
42 |
test_img = cv2.resize(test_img, (640, 640))
|
43 |
test_img = cv2.cvtColor(test_img, cv2.COLOR_RGB2BGR)
|
44 |
test_img = np.expand_dims(test_img, axis=0)
|
45 |
|
46 |
+
prediction = model.predict(preprocess_input(test_img)).round()
|
47 |
+
print("generated mask")
|
48 |
mask = Image.fromarray(prediction[...,0].squeeze()*255).convert("L")
|
49 |
#mask.save("masks/sofa.jpg")
|
50 |
return np.array(mask)
|