Commit f8b66c6a authored by pawel rosikiewicz's avatar pawel rosikiewicz 💬
Browse files

adding firts analyses, and EDA plots

parent 0c6aedfe
Pipeline #187636 passed with stage
in 27 seconds
This diff is collapsed.
......@@ -34,7 +34,7 @@
TFHUB_MODELS = {
"MobileNet_v2": {
"module_name": "MobileNet_v2",
"working_name": "mobilenet",
"working_name": "MobileNet_v2",
"file_name": "imagenet_mobilenet_v2_100_224_feature_vector_2",
"module_url": "https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/feature_vector/2",
"input_size":(224, 224),
......@@ -43,7 +43,7 @@ TFHUB_MODELS = {
},
"BiT_M_Resnet101":{
"module_name": "BiT_M_Resnet101",
"working_name": "resnet",
"working_name": "BiT_M_Resnet101",
"file_name": "bit_m-r101x1_1",
"module_url":"https://tfhub.dev/google/bit/m-r101x1/1",
"input_size": (224, 224),
......
......@@ -65,7 +65,9 @@ def cluster_images_and_plot_examples(*,
max_pie_nr = 7,
n_img_examples =100 ,
max_img_per_col = 10,
figsize_scaling = 1.5
figsize_scaling = 1.5,
extracted_features_file_ext = "extracted_beta_features"
):
'''
Function that creates 4 plots
......@@ -108,7 +110,7 @@ def cluster_images_and_plot_examples(*,
# paths
'''extracted features, and labels are loaded using logfiles created while extracting features'''
path_raw_images_and_log_files = os.path.join(path, f"{dataset_name}__{dataset_variant}")
path_extracted_features = os.path.join(path, f"{dataset_name}__{dataset_variant}__extracted_features")
path_extracted_features = os.path.join(path, f"{dataset_name}__{dataset_variant}__{extracted_features_file_ext}")
# ...............................................
......@@ -150,7 +152,7 @@ def cluster_images_and_plot_examples(*,
# -- preparing data for plots No2 & 3 --
# prepare lists with classnames and clusternames for annotated pie charts,
img_classnames, img_groupnames = prepare_img_classname_and_groupname(
data_for_plot = clustering_results[module_name],
......@@ -205,6 +207,7 @@ def cluster_images_and_plot_examples(*,
)
......@@ -218,9 +221,10 @@ def pca_analysis_on_plots(*,
module_names,
class_labels_configs,
pca_figsize = (12,4), # tuple (row lengh, row height)
pca_axes_max_nr = 250,
pca_axes_max_nr = 50,
verbose = False,
scale_data = False
scale_data = False,
extracted_features_file_ext = "extracted_beta_features"
):
'''
......@@ -267,7 +271,7 @@ def pca_analysis_on_plots(*,
# paths
'''extracted features, and labels are loaded using logfiles created while extracting features'''
path_raw_images_and_log_files = os.path.join(path, f"{dataset_name}__{dataset_variant}")
path_extracted_features = os.path.join(path, f"{dataset_name}__{dataset_variant}__extracted_features")
path_extracted_features = os.path.join(path, f"{dataset_name}__{dataset_variant}__{extracted_features_file_ext}")
# pca plot and analysis for the two remaining plots,
pca_models_dict = pca_analyis_with_plots(
......@@ -355,7 +359,8 @@ def plot_n_image_examples(*,
font_scaling = 1, # float, affects size of title and lenged font,
legend_pos_to_left =0, # float, fraction of the image total size, will be added to horozontal position of the center of the legend,
max_img_per_col=None, # int, or None, how many images will be displayed max, on each column, then less, then wider is the image, None is automatic
class_colors_cmap = "tab20" # str, used to create unique colors for each class, not used if class_labels_colors is provided
class_colors_cmap = "tab20", # str, used to create unique colors for each class, not used if class_labels_colors is provided
extracted_features_file_ext = "extracted_beta_features"
):
'''
......@@ -426,7 +431,7 @@ def plot_n_image_examples(*,
# path in FastClassAI pipeline
if batch_labels_path==None:
batch_labels_path=os.path.join(path, f"{dataset_name}__{dataset_variant}__extracted_features")
batch_labels_path=os.path.join(path, f"{dataset_name}__{dataset_variant}__{extracted_features_file_ext}")
else:
pass
......@@ -594,7 +599,9 @@ def annotated_piecharts_with_subset_class_composition(*,
# class colors,
class_colors_cmap = "Greens",
cmap_colors_from = 0.4, # so it doent starts with white color!
cmap_colors_to = 1
cmap_colors_to = 1,
extracted_features_file_ext = "extracted_beta_features"
):
'''
FastClassAI pipeline function, creates annotated pie charts showing class and file/image number and %
......@@ -673,7 +680,7 @@ def annotated_piecharts_with_subset_class_composition(*,
# / plot each subset separately /
# go to dir with file labels created when extracting (FastClassAI pipeline)
os.chdir(os.path.join(path, f"{dataset_name}__{dataset_variant}__extracted_features"))
os.chdir(os.path.join(path, f"{dataset_name}__{dataset_variant}__{extracted_features_file_ext}"))
# collect the data for each subset
for sn_i, (one_displayed_subset_name, one_subset_name) in enumerate(zip(displayed_subset_names,subset_names)):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment