text_html_output_1.png
from pathlib import Path

from tqdm import tqdm

import pandas as pd

path_working_dir = Path().resolve()
path_input_nih = (path_working_dir / f'../input/data').resolve()
path_input_alias = (path_working_dir / f'./alias').resolve()
path_input_model = (path_working_dir / f'../input/nih-chest-xrays-trained-models').resolve()

df_input_all = pd.read_csv(path_input_nih / 'Data_Entry_2017.csv')
df_input_all['Finding Labels'] = df_input_all['Finding Labels'].str.replace('No Finding', '')
df_list_train = pd.read_csv(path_input_nih / 'train_val_list.txt', header=None)
df_list_valid = pd.read_csv(path_input_nih / 'test_list.txt', header=None)
list_all = df_input_all['Image Index'].tolist()
list_train = df_list_train[0].tolist()
list_valid = df_list_valid[0].tolist()
list_idx_train = [True if fname in list_train else False for fname in tqdm(list_all)]
list_idx_valid = [True if fname in list_valid else False for fname in tqdm(list_all)]
list_classes = sorted([target for target in set(df_input_all['Finding Labels'].tolist()) if not '|' in target and target != ''])
df_input_train = df_input_all[list_idx_train].reset_index(drop=True)[['Image Index', 'Finding Labels']]
df_input_valid = df_input_all[list_idx_valid].reset_index(drop=True)[['Image Index', 'Finding Labels']]
df_input_merge = pd.concat([df_input_train, df_input_valid]).reset_index(drop=True)