I start my model and get a mask prediction of the area I would like to crop.
img = cv2.imread('picture.jpg')
img = cv2.resize(img, (224, 224))
print(img.shape)
T = np.zeros((1, 224, 224, 3), dtype='float32')
T[0]=img
prediction = model.predict(T , verbose=1)
prediction = prediction[0, :, : , :]
plt.imshow(img)
plt.show()
print(prediction.shape)
plt.imshow(np.squeeze(prediction).astype(np.float32))
plt.show()
This code is the closest I have gotten to the desired image, the problem with this image that is provided is that it doesn't crop out black background
result = prediction * img
plt.imshow((result/255).astype(np.float32))
plt.show()