<jupyter_start><jupyter_text>For Lungs<jupyter_code>dataset = LandmarksDataset(train_lungs,
                           img_path = "../Chest-xray-landmark-dataset/Images",
                           label_path = "../Chest-xray-landmark-dataset/landmarks",
                           heart = False,
                           transform = transforms.Compose([
                                       RandomScale(),
                                       Rotate(3),
                                       AugColor(0.40),
                                       ToTensor()])
                           )
import matplotlib.pyplot as plt
from utils.utils import drawOrgans

sample = dataset[0]
landmarks = sample['landmarks']

RL = landmarks[:44] * 1024
LL = landmarks[44:94] * 1024
H = landmarks[94:] * 1024

drawOrgans(RL,LL,H, sample['image'][0,:,:])<jupyter_output><empty_output><jupyter_text>Running 100 times every landmark with random data augmentations, but without images<jupyter_code>from utils.datasetNoImages import LandmarksDataset, ToTensor, RandomScale, Rotate

dataset = LandmarksDataset(train_lungs,
                           img_path = "../Chest-xray-landmark-dataset/Images",
                           label_path = "../Chest-xray-landmark-dataset/landmarks",
                           heart = False,
                           transform = transforms.Compose([
                                       RandomScale(),
                                       Rotate(3),
                                       ToTensor()])
                           )
targets = []

for j in range(0, 100):
    print('\r',j+1,'of', 100, end='')
    for i in range(0, len(dataset.images)):   
        sample = dataset[i]

        target = sample['landmarks']
        target = target.reshape(1, -1).numpy()
        targets.append(target)
    

targets = np.concatenate(targets, axis = 0)
average = targets.mean(axis = 0).reshape(-1 ,2)

plt.imshow(np.zeros([1024,1024]))
plt.scatter(average[:,0] * 1024, average[:,1] * 1024)
plt.axis('off')
from sklearn.decomposition import PCA

pca = PCA(n_components=64)
pca.fit(targets)

components = pca.components_
np.save("models/lungs_pca_components.npy", components)

mean = pca.mean_
np.save("models/lungs_pca_mean.npy", mean)<jupyter_output><empty_output><jupyter_text>For lungs and heart<jupyter_code>from utils.dataset import LandmarksDataset, ToTensor, RandomScale, AugColor, Rotate

dataset = LandmarksDataset(train_heart,
                           img_path = "../Chest-xray-landmark-dataset/Images",
                           label_path = "../Chest-xray-landmark-dataset/landmarks",
                           heart = True,
                           transform = transforms.Compose([
                                       RandomScale(),
                                       Rotate(3),
                                       AugColor(0.40),
                                       ToTensor()])
                           )

sample = dataset[2]
landmarks = sample['landmarks']

RL = landmarks[:44] * 1024
LL = landmarks[44:94] * 1024
H = landmarks[94:] * 1024

drawOrgans(RL,LL,H, sample['image'][0,:,:])
from utils.datasetNoImages import LandmarksDataset, ToTensor, RandomScale, Rotate

dataset = LandmarksDataset(train_heart,
                           img_path = "../Chest-xray-landmark-dataset/Images",
                           label_path = "../Chest-xray-landmark-dataset/landmarks",
                           heart = True,
                           transform = transforms.Compose([
                                       RandomScale(),
                                       Rotate(3),
                                       ToTensor()])
                           )
targets = []

for j in range(0, 100):
    print('\r',j+1,'of', 100, end='')
    for i in range(0, len(dataset.images)):   
        sample = dataset[i]

        target = sample['landmarks']
        target = target.reshape(1, -1).numpy()
        targets.append(target)
    

targets = np.concatenate(targets, axis = 0)
average = targets.mean(axis = 0).reshape(-1 ,2)

plt.imshow(np.zeros([1024,1024]))
plt.scatter(average[:,0] * 1024, average[:,1] * 1024)
plt.axis('off')
from sklearn.decomposition import PCA

pca = PCA(n_components=64)
pca.fit(targets)

components = pca.components_
np.save("models/heart_pca_components.npy", components)

mean = pca.mean_
np.save("models/heart_pca_mean.npy", mean)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12063920774251632, 'fraction_numerical': 0.02858428989421562, 'mean_word_length': 1.748299319727891, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '634157', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 1386, 'n_tokens_neox': 1264, 'n_words': 229, 'path': 'getPCA.ipynb', 'repo_name': 'ngaggion/Chest-x-ray-Baselines', 'size': '4443'}