diff --git a/README.md b/README.md index c8b30c2efd9b6581b6e792892e909f9701bac089..81bcdc4eab586059e65af7ed7bec31a692b74696 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ by *Oriane Siméoni, Gilles Puy, Huy V. Vo, Simon Roburin, Spyros Gidaris, Andre <div> <img width="25%" alt="LOST visualizations" src="examples/LOST_ex0.png"> <img width="31%" alt="LOST visualizations" src="examples/LOST_ex1.png"> + <img width="27%" alt="LOST visualizations" src="examples/LOST_ex2.png"> </div> diff --git a/examples/LOST_ex0.png b/examples/LOST_ex0.png old mode 100755 new mode 100644 index 72c0fc4ca9e53f9865e29abd61e0ec950829745a..e602f8d94282df97089371417c75ce7e9008b836 Binary files a/examples/LOST_ex0.png and b/examples/LOST_ex0.png differ diff --git a/examples/LOST_ex1.png b/examples/LOST_ex1.png old mode 100755 new mode 100644 index b06970cd690e979b680036d3c70916f0c3f4b825..2d9ad20392d88e88db59210a72737706cde07ac1 Binary files a/examples/LOST_ex1.png and b/examples/LOST_ex1.png differ diff --git a/examples/LOST_ex2.png b/examples/LOST_ex2.png new file mode 100644 index 0000000000000000000000000000000000000000..b1338cb736c231b29424393eb0fe092e7cf83450 Binary files /dev/null and b/examples/LOST_ex2.png differ diff --git a/visualizations.py b/visualizations.py index f1f1bd3073c63e7aa0a86b8ae6da16789cc75344..5ee43d01c5cec2f22f62491b76426a2e45f23886 100755 --- a/visualizations.py +++ b/visualizations.py @@ -7,7 +7,7 @@ from PIL import Image import matplotlib.pyplot as plt -def visualize_predictions(image, pred, seed, scales, dims, vis_folder, im_name): +def visualize_predictions(image, pred, seed, scales, dims, vis_folder, im_name, plot_seed=False): """ Visualization of the predicted box and the corresponding seed patch. """ @@ -18,18 +18,19 @@ def visualize_predictions(image, pred, seed, scales, dims, vis_folder, im_name): image, (int(pred[0]), int(pred[1])), (int(pred[2]), int(pred[3])), - (255, 0, 0), 2, + (255, 0, 0), 3, ) # Plot the seed - s_ = np.unravel_index(seed.cpu().numpy(), (w_featmap, h_featmap)) - size_ = np.asarray(scales) / 2 - cv2.rectangle( - image, - (int(s_[1] * scales[1] - (size_[1] / 2)), int(s_[0] * scales[0] - (size_[0] / 2))), - (int(s_[1] * scales[1] + (size_[1] / 2)), int(s_[0] * scales[0] + (size_[0] / 2))), - (0, 255, 0), -1, - ) + if plot_seed: + s_ = np.unravel_index(seed.cpu().numpy(), (w_featmap, h_featmap)) + size_ = np.asarray(scales) / 2 + cv2.rectangle( + image, + (int(s_[1] * scales[1] - (size_[1] / 2)), int(s_[0] * scales[0] - (size_[0] / 2))), + (int(s_[1] * scales[1] + (size_[1] / 2)), int(s_[0] * scales[0] + (size_[0] / 2))), + (0, 255, 0), -1, + ) pltname = f"{vis_folder}/LOST_{im_name}.png" Image.fromarray(image).save(pltname)