13: ("Pulmonary fibrosis", "#e75480"), 14: ("No finding", "#ffffff") } # %% -------------------- # IMAGE DIR img_dir = "D:/GWU/4 Spring 2021/6501 Capstone/VBD CXR/PyCharm " \ "Workspace/vbd_cxr/9_data/512/transformed_data/train" # %% -------------------- # ANNOTATION DIR train_data = pd.read_csv( "D:/GWU/4 Spring 2021/6501 Capstone/VBD CXR/PyCharm " "Workspace/vbd_cxr/1_merger/wbf_merged/90_percent_train/object_detection/95_percent" "/80_percent/train_df_0.csv") # %% -------------------- # image_ids = train_data["image_id"].unique() image_ids = ["e1a4353d3e747a7150cb06cac73f4d6f"] # shuffle is inplace operation random.shuffle(image_ids) for img in image_ids[:10]: img_array = get_image_as_array(f"{img_dir}/{img}.jpeg") # get bounding box info img_bb_info = get_bb_info(train_data, img, ['x_min', 'y_min', 'x_max', 'y_max', "class_id"]) # plot image with bounding boxes bounding_box_plotter(img_array, img, img_bb_info, label2color, save_title_or_plot="plot")
gt = pd.read_csv( "D:/GWU/4 Spring 2021/6501 Capstone/VBD CXR/PyCharm Workspace/vbd_cxr/2_data_split/512/unmerged/10_percent_holdout/holdout_df.csv" ) predictions = pd.read_csv( "D:/GWU/4 Spring 2021/6501 Capstone/VBD CXR/PyCharm Workspace/vbd_cxr/5_inference_on_holdout_10_percent/0_predictions/holdout_ensemble_classification_object_detection.csv" ) # %% -------------------- label2color = get_label_2_color_dict() # %% -------------------- original_image_ids = gt["image_id"].unique() # %% -------------------- for image_id in original_image_ids[:10]: img_as_arr = get_image_as_array( f"D:/GWU/4 Spring 2021/6501 Capstone/VBD CXR/PyCharm Workspace/vbd_cxr/input_data/512x512/train/{image_id}.png" ) # %% -------------------- left = get_bb_info(gt, image_id, ['x_min', 'y_min', 'x_max', 'y_max', "class_id"]) right = get_bb_info(predictions, image_id, ['x_min', 'y_min', 'x_max', 'y_max', "label"]) # %% -------------------- bounding_box_plotter_side_to_side(img_as_arr, image_id, left, right, "Ground Truth", "Predictions", label2color)
# %% -------------------- gt = pd.read_csv( f"{BASE_DIR}/2_data_split/512/unmerged/10_percent_holdout/holdout_df.csv") predictions = pd.read_csv( f"{BASE_DIR}/5_inference_on_holdout_10_percent/0_predictions/holdout_ensemble_classification_object_detection.csv" ) # %% -------------------- label2color = get_label_2_color_dict() # %% -------------------- original_image_ids = gt["image_id"].unique() # %% -------------------- for image_id in original_image_ids[0:20]: img_as_arr = get_image_as_array( f"{BASE_DIR}/input_data/512x512/train/{image_id}.png") # %% -------------------- left = get_bb_info(gt, image_id, ['x_min', 'y_min', 'x_max', 'y_max', "class_id"]) right = get_bb_info(predictions, image_id, ['x_min', 'y_min', 'x_max', 'y_max', "label"]) # %% -------------------- bounding_box_plotter_side_to_side(img_as_arr, image_id, left, right, "Ground Truth", "Predictions", label2color)
# %% -------------------- train_data = pd.read_csv("/transformed_data/transformed_train.csv") # %% -------------------- train_data.head() # %% -------------------- train_data.columns # %% -------------------- # img = "9a5094b2563a1ef3ff50dc5c7ff71345" img = "001d127bad87592efe45a5c7678f8b8d" # %% -------------------- img_array = get_image_as_array(f"{train_dir_path}/{img}.jpeg") # %% -------------------- # plot original image plot_img(img_array, "Original") # %% -------------------- # get bounding box info img_bb_info = get_bb_info(train_data, img, ['x_min', 'y_min', 'x_max', 'y_max', "class_id"]) # %% -------------------- # plot image with bounding boxes bounding_box_plotter(img_array, img, img_bb_info, label2color) # %% --------------------
# %% -------------------- import matplotlib.pyplot as plt import numpy as np from skimage import exposure from common.utilities import get_image_as_array # %% -------------------- img = get_image_as_array( 'D:/GWU/4 Spring 2021/6501 Capstone/VBD CXR/PyCharm ' 'Workspace/vbd_cxr/9_data/512/transformed_data/train/0c4a6bc602d1d207f217212c68a7131b.jpeg' ) img = np.asarray(img) plt.figure(figsize=(12, 12)) plt.imshow(img, 'gray') plt.show() # %% -------------------- img_hist = exposure.equalize_hist(img) plt.figure(figsize=(12, 12)) plt.imshow(img_hist, 'gray') plt.show() # %% -------------------- img_clahe = exposure.equalize_adapthist(img / np.max(img)) plt.figure(figsize=(12, 12)) plt.imshow(img_clahe, 'gray') plt.show()