Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rahulremanan/180b719b1ca6578dfef9f4949997dfde to your computer and use it in GitHub Desktop.
Save rahulremanan/180b719b1ca6578dfef9f4949997dfde to your computer and use it in GitHub Desktop.
Build pairwise image comparisons using the Twitter saliency filter
clear_image_history(unzip_dir)
get_fairface_img(img_labels, img_idx1, unzip_dir, fairface_data)
get_fairface_img(img_labels, img_idx2, unzip_dir, fairface_data)
img_path = next(data_dir.glob("./*.jpg"))
print(img_path)
for img_file in data_dir.glob("./*.jpg"):
img = mpimg.imread(img_file)
plt.figure()
plt.imshow(img)
plt.gca().add_patch(
Rectangle((0, 0), 200, 112, linewidth=1, edgecolor="r", facecolor="none")
)
cmd = f"{str(bin_path)} {str(model_path)} '{img_path.absolute()}' show_all_points"
print(cmd)
output = subprocess.check_output(cmd, shell=True) # Success!
print(output.splitlines())
!{str(bin_path)} {str(model_path)} '{img_path.absolute()}' show_all_points | head
parse_output(output).keys()
model = ImageSaliencyModel(crop_binary_path=bin_path, crop_model_path=model_path)
print(plt.matplotlib.__version__)
print(list(data_dir.glob("./*.jpg")))
for img_path in data_dir.glob("*.jpg"):
print(img_path)
model.plot_img_crops(img_path)
for img_path in reservoir_sampling(data_dir.glob("./*.jpg"), K=5):
model.plot_img_crops(img_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment