def main(): print "Generating seam-removed images" data_path = 'val2014' search_ids = [26323, 441543, 575032, 440023] #26323, create_images = True create_annotation = False annotation_file = [] annotation_file_name = 'annotation.txt' save_path = 'test_data/merge_seam_data/simple_seam/' for id in search_ids: if create_images: path = os.path.join(data_path, 'COCO_val2014_' + str(id).zfill(12) + '.jpg') im = plt.imread(path) / 255. save_path = 'test_data/merge_seam_data/simple_seam/' im_prefix = 'COCO_val2014_' + str(id).zfill(12) remove_pixels = 100 snapshot_iter = 20 h_stack = seam_carve_h(im, remove_pixels, snapshot_iter, os.path.join(save_path, im_prefix)) v_stack = seam_carve_v(im, remove_pixels, snapshot_iter, os.path.join(save_path, im_prefix)) for i,im in enumerate(h_stack): print "Removing vertical seam from horizontal stack", i new_path = os.path.join(save_path, im_prefix + '_h_fuck_' + str((i+1) * snapshot_iter)) seam_carve_v(im, remove_pixels, snapshot_iter, new_path) if create_annotation: annotation_file.append(str(id)) for a in cocotools.find_annotation(id): annotation_file.append('\t' + a) if create_annotation: np.savetxt(os.path.join(save_path,annotation_file_name), annotation_file, delimiter=" ", fmt="%s") print "Done." return
def main(): search_ids = [29587, 29563] #Find the image id you decided to use data_path = 'val2014' for id in search_ids: path = os.path.join(data_path, 'COCO_val2014_' + str(id).zfill(12) + '.jpg') im = plt.imread(path) plt.imshow(im) print "Image ID :", id for a in cocotools.find_annotation(id): print a plt.show() return
def main(): print "Generating color-altered images" search_ids = [29587, 29563, 33900, 36477, 40881, 42526, 42507, 516239, 580757] data_path = 'val2014' save_path = 'test_data/color_data/simple_color/' annotation_file = [] annotation_file_name = 'annotation.txt' for id in search_ids: path = os.path.join(data_path, 'COCO_val2014_' + str(id).zfill(12) + '.jpg') im = plt.imread(path) annotation_file.append(str(id)) for a in cocotools.find_annotation(id): annotation_file.append('\t' + a) generate_all_color(im, os.path.join(save_path,'COCO_val2014_' + str(id).zfill(12))) np.savetxt(os.path.join(save_path,annotation_file_name), annotation_file, delimiter=" ", fmt="%s") print "Done." return
def main(): print "Generating color-altered images" search_ids = [29587, 29563, 33900, 36477, 40881, 42526, 42507, 516239, 580757] data_path = "val2014" save_path = "1/a" annotation_file = [] annotation_file_name = "annotation.txt" for id in search_ids: path = os.path.join(data_path, "COCO_val2014_" + str(id).zfill(12) + ".jpg") im = plt.imread(path) annotation_file.append(str(id)) for a in cocotools.find_annotation(id): annotation_file.append("\t" + a) generate_all_color(im, os.path.join(save_path, "COCO_val2014_" + str(id).zfill(12))) np.savetxt(os.path.join(save_path, annotation_file_name), annotation_file, delimiter=" ", fmt="%s") print "Done." return