anindya-hf-2002 commited on
Commit
65eeb0e
·
verified ·
1 Parent(s): 3f2d886

upload application files

Browse files
main.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+
4
+ from src.inference import load_classifier, load_model, generate_images, convert_into_image, classify_image
5
+ from src.models import ResUNetGenerator
6
+ from src.explainer import GradCAM, preprocess_image
7
+
8
+ # Loading Models
9
+ classifier_path = 'models\\efficientnet_b1-epoch16-val_loss0.46_ft.ckpt'
10
+ g_NP_checkpoint = 'models\\g_NP_best.ckpt'
11
+ g_PN_checkpoint = 'models\\g_PN_best.ckpt'
12
+ g_NP = load_model(g_NP_checkpoint, ResUNetGenerator(gf=32, channels=1))
13
+ g_PN = load_model(g_PN_checkpoint, ResUNetGenerator(gf=32, channels=1))
14
+ classifier = load_classifier(classifier_path)
15
+ target_layer = classifier.model.features[-1]
16
+ grad_cam = GradCAM(classifier, target_layer)
17
+
18
+
19
+ def counterfactual_generation(input_image):
20
+
21
+ translated_images, recon_images = generate_images(input_image, classifier, g_PN, g_NP)
22
+ translated_images = convert_into_image(translated_images)
23
+ recon_images = convert_into_image(recon_images)
24
+ return translated_images, recon_images
25
+
26
+ def image_classification(input_image):
27
+
28
+ result, target_class = classify_image(input_image, classifier=classifier)
29
+ input_tensor = preprocess_image(input_image)
30
+ cam = grad_cam.generate_cam(input_tensor, target_class)
31
+ cam_image = grad_cam.visualize_cam(cam, input_tensor)
32
+
33
+ return result, cam_image
34
+
35
+ # Defining the components
36
+ inputs1 = gr.Image(type="pil", format="png")
37
+ inputs2 = gr.Image(type="pil", format="png")
38
+ outputs1 = [gr.Image(type="pil", label="Translated Images", format="png"),
39
+ gr.Image(type="pil", label="Reconstructed Images", format="png")]
40
+
41
+ outputs2 = [gr.Label(label="Classification Result"), gr.Image(label="Grad-CAM", format="png")]
42
+
43
+ with gr.Blocks() as demo:
44
+ with gr.Tab("Counterfactual Generation"):
45
+ app1 = gr.Interface(fn=counterfactual_generation, inputs=inputs1, outputs=outputs1,
46
+ title="Counterfactual Image Generation", allow_flagging="never",
47
+ description="Generate counterfactual images to explain the classifier's decisions.")
48
+
49
+ with gr.Tab("Classification"):
50
+ app2 = gr.Interface(fn=image_classification, inputs=inputs2, outputs=outputs2,
51
+ title="Image Classification", allow_flagging="never",
52
+ description="Classify the input medical image and visualize Grad-CAM.")
53
+
54
+ # Launch the app
55
+ demo.launch(share=True)
models/cyclegan-epoch_epoch=38-vloss_val_generator_loss=1.64.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b2ed3c9f3a16222af626977aff6fc9763bf2862a56ea1475c41e783d56942f92
3
+ size 110015900
models/efficientnet_b1-epoch16-val_loss0.46_ft.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3bba6f1e551baa0a91c6fa4d824d87ba12bcbcce27def144d05318f4cbbbb67c
3
+ size 78886204
models/g_NP_best.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5e4d7a90fbdd5adda11834b6496cad111cfb3a81d6cf347dfd2fb48373e75e1b
3
+ size 6537396
models/g_PN_best.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f1374c46226207f31ccf078e8bfaafdc299ed10a1b9de154a865f74b57d22387
3
+ size 6537396
requirements.txt ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ pydicom
2
+ wandb
3
+ torchsummary
4
+ torchvision
5
+ torchmetrics
6
+ lightning==2.2.3
7
+ pillow
8
+ matplotlib
9
+ pandas
10
+ numpy
11
+ gradio
src/__pycache__/classifier.cpython-311.pyc ADDED
Binary file (5.04 kB). View file
 
src/__pycache__/config.cpython-311.pyc ADDED
Binary file (513 Bytes). View file
 
src/__pycache__/dataset.cpython-311.pyc ADDED
Binary file (5.21 kB). View file
 
src/__pycache__/explainer.cpython-311.pyc ADDED
Binary file (4.48 kB). View file
 
src/__pycache__/inference.cpython-311.pyc ADDED
Binary file (5 kB). View file
 
src/__pycache__/models.cpython-311.pyc ADDED
Binary file (26.9 kB). View file
 
src/__pycache__/train.cpython-311.pyc ADDED
Binary file (4.3 kB). View file
 
src/classifier.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import torch.nn as nn
3
+ import lightning as pl
4
+ import torchvision.models as models
5
+ from torchmetrics import Accuracy
6
+
7
+
8
+ class Classifier(pl.LightningModule):
9
+ def __init__(self, transfer=True):
10
+ super(Classifier, self).__init__()
11
+ self.conv = nn.Conv2d(1, 3, kernel_size=3, stride=1, padding=1) # Adjust input channels to 3
12
+ self.model = models.efficientnet_b1(weights='IMAGENET1K_V1')
13
+ if transfer:
14
+ # layers are frozen by using eval()
15
+ self.model.eval()
16
+ # freeze params
17
+ for p in self.model.parameters() :
18
+ p.requires_grad = False
19
+ num_ftrs = 1280
20
+ self.model.classifier = nn.Sequential(
21
+ nn.LeakyReLU(),
22
+ nn.Dropout(p=0.3),
23
+ nn.Linear(in_features=num_ftrs , out_features=2),
24
+ nn.Softmax(dim=1)
25
+ )
26
+
27
+ self.criterion = nn.CrossEntropyLoss()
28
+ self.train_accuracy = Accuracy(task='binary')
29
+ self.val_accuracy = Accuracy(task='binary')
30
+
31
+ def forward(self, x):
32
+ x = self.conv(x)
33
+ return self.model(x)
34
+
35
+ def training_step(self, batch, batch_idx):
36
+ images, labels = batch
37
+ outputs = self(images)
38
+ loss = self.criterion(outputs, labels)
39
+ self.log('train_loss', loss, prog_bar=True, on_epoch=True, on_step=True)
40
+ # Calculate and log accuracy
41
+ _, preds = torch.max(outputs, 1)
42
+ acc = self.train_accuracy(preds, labels)
43
+ self.log('train_acc', acc, prog_bar=True, on_step=True, on_epoch=True)
44
+ return loss
45
+
46
+ def validation_step(self, batch, batch_idx):
47
+ images, labels = batch
48
+ outputs = self(images)
49
+ loss = self.criterion(outputs, labels)
50
+ self.log('val_loss', loss, prog_bar=True, sync_dist=True)
51
+ # Calculate and log accuracy
52
+ _, preds = torch.max(outputs, 1)
53
+ acc = self.val_accuracy(preds, labels)
54
+ self.log('val_acc', acc, prog_bar=True, sync_dist=True)
55
+ return loss
56
+
57
+ def on_train_epoch_end(self):
58
+ self.train_accuracy.reset()
59
+
60
+ def on_validation_epoch_end(self):
61
+ self.val_accuracy.reset()
62
+
63
+ def configure_optimizers(self):
64
+ optimizer = torch.optim.Adam(self.parameters(), lr=0.0001)
65
+ scheduler = torch.optim.lr_scheduler.ReduceLROnPlateau(optimizer, mode='min', factor=0.2, patience=5, verbose=True)
66
+ return {
67
+ 'optimizer': optimizer,
68
+ 'lr_scheduler': {
69
+ 'scheduler': scheduler,
70
+ 'monitor': 'val_loss',
71
+ },
72
+ 'monitor': 'val_loss'
73
+ }
src/config.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ class CFG:
2
+ GAN_FILTERS = 32
3
+ DIS_FILTERS = 64
src/dataset.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from PIL import Image
2
+ from torch.utils.data import Dataset
3
+ from torchvision import transforms
4
+ import os
5
+
6
+ class ClassifierDataset(Dataset):
7
+ def __init__(self, root_dir, transform=None):
8
+ self.root_dir = root_dir
9
+ self.transform = transform
10
+
11
+ self.classes = ['0', '1']
12
+ self.class_to_idx = {cls: idx for idx, cls in enumerate(self.classes)}
13
+
14
+ self.samples = self._make_dataset()
15
+
16
+ def _make_dataset(self):
17
+ samples = []
18
+ for class_name in self.classes:
19
+ class_dir = os.path.join(self.root_dir, class_name)
20
+ for img_name in os.listdir(class_dir):
21
+ img_path = os.path.join(class_dir, img_name)
22
+ samples.append((img_path, self.class_to_idx[class_name]))
23
+ return samples
24
+
25
+ def __len__(self):
26
+ return len(self.samples)
27
+
28
+ def __getitem__(self, idx):
29
+ img_path, label = self.samples[idx]
30
+ img = Image.open(img_path).convert('L') # Convert to grayscale
31
+ if self.transform:
32
+ img = self.transform(img)
33
+ return img, label
34
+
35
+
36
+
37
+ class CustomDataset(Dataset):
38
+ def __init__(self, root_dir, train_N, train_P, img_res):
39
+ self.root_dir = root_dir
40
+ self.train_N = train_N
41
+ self.train_P = train_P
42
+ self.img_res = img_res
43
+ self.transforms = transforms.Compose([
44
+ transforms.Resize(img_res),
45
+ transforms.ToTensor(),
46
+ transforms.Normalize(mean=[0.5], std=[0.5]) # Assuming grayscale images
47
+ ])
48
+
49
+ def __len__(self):
50
+ return min(len(os.listdir(os.path.join(self.root_dir, self.train_N))),
51
+ len(os.listdir(os.path.join(self.root_dir, self.train_P))))
52
+
53
+ def __getitem__(self, idx):
54
+ normal_path = os.path.join(self.root_dir, self.train_N, os.listdir(os.path.join(self.root_dir, self.train_N))[idx])
55
+ pneumo_path = os.path.join(self.root_dir, self.train_P, os.listdir(os.path.join(self.root_dir, self.train_P))[idx])
56
+
57
+ normal_img = Image.open(normal_path).convert("L") # Load as grayscale
58
+ pneumo_img = Image.open(pneumo_path).convert("L") # Load as grayscale
59
+
60
+ normal_img = self.transforms(normal_img)
61
+ pneumo_img = self.transforms(pneumo_img)
62
+
63
+ return normal_img, pneumo_img
64
+
65
+
src/explainer.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import cv2
3
+ import torchvision.transforms as transforms
4
+
5
+
6
+ class GradCAM:
7
+ def __init__(self, model, target_layer):
8
+ self.model = model
9
+ self.target_layer = target_layer
10
+ self.gradients = None
11
+ self.activations = None
12
+ self._register_hooks()
13
+
14
+ def _register_hooks(self):
15
+ def forward_hook(module, input, output):
16
+ self.activations = output
17
+
18
+ def backward_hook(module, grad_in, grad_out):
19
+ self.gradients = grad_out[0]
20
+
21
+ self.target_layer.register_forward_hook(forward_hook)
22
+ self.target_layer.register_backward_hook(backward_hook)
23
+
24
+ def generate_cam(self, input_image, target_class):
25
+ self.model.zero_grad()
26
+ output = self.model(input_image)
27
+ loss = output[:, target_class].sum()
28
+ loss.backward()
29
+
30
+ weights = self.gradients.mean(dim=(2, 3), keepdim=True)
31
+ cam = (weights * self.activations).sum(dim=1, keepdim=True)
32
+
33
+ cam = cam.detach().cpu().numpy()
34
+ cam = np.maximum(cam, 0)
35
+ cam = cam / cam.max()
36
+ cam = cam.squeeze()
37
+
38
+ return cam
39
+
40
+ def visualize_cam(self, cam, input_image):
41
+ cam = cv2.resize(cam, (input_image.shape[2], input_image.shape[3]))
42
+ heatmap = cv2.applyColorMap(np.uint8(255 * cam), cv2.COLORMAP_JET)
43
+ heatmap = np.float32(heatmap) / 255
44
+ input_image = np.moveaxis(input_image.cpu().numpy()[0], 0, -1)
45
+ input_image = np.float32(input_image)
46
+ cam_image = heatmap + input_image
47
+ cam_image = cam_image / cam_image.max()
48
+ return cam_image
49
+
50
+ def preprocess_image(image):
51
+ preprocess = transforms.Compose([
52
+ transforms.Grayscale(num_output_channels=1),
53
+ transforms.Resize((512, 512)),
54
+ transforms.ToTensor(),
55
+ transforms.Normalize(mean=[0.5], std=[0.5])
56
+ ])
57
+ image = preprocess(image)
58
+ image = image.unsqueeze(0)
59
+ return image
src/generate_images.py ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import torch
3
+ from PIL import Image
4
+ import numpy as np
5
+ from torch.utils.data import DataLoader, Dataset
6
+ from torchvision import transforms
7
+ from tqdm import tqdm
8
+
9
+ from src.models import ResUNetGenerator
10
+
11
+ # Custom Dataset
12
+ class ImageDataset(Dataset):
13
+ def __init__(self, image_paths, transform=None):
14
+ self.image_paths = image_paths
15
+ self.transform = transform
16
+
17
+ def __len__(self):
18
+ return len(self.image_paths)
19
+
20
+ def __getitem__(self, idx):
21
+ img_path = self.image_paths[idx]
22
+ image = Image.open(img_path).convert('L')
23
+ if self.transform:
24
+ image = self.transform(image)
25
+ return image, img_path
26
+
27
+ # Function to save image
28
+ def save_image(tensor, path):
29
+ if tensor.is_cuda:
30
+ tensor = tensor.cpu()
31
+
32
+ array = tensor.permute(1, 2, 0).detach().numpy()
33
+ array = (array * 0.5 + 0.5) * 255
34
+ array = array.astype(np.uint8)
35
+ if array.shape[2] == 1:
36
+ array = array.squeeze(2)
37
+ image = Image.fromarray(array, mode='L')
38
+ else:
39
+ image = Image.fromarray(array)
40
+ image.save(path)
41
+
42
+ # Function to load model
43
+ def load_model(checkpoint_path, model_class, device):
44
+ model = model_class().to(device)
45
+ model.load_state_dict(torch.load(checkpoint_path, map_location=torch.device('cpu')))
46
+ model.eval()
47
+ return model
48
+
49
+ def generate_images(image_folder, g_NP_checkpoint, g_PN_checkpoint, output_dir='data/translated_images', batch_size=16):
50
+ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
51
+
52
+ # Load models
53
+ g_NP = load_model(g_NP_checkpoint, lambda: ResUNetGenerator(gf=32, channels=1), device)
54
+ g_PN = load_model(g_PN_checkpoint, lambda: ResUNetGenerator(gf=32, channels=1), device)
55
+
56
+ # Create output directories
57
+ os.makedirs(os.path.join(output_dir, '0'), exist_ok=True)
58
+ os.makedirs(os.path.join(output_dir, '1'), exist_ok=True)
59
+
60
+ # Collect image paths
61
+ image_paths_0 = [os.path.join(image_folder, '0', fname) for fname in os.listdir(os.path.join(image_folder, '0')) if fname.endswith(('.png', '.jpg', '.jpeg'))]
62
+ image_paths_1 = [os.path.join(image_folder, '1', fname) for fname in os.listdir(os.path.join(image_folder, '1')) if fname.endswith(('.png', '.jpg', '.jpeg'))]
63
+
64
+ # Prepare dataset and dataloader
65
+ transform = transforms.Compose([transforms.ToTensor(), transforms.Normalize(mean=[0.485], std=[0.229])])
66
+ dataset_0 = ImageDataset(image_paths_0, transform)
67
+ dataset_1 = ImageDataset(image_paths_1, transform)
68
+ dataloader_0 = DataLoader(dataset_0, batch_size=batch_size, shuffle=False)
69
+ dataloader_1 = DataLoader(dataset_1, batch_size=batch_size, shuffle=False)
70
+
71
+ # Process images from negative (0) to positive (1)
72
+ with torch.no_grad():
73
+ for batch, paths in tqdm(dataloader_0, desc="Converting N to P: "):
74
+ batch = batch.to(device)
75
+ translated_images = g_NP(batch)
76
+ translated_images = g_PN(translated_images)
77
+ for img, path in zip(translated_images, paths):
78
+ save_path = os.path.join(output_dir, '1', os.path.basename(path))
79
+ save_image(img, save_path)
80
+
81
+ # Process images from positive (1) to negative (0)
82
+ for batch, paths in tqdm(dataloader_1, desc="Converting P to N: "):
83
+ batch = batch.to(device)
84
+ translated_images = g_PN(batch)
85
+ translated_images = g_NP(translated_images)
86
+ for img, path in zip(translated_images, paths):
87
+ save_path = os.path.join(output_dir, '0', os.path.basename(path))
88
+ save_image(img, save_path)
89
+
90
+ if __name__ == '__main__':
91
+ image_folder = r'data\rsna-pneumonia-dataset\train'
92
+ g_NP_checkpoint = 'models\g_NP_best.ckpt'
93
+ g_PN_checkpoint = 'models\g_PN_best.ckpt'
94
+
95
+
96
+ generate_images(image_folder, g_NP_checkpoint, g_PN_checkpoint)
src/inference.py ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from torchvision import transforms
3
+ from PIL import Image
4
+ import numpy as np
5
+
6
+ from src.classifier import Classifier
7
+
8
+ # Ensure the necessary directories exist
9
+ # os.makedirs('results/translated_N', exist_ok=True)
10
+ # os.makedirs('results/translated_P', exist_ok=True)
11
+
12
+ # Load the classifier model
13
+ def load_classifier(classifier_path):
14
+ classifier = Classifier()
15
+ classifier_checkpoint = torch.load(classifier_path, map_location=torch.device('cpu'))
16
+ classifier.load_state_dict(classifier_checkpoint['state_dict'])
17
+ classifier.eval()
18
+ return classifier
19
+
20
+ # Load the generator models
21
+ def load_model(checkpoint_path, model):
22
+ checkpoint = torch.load(checkpoint_path, map_location=torch.device('cpu'))
23
+ model.load_state_dict(checkpoint)
24
+ model.eval()
25
+ return model
26
+
27
+ def load_image(input_image, image_size):
28
+ transform = transforms.Compose([
29
+ transforms.Resize((image_size, image_size)), # Resize image to 512x512
30
+ transforms.ToTensor(),
31
+ transforms.Normalize(mean=[0.485], std=[0.229]) # Normalize image
32
+ ])
33
+ input_image = input_image.convert('L')
34
+ return transform(input_image).unsqueeze(0)
35
+
36
+ def convert_into_image(tensor):
37
+ if tensor.is_cuda:
38
+ tensor = tensor.cpu()
39
+ array = tensor.squeeze(0).permute(1, 2, 0).detach().numpy()
40
+ array = (array * 0.5 + 0.5) * 255
41
+ array = array.astype(np.uint8)
42
+
43
+ if array.shape[2] == 1:
44
+ array = array.squeeze(2)
45
+ image = Image.fromarray(array, mode='L')
46
+ else:
47
+ image = Image.fromarray(array)
48
+
49
+ return image
50
+
51
+ def generate_images(input_image, classifier, g_PN, g_NP, image_size=512):
52
+
53
+ image = load_image(input_image, image_size)
54
+
55
+ # Classify the image
56
+ classifier_output = classifier(image).cpu().detach().numpy()
57
+ pred = np.argmax(classifier_output, axis=1)[0]
58
+
59
+ if pred > 0.5:
60
+ print("Classified as Domain P")
61
+ translate_to_domain = g_PN
62
+ folder_to_save = 'results/translated_N'
63
+ reverse_translate = g_NP
64
+ else:
65
+ print("Classified as Domain N")
66
+ translate_to_domain = g_NP
67
+ folder_to_save = 'results/translated_P'
68
+ reverse_translate = g_PN
69
+
70
+ # Perform translation and save images
71
+ with torch.no_grad():
72
+ for i in range(1): # Generate and save 10 images
73
+ translated_image = translate_to_domain(image)
74
+ # save_image(translated_image, os.path.join(folder_to_save, f'translated_{i}.png'))
75
+
76
+ # Translate back to the original domain and save
77
+ recon_image = reverse_translate(translated_image)
78
+ # save_image(recon_image, os.path.join(folder_to_save, f'recon_{i}.png'))
79
+
80
+ return translated_image, recon_image
81
+
82
+ def classify_image(input_image, classifier, image_size=512):
83
+
84
+ image = load_image(input_image, image_size)
85
+ classifier_output = classifier(image).cpu().detach().numpy()
86
+ pred = np.argmax(classifier_output, axis=1)[0]
87
+ if pred > 0.5:
88
+ return {"Pneumonia": classifier_output[0][1]}, 1
89
+
90
+ else:
91
+ return {"Normal": classifier_output[0][0]}, 0
src/models.py ADDED
@@ -0,0 +1,405 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import torch.nn as nn
3
+ import lightning as pl
4
+ import wandb
5
+ import itertools
6
+ from torch.optim.lr_scheduler import LambdaLR
7
+ from torch.utils.data import DataLoader
8
+ import numpy as np
9
+ import matplotlib.pyplot as plt
10
+
11
+ from src.classifier import Classifier
12
+ from src.dataset import CustomDataset
13
+
14
+
15
+ class AttentionGate(nn.Module):
16
+ def __init__(self, in_channels, out_channels):
17
+ super(AttentionGate, self).__init__()
18
+ self.conv_gate = nn.Conv2d(in_channels, out_channels, kernel_size=1, stride=1, padding=0)
19
+ self.conv_x = nn.Conv2d(in_channels, out_channels, kernel_size=1, stride=1, padding=0)
20
+ self.softmax = nn.Softmax(dim=1)
21
+
22
+ def forward(self, x, g):
23
+ gate = self.conv_gate(g)
24
+ x = self.conv_x(x)
25
+ attention = self.softmax(gate)
26
+ x_att = x * attention
27
+ return x_att
28
+
29
+ class ResUNetGenerator(nn.Module):
30
+ def __init__(self, gf, channels):
31
+ super(ResUNetGenerator, self).__init__()
32
+ # self.img_shape = img_shape
33
+ self.channels = channels
34
+
35
+ # Downsampling layers
36
+ self.conv1 = nn.Sequential(
37
+ nn.Conv2d(channels, gf, kernel_size=4, stride=2, padding=1),
38
+ nn.LeakyReLU(0.2, inplace=True),
39
+ nn.GroupNorm(num_groups=1, num_channels=gf)
40
+ )
41
+ self.conv2 = nn.Sequential(
42
+ nn.Conv2d(gf, gf * 2, kernel_size=4, stride=2, padding=1),
43
+ nn.LeakyReLU(0.2, inplace=True),
44
+ nn.GroupNorm(num_groups=1, num_channels=gf * 2)
45
+ )
46
+ self.conv3 = nn.Sequential(
47
+ nn.Conv2d(gf * 2, gf * 4, kernel_size=4, stride=2, padding=1),
48
+ nn.LeakyReLU(0.2, inplace=True),
49
+ nn.GroupNorm(num_groups=1, num_channels=gf * 4)
50
+ )
51
+ self.conv4 = nn.Sequential(
52
+ nn.Conv2d(gf * 4, gf * 8, kernel_size=4, stride=2, padding=1),
53
+ nn.LeakyReLU(0.2, inplace=True),
54
+ nn.GroupNorm(num_groups=1, num_channels=gf * 8)
55
+ )
56
+
57
+ self.attn_layer = nn.ModuleList([
58
+ AttentionGate(gf * 2**(i), gf * 2**(i+1))
59
+ for i in range(3)
60
+ ])
61
+
62
+ # Upsampling layers
63
+ self.deconv1 = nn.Sequential(
64
+ nn.ConvTranspose2d(gf * 8, gf * 4, kernel_size=4, stride=2, padding=1),
65
+ nn.ReLU(inplace=True),
66
+ nn.GroupNorm(num_groups=1, num_channels=gf * 4)
67
+ )
68
+ self.deconv2 = nn.Sequential(
69
+ nn.ConvTranspose2d(gf * 8, gf * 2, kernel_size=4, stride=2, padding=1),
70
+ nn.ReLU(inplace=True),
71
+ nn.GroupNorm(num_groups=1, num_channels=gf * 2)
72
+ )
73
+ self.deconv3 = nn.Sequential(
74
+ nn.ConvTranspose2d(gf * 4, gf, kernel_size=4, stride=2, padding=1),
75
+ nn.ReLU(inplace=True),
76
+ nn.GroupNorm(num_groups=1, num_channels=gf)
77
+ )
78
+ self.deconv4 = nn.Sequential(
79
+ nn.ConvTranspose2d(gf * 2, channels, kernel_size=4, stride=2, padding=1),
80
+ nn.Tanh()
81
+ )
82
+
83
+ def forward(self, x):
84
+ # Downsampling
85
+ d1 = self.conv1(x)
86
+ d2 = self.conv2(d1)
87
+ d3 = self.conv3(d2)
88
+ d4 = self.conv4(d3)
89
+
90
+ # Upsampling
91
+ u1 = self.deconv1(d4)
92
+ u1 = self.attn_layer[2](d3, u1)
93
+
94
+ u2 = self.deconv2(u1)
95
+ u2 = self.attn_layer[1](d2, u2)
96
+
97
+ u3 = self.deconv3(u2)
98
+ u3 = self.attn_layer[0](d1, u3)
99
+
100
+ output = self.deconv4(u3)
101
+
102
+ return output
103
+
104
+ def configure_optimizers(self):
105
+ optimizer = torch.optim.Adam(self.parameters(), lr=0.0002, betas=(0.5, 0.999))
106
+ return optimizer
107
+
108
+
109
+ class Discriminator(pl.LightningModule):
110
+ def __init__(self, df):
111
+ super(Discriminator, self).__init__()
112
+ self.df = df
113
+ # Define the layers for the discriminator
114
+ self.conv_layers = nn.ModuleList([nn.Sequential(
115
+ nn.Conv2d(1 if i == 0 else df * 2**(i-1), df * 2**i, kernel_size=4, stride=2, padding=1),
116
+ nn.LeakyReLU(0.2),
117
+ nn.GroupNorm(8, df * 2**i)) for i in range(4)])
118
+
119
+ self.final_conv = nn.Conv2d(df * 8, 1, kernel_size=4, stride=1, padding=1)
120
+
121
+ def forward(self, x):
122
+ out = x
123
+ for conv_layer in self.conv_layers:
124
+ out = conv_layer(out)
125
+ validity = self.final_conv(out)
126
+ return validity
127
+
128
+ def configure_optimizers(self):
129
+ optimizer = torch.optim.Adam(self.parameters(), lr=0.0002, betas=(0.5, 0.999))
130
+ return optimizer
131
+
132
+
133
+
134
+ class CycleGAN(pl.LightningModule):
135
+ def __init__(self, train_dir, val_dir, test_dataloader, classifier_path, checkpoint_dir, image_size=512, batch_size=4, channels=1, gf=32, df=64, lambda_cycle=10.0, lambda_id=0.1, classifier_weight=1):
136
+ super(CycleGAN, self).__init__()
137
+ self.image_size = image_size
138
+ self.batch_size = batch_size
139
+ self.channels = channels
140
+ self.gf = gf
141
+ self.df = df
142
+ self.lambda_cycle = lambda_cycle
143
+ self.lambda_id = lambda_id * lambda_cycle
144
+ self.classifier_path = classifier_path
145
+ self.classifier_weight = classifier_weight
146
+ self.lowest_val_loss = float('inf')
147
+ self.validation_step_outputs = []
148
+ self.train_dir = train_dir
149
+ self.val_dir = val_dir
150
+ self.test_dataloader = test_dataloader
151
+ self.checkpoint_dir = checkpoint_dir
152
+
153
+ # Initialize the generator, discriminator, and classifier models
154
+ self.g_NP = ResUNetGenerator(gf, channels=self.channels)
155
+ self.g_PN = ResUNetGenerator(gf, channels=self.channels)
156
+ self.d_N = Discriminator(df)
157
+ self.d_P = Discriminator(df)
158
+ self.automatic_optimization = False
159
+
160
+ self.classifier = Classifier()
161
+ checkpoint = torch.load(classifier_path)
162
+ self.classifier.load_state_dict(checkpoint['state_dict'])
163
+ self.classifier.eval()
164
+ self.freeze_classifier()
165
+
166
+ def freeze_classifier(self):
167
+ print("freezing Classifier...")
168
+ for p in self.classifier.parameters() :
169
+ p.requires_grad = False
170
+
171
+
172
+ def generator_training_step(self, img_N, img_P, opt):
173
+ self.toggle_optimizer(opt)
174
+ # Translate images to the other domain
175
+ fake_P = self.g_NP(img_N)
176
+ fake_N = self.g_PN(img_P)
177
+
178
+ # Translate images back to original domain
179
+ reconstr_N = self.g_PN(fake_P)
180
+ reconstr_P = self.g_NP(fake_N)
181
+
182
+ # Identity mapping of images
183
+ img_N_id = self.g_PN(img_N)
184
+ img_P_id = self.g_NP(img_P)
185
+ # Discriminators determine validity of translated images
186
+ valid_N = self.d_N(fake_N)
187
+ valid_P = self.d_P(fake_P)
188
+
189
+ class_N_loss = self.classifier(fake_N)
190
+ class_P_loss = self.classifier(fake_P)
191
+ # Adversarial loss
192
+ valid_target = torch.ones_like(valid_N)
193
+ adversarial_loss = nn.MSELoss()(valid_N, valid_target) + nn.MSELoss()(valid_P, valid_target)
194
+
195
+ # Cycle consistency loss
196
+ cycle_loss = nn.L1Loss()(reconstr_N, img_N) + nn.L1Loss()(reconstr_P, img_P)
197
+
198
+ # Identity loss
199
+ identity_loss = nn.L1Loss()(img_N_id, img_N) + nn.L1Loss()(img_P_id, img_P)
200
+
201
+ # Classifier loss
202
+ class_loss = nn.MSELoss()(class_N_loss, torch.ones_like(class_N_loss)) + nn.MSELoss()(class_P_loss, torch.zeros_like(class_P_loss))
203
+
204
+ # Total generator loss
205
+ total_loss = adversarial_loss + self.lambda_cycle * cycle_loss + self.lambda_id * identity_loss + self.classifier_weight * class_loss
206
+
207
+ self.log('adversarial_loss', adversarial_loss, on_step=True, on_epoch=True, prog_bar=True, logger=True)
208
+ self.log('reconstruction_loss', cycle_loss, on_step=True, on_epoch=True, prog_bar=True, logger=True)
209
+ self.log('identity_loss', identity_loss, on_step=True, on_epoch=True, prog_bar=True, logger=True)
210
+ self.log('class_loss', class_loss, on_step=True, on_epoch=True, prog_bar=True, logger=True)
211
+ self.log('generator_loss', total_loss, on_step=True, on_epoch=True, prog_bar=True, logger=True)
212
+
213
+ opt.zero_grad()
214
+ self.manual_backward(total_loss)
215
+ opt.step()
216
+ self.untoggle_optimizer(opt)
217
+
218
+ return total_loss, adversarial_loss, cycle_loss
219
+
220
+ def discriminator_training_step(self, img_N, img_P, opt):
221
+ # Pass real images through discriminator D_N
222
+ self.toggle_optimizer(opt)
223
+ pred_real_N = self.d_N(img_N)
224
+ mse_real_N = nn.MSELoss()(pred_real_N, torch.ones_like(pred_real_N))
225
+ fake_P = self.g_PN(img_P)
226
+ pred_fake_N = self.d_N(fake_P)
227
+ mse_fake_N = nn.MSELoss()(pred_fake_N, torch.zeros_like(pred_fake_N))
228
+
229
+ pred_real_P = self.d_P(img_P)
230
+ mse_real_P = nn.MSELoss()(pred_real_P, torch.ones_like(pred_real_P))
231
+ fake_N = self.g_NP(img_N)
232
+ pred_fake_P = self.d_P(fake_N)
233
+ mse_fake_P = nn.MSELoss()(pred_fake_P, torch.zeros_like(pred_fake_P))
234
+
235
+ # Compute total discriminator loss
236
+ dis_loss = 0.5 * (mse_real_N + mse_fake_N + mse_real_P + mse_fake_P)
237
+ opt.zero_grad()
238
+ self.manual_backward(mse_fake_P)
239
+ opt.step()
240
+ self.untoggle_optimizer(opt)
241
+
242
+ self.log('mse_fake_N', mse_fake_N, on_step=True, on_epoch=True, prog_bar=True, logger=True)
243
+ self.log('mse_fake_P', mse_fake_P, on_step=True, on_epoch=True, prog_bar=True, logger=True)
244
+ self.log('discriminator_loss', dis_loss, on_step=True, on_epoch=True, prog_bar=True, logger=True)
245
+
246
+ return dis_loss, mse_fake_N, mse_fake_P
247
+
248
+ def training_step(self, batch, batch_idx):
249
+ img_N, img_P = batch
250
+ optD, optG = self.optimizers()
251
+
252
+ total_loss, adversarial_loss, cycle_loss = self.generator_training_step(img_N, img_P, optG)
253
+ dis_loss, mse_fake_N, mse_fake_P = self.discriminator_training_step(img_N, img_P, optD)
254
+
255
+ return {"generator_loss": total_loss, "adversarial_loss": adversarial_loss, "reconstruction_loss": cycle_loss, "discriminator_loss": dis_loss, "mse_fake_N": mse_fake_N, "mse_fake_P": mse_fake_P}
256
+
257
+ def validation_step(self, batch, batch_idx):
258
+ img_N, img_P = batch
259
+
260
+ # Translate images to the other domain
261
+ fake_P = self.g_NP(img_N)
262
+ fake_N = self.g_PN(img_P)
263
+
264
+ # Translate images back to original domain
265
+ reconstr_N = self.g_PN(fake_P)
266
+ reconstr_P = self.g_NP(fake_N)
267
+
268
+ # Identity mapping of images
269
+ img_N_id = self.g_PN(img_N)
270
+ img_P_id = self.g_NP(img_P)
271
+
272
+ # Discriminators determine validity of translated images
273
+ valid_N = self.d_N(fake_N)
274
+ valid_P = self.d_P(fake_P)
275
+
276
+ class_N_loss = self.classifier(fake_N)
277
+ class_P_loss = self.classifier(fake_P)
278
+
279
+ # Adversarial loss
280
+ valid_target = torch.ones_like(valid_N)
281
+ adversarial_loss = nn.MSELoss()(valid_N, valid_target) + nn.MSELoss()(valid_P, valid_target)
282
+
283
+ # Cycle consistency loss
284
+ cycle_loss = nn.L1Loss()(reconstr_N, img_N) + nn.L1Loss()(reconstr_P, img_P)
285
+
286
+ # Identity loss
287
+ identity_loss = nn.L1Loss()(img_N_id, img_N) + nn.L1Loss()(img_P_id, img_P)
288
+
289
+ # Classifier loss
290
+ class_loss = nn.MSELoss()(class_N_loss, torch.ones_like(class_N_loss)) + nn.MSELoss()(class_P_loss, torch.zeros_like(class_P_loss))
291
+
292
+
293
+ # Total generator loss
294
+ total_loss = adversarial_loss + self.lambda_cycle * cycle_loss + self.lambda_id * identity_loss + self.classifier_weight * class_loss
295
+ self.validation_step_outputs.append(total_loss)
296
+
297
+ self.log('val_adversarial_loss', adversarial_loss, on_step=False, on_epoch=True, prog_bar=True, logger=True)
298
+ self.log('val_cycle_loss', cycle_loss, on_step=False, on_epoch=True, prog_bar=True, logger=True)
299
+ self.log('val_identity_loss', identity_loss, on_step=False, on_epoch=True, prog_bar=True, logger=True)
300
+ self.log('val_class_loss', class_loss, on_step=False, on_epoch=True, prog_bar=True, logger=True)
301
+ self.log('val_generator_loss', total_loss, on_step=False, on_epoch=True, prog_bar=True, logger=True)
302
+
303
+ return total_loss
304
+
305
+ def on_validation_end(self):
306
+ # Calculate average validation loss
307
+ avg_val_loss = torch.stack(self.validation_step_outputs).mean()
308
+
309
+ # Check if current validation loss is lower than the lowest recorded validation loss
310
+ if avg_val_loss < self.lowest_val_loss:
311
+ # Update lowest validation loss and corresponding epoch
312
+ self.lowest_val_loss = avg_val_loss
313
+
314
+ # Save the generators' state dictionaries
315
+ torch.save(self.g_NP.state_dict(), f"{self.checkpoint_dir}/g_NP_best.ckpt")
316
+ torch.save(self.g_PN.state_dict(), f"{self.checkpoint_dir}/g_PN_best.ckpt")
317
+ print(f"Model saved! loss reduced to {self.lowest_val_loss}")
318
+
319
+ def configure_optimizers(self):
320
+ optG = torch.optim.Adam(itertools.chain(self.g_NP.parameters(), self.g_PN.parameters()),lr=2e-4, betas=(0.5, 0.999))
321
+ optD = torch.optim.Adam(itertools.chain(self.d_N.parameters(), self.d_P.parameters()),lr=2e-4, betas=(0.5, 0.999))
322
+
323
+ gamma = lambda epoch: 1 - max(0, epoch + 1 - 100) / 101
324
+ schD = LambdaLR(optD, lr_lambda=gamma)
325
+ # Optimizer= [optD, optG]
326
+ return optD, optG
327
+
328
+ def train_dataloader(self):
329
+ root_dir = self.train_dir
330
+ train_N = "0"
331
+ train_P = "1"
332
+ img_res = (self.image_size, self.image_size)
333
+
334
+ dataset = CustomDataset(root_dir=root_dir, train_N=train_N, train_P=train_P, img_res=img_res)
335
+
336
+ # Set up DataLoader for parallel processing and GPU acceleration
337
+ dataloader = DataLoader(dataset, batch_size=self.batch_size, shuffle=True, num_workers=4, pin_memory=True)
338
+
339
+ return dataloader
340
+
341
+ def val_dataloader(self):
342
+ root_dir = self.val_dir
343
+ train_N = "0"
344
+ train_P = "1"
345
+ img_res = (self.image_size, self.image_size)
346
+
347
+ dataset = CustomDataset(root_dir=root_dir, train_N=train_N, train_P=train_P, img_res=img_res)
348
+
349
+ # Set up DataLoader for parallel processing and GPU acceleration
350
+ dataloader = DataLoader(dataset, batch_size=self.batch_size, shuffle=False, num_workers=4, pin_memory=True)
351
+
352
+ return dataloader
353
+
354
+
355
+ def on_train_batch_end(self, outputs, batch, batch_idx):
356
+ if batch_idx % 100 == 0:
357
+ # Get a random batch from the test dataloader
358
+ batch = next(iter(self.test_dataloader))
359
+ img_N, img_P = batch
360
+
361
+ # Pick a random image from the batch
362
+ idx = np.random.randint(img_N.size(0))
363
+ img_N = img_N[idx].unsqueeze(0).to('cuda')
364
+ img_P = img_P[idx].unsqueeze(0).to('cuda')
365
+ # Translate images to the other domain
366
+ fake_P = self.g_NP(img_N)
367
+ fake_N = self.g_PN(img_P)
368
+
369
+ # Translate images back to original domain
370
+ reconstr_N = self.g_PN(fake_P)
371
+ reconstr_P = self.g_NP(fake_N)
372
+
373
+ # Plot the images
374
+ fig, axes = plt.subplots(2, 3, figsize=(15, 10))
375
+
376
+ # Plot real N, translated P, and reconstructed N
377
+ axes[0, 0].imshow(img_N.squeeze(0).permute(1, 2, 0).cpu().detach().numpy(), cmap='gray')
378
+ axes[0, 0].set_title("Real N")
379
+ axes[0, 0].axis('off')
380
+
381
+ axes[0, 1].imshow(fake_P.squeeze(0).permute(1, 2, 0).cpu().detach().numpy(), cmap='gray')
382
+ axes[0, 1].set_title("Translated P")
383
+ axes[0, 1].axis('off')
384
+
385
+ axes[0, 2].imshow(reconstr_N.squeeze(0).permute(1, 2, 0).cpu().detach().numpy(), cmap='gray')
386
+ axes[0, 2].set_title("Reconstructed N")
387
+ axes[0, 2].axis('off')
388
+
389
+ # Plot real P, translated N, and reconstructed P
390
+ axes[1, 0].imshow(img_P.squeeze(0).permute(1, 2, 0).cpu().detach().numpy(), cmap='gray')
391
+ axes[1, 0].set_title("Real P")
392
+ axes[1, 0].axis('off')
393
+
394
+ axes[1, 1].imshow(fake_N.squeeze(0).permute(1, 2, 0).cpu().detach().numpy(), cmap='gray')
395
+ axes[1, 1].set_title("Translated N")
396
+ axes[1, 1].axis('off')
397
+
398
+ axes[1, 2].imshow(reconstr_P.squeeze(0).permute(1, 2, 0).cpu().detach().numpy(), cmap='gray')
399
+ axes[1, 2].set_title("Reconstructed P")
400
+ axes[1, 2].axis('off')
401
+
402
+ # Log the figure in WandB
403
+ wandb.log({"test_images": wandb.Image(fig)})
404
+
405
+ plt.close(fig)
src/train.py ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from torchvision import transforms
2
+ from torch.utils.data import DataLoader
3
+ from lightning.pytorch.loggers.wandb import WandbLogger
4
+ from lightning.pytorch.callbacks import ModelCheckpoint
5
+ import lightning as pl
6
+ import wandb
7
+
8
+ from src.dataset import ClassifierDataset, CustomDataset
9
+ from src.classifier import Classifier
10
+ from src.models import CycleGAN
11
+ from src.config import CFG
12
+
13
+ def train_classifier(image_size,
14
+ batch_size,
15
+ epochs,
16
+ resume_ckpt_path,
17
+ train_dir,
18
+ val_dir,
19
+ checkpoint_dir,
20
+ project,
21
+ job_name):
22
+
23
+ clf_wandb_logger = WandbLogger(project=project, name=job_name, log_model="all")
24
+
25
+ transform = transforms.Compose([
26
+ transforms.Resize((image_size, image_size)), # Resize image to 512x512
27
+ transforms.ToTensor(),
28
+ transforms.Normalize(mean=[0.485], std=[0.229]) # Normalize image
29
+ ])
30
+
31
+ # Define dataset paths
32
+ # train_dir = "/kaggle/working/CycleGan-CFE/train-data/train"
33
+ # val_dir = "/kaggle/working/CycleGan-CFE/train-data/val"
34
+
35
+ # Create datasets
36
+ train_dataset = ClassifierDataset(root_dir=train_dir, transform=transform)
37
+ val_dataset = ClassifierDataset(root_dir=val_dir, transform=transform)
38
+ print("Total Training Images: ",len(train_dataset))
39
+ print("Total Validation Images: ",len(val_dataset))
40
+
41
+ # Create data loaders
42
+ train_loader = DataLoader(train_dataset, batch_size=batch_size, shuffle=True, pin_memory=True, num_workers=4)
43
+ val_loader = DataLoader(val_dataset, batch_size=batch_size, shuffle=False, pin_memory=True, num_workers=4)
44
+ # Instantiate the classifier model
45
+ clf = Classifier(transfer=True)
46
+
47
+ checkpoint_callback = ModelCheckpoint(
48
+ monitor='val_loss',
49
+ dirpath=checkpoint_dir,
50
+ filename='efficientnet_b2-epoch{epoch:02d}-val_loss{val_loss:.2f}',
51
+ auto_insert_metric_name=False,
52
+ save_weights_only=False,
53
+ save_top_k=3,
54
+ mode='min'
55
+ )
56
+ # Set up PyTorch Lightning Trainer with multiple GPUs and tqdm progress bar
57
+ trainer = pl.Trainer(
58
+ devices="auto",
59
+ precision="16-mixed",
60
+ accelerator="auto",
61
+ max_epochs=epochs,
62
+ accumulate_grad_batches=10,
63
+ log_every_n_steps=1,
64
+ check_val_every_n_epoch=1,
65
+ benchmark=True,
66
+ logger=clf_wandb_logger,
67
+ callbacks=[checkpoint_callback],
68
+ )
69
+
70
+ # Train the classifier
71
+ trainer.fit(clf, train_loader, val_loader, ckpt_path=resume_ckpt_path)
72
+ wandb.finish()
73
+
74
+
75
+ def train_cyclegan(image_size,
76
+ batch_size,
77
+ epochs,
78
+ classifier_path,
79
+ resume_ckpt_path,
80
+ train_dir,
81
+ val_dir,
82
+ test_dir,
83
+ checkpoint_dir,
84
+ project,
85
+ job_name,
86
+ ):
87
+
88
+
89
+ testdata_dir = test_dir
90
+ train_N = "0"
91
+ train_P = "1"
92
+ img_res = (image_size, image_size)
93
+
94
+ test_dataset = CustomDataset(root_dir=testdata_dir, train_N=train_N, train_P=train_P, img_res=img_res)
95
+ test_dataloader = DataLoader(test_dataset, batch_size=batch_size, shuffle=False, num_workers=4, pin_memory=True)
96
+
97
+ wandb_logger = WandbLogger(project=project, name=job_name, log_model="all")
98
+ print(classifier_path)
99
+ cyclegan = CycleGAN(train_dir=train_dir, val_dir=val_dir, test_dataloader=test_dataloader, classifier_path=classifier_path, checkpoint_dir=checkpoint_dir, gf=CFG.GAN_FILTERS, df=CFG.DIS_FILTERS)
100
+
101
+ gan_checkpoint_callback = ModelCheckpoint(dirpath=checkpoint_dir,
102
+ filename='cyclegan-epoch_{epoch}-vloss_{val_generator_loss:.2f}',
103
+ monitor='val_generator_loss',
104
+ save_top_k=3,
105
+ save_last=True,
106
+ save_weights_only=False,
107
+ verbose=True,
108
+ mode='min')
109
+
110
+
111
+ # Create the trainer
112
+ trainer = pl.Trainer(
113
+ accelerator="auto",
114
+ precision="16-mixed",
115
+ max_epochs=epochs,
116
+ log_every_n_steps=1,
117
+ benchmark=True,
118
+ devices="auto",
119
+ logger=wandb_logger,
120
+ callbacks= [gan_checkpoint_callback]
121
+ )
122
+
123
+ # Train the CycleGAN model
124
+ trainer.fit(cyclegan, ckpt_path=resume_ckpt_path)
src/wandb/run-20240511_204545-zlcauue2/files/code/src/pipeline.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+
3
+ from train import train_classifier, train_cyclegan
4
+
5
+ def main():
6
+ parser = argparse.ArgumentParser(description="Pipeline for training classifier or CycleGAN")
7
+ parser.add_argument("--model_type", type=str, choices=["classifier", "cycle-gan"], help="Type of model to train")
8
+ parser.add_argument("--image_size", type=int, default=512, help="Size of input images")
9
+ parser.add_argument("--batch_size", type=int, default=4, help="Batch size for training")
10
+ parser.add_argument("--epochs", type=int, default=10, help="Number of epochs for training")
11
+ parser.add_argument("--resume_ckpt_path", type=str, default=None, help="Checkpoint path for resuming the training")
12
+ parser.add_argument("--train_dir", type=str, required=True, help="Path to training data directory")
13
+ parser.add_argument("--val_dir", type=str, required=True, help="Path to validation data directory")
14
+ parser.add_argument("--test_dir", type=str, required=True, help="Path to test data directory (for CycleGAN)")
15
+ parser.add_argument("--project", type=str, default="CycleGAN-CounterFactual Explanation", help="Name of the project (for logging)")
16
+ parser.add_argument("--job_name", type=str, default="training", help="Name of the training job (for logging)")
17
+ parser.add_argument("--checkpoint_dir", type=str, default="./models", help="Directory to save model checkpoints")
18
+ parser.add_argument("--classifier_path", type=str, default=None, help="Path to pre-trained classifier model (for CycleGAN)")
19
+
20
+ args = parser.parse_args()
21
+
22
+ if args.model_type == "classifier":
23
+ train_classifier(args.image_size, args.batch_size, args.epochs, args.resume_ckpt_path, args.train_dir, args.val_dir, args.checkpoint_dir, args.project, args.job_name)
24
+ elif args.model_type == "cycle-gan":
25
+ if args.classifier_path == None:
26
+ raise ValueError("Please provide the 'classifier checkpoint path' to train the cyle GAN model")
27
+ train_cyclegan(args.image_size, args.batch_size, args.epochs, args.classifier_path, args.resume_ckpt_path, args.train_dir, args.val_dir, args.test_dir, args.checkpoint_dir, args.project, args.job_name)
28
+ else:
29
+ print("Invalid model type. Choose either 'classifier' or 'cycle-gan'.")
30
+
31
+ if __name__ == "__main__":
32
+ main()
src/wandb/run-20240511_204545-zlcauue2/files/config.yaml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ wandb_version: 1
2
+
3
+ _wandb:
4
+ desc: null
5
+ value:
6
+ code_path: code/src/pipeline.py
7
+ python_version: 3.11.7
8
+ cli_version: 0.17.0
9
+ framework: torch
10
+ is_jupyter_run: false
11
+ is_kaggle_kernel: false
12
+ start_time: 1715440545
13
+ t:
14
+ 1:
15
+ - 1
16
+ - 41
17
+ - 55
18
+ 2:
19
+ - 1
20
+ - 41
21
+ - 55
22
+ 3:
23
+ - 2
24
+ - 7
25
+ - 13
26
+ - 23
27
+ - 66
28
+ 4: 3.11.7
29
+ 5: 0.17.0
30
+ 8:
31
+ - 3
32
+ - 5
33
+ 13: windows-amd64
34
+ m:
35
+ - 1: trainer/global_step
36
+ 6:
37
+ - 3
src/wandb/run-20240511_204545-zlcauue2/files/diff.patch ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/.gitignore b/.gitignore
2
+ index 68bc17f..cdb9062 100644
3
+ --- a/.gitignore
4
+ +++ b/.gitignore
5
+ @@ -2,6 +2,7 @@
6
+ __pycache__/
7
+ *.py[cod]
8
+ *$py.class
9
+ +cfe/
10
+
11
+ # C extensions
12
+ *.so
13
+ diff --git a/README.md b/README.md
14
+ index 0c0d28c..82d90e4 100644
15
+ --- a/README.md
16
+ +++ b/README.md
17
+ @@ -5,3 +5,10 @@ This project addresses the critical need for transparent and interpretable decis
18
+ The primary objective is to generate realistic counterfactual images for image classifiers operating in medical contexts. By harnessing advanced techniques from adversarial learning, the project seeks to overcome the challenges associated with existing methods, such as saliency maps, which may not effectively capture the intricate nuances of decision-making processes rooted in texture and structure.
19
+
20
+ The proposed approach holds promise for enhancing the interpretability of deep learning models, especially in high-stakes domains like healthcare, where transparent decision-making is paramount. By providing realistic counterfactual explanations, the project aims to empower clinicians and stakeholders with insights into classifier decisions, thereby fostering trust and facilitating more informed medical interventions.
21
+ +
22
+ +
23
+ +### Python 3.11.0 recommended
24
+ +```
25
+ +python -m venv myenv
26
+ +.\myenv\Scripts\activate
27
+ +```
src/wandb/run-20240511_204545-zlcauue2/files/output.log ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ D:\Official\Reseach Projects\Personal Projects\Machine Learning\Deep Learning\Counterfactual-Image-Generation-using-CycleGAN\cfe\Lib\site-packages\torch\optim\lr_scheduler.py:28: UserWarning: The verbose parameter is deprecated. Please use get_last_lr() to access the learning rate.
2
+ warnings.warn("The verbose parameter is deprecated. Please use get_last_lr() "
3
+ | Name | Type | Params
4
+ ----------------------------------------------------
5
+ 0 | conv | Conv2d | 30
6
+ 1 | model | SwinTransformer | 27.7 M
7
+ 2 | criterion | CrossEntropyLoss | 0
8
+ 3 | train_accuracy | BinaryAccuracy | 0
9
+ 4 | val_accuracy | BinaryAccuracy | 0
10
+ ----------------------------------------------------
11
+ 197 K Trainable params
12
+ 27.5 M Non-trainable params
13
+ 27.7 M Total params
14
+ 110.867 Total estimated model params size (MB)
15
+ D:\Official\Reseach Projects\Personal Projects\Machine Learning\Deep Learning\Counterfactual-Image-Generation-using-CycleGAN\cfe\Lib\site-packages\lightning\pytorch\trainer\connectors\data_connector.py:436: Consider setting `persistent_workers=True` in 'val_dataloader' to speed up the dataloader worker initialization.
16
+
17
+
18
+
19
+
20
+ D:\Official\Reseach Projects\Personal Projects\Machine Learning\Deep Learning\Counterfactual-Image-Generation-using-CycleGAN\cfe\Lib\site-packages\lightning\pytorch\trainer\connectors\data_connector.py:436: Consider setting `persistent_workers=True` in 'train_dataloader' to speed up the dataloader worker initialization.
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+ Epoch 0: 0%|▏ | 9/4185 [02:58<23:03:15, 0.05it/s, v_num=uue2, train_acc=0.250]
31
+ D:\Official\Reseach Projects\Personal Projects\Machine Learning\Deep Learning\Counterfactual-Image-Generation-using-CycleGAN\cfe\Lib\site-packages\lightning\pytorch\trainer\call.py:54: Detected KeyboardInterrupt, attempting graceful shutdown...
src/wandb/run-20240511_204545-zlcauue2/files/requirements.txt ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GitPython==3.1.43
2
+ Jinja2==3.1.4
3
+ MarkupSafe==2.1.5
4
+ PyYAML==6.0.1
5
+ aiohttp==3.9.5
6
+ aiosignal==1.3.1
7
+ attrs==23.2.0
8
+ certifi==2024.2.2
9
+ charset-normalizer==3.3.2
10
+ click==8.1.7
11
+ colorama==0.4.6
12
+ contourpy==1.2.1
13
+ cycler==0.12.1
14
+ docker-pycreds==0.4.0
15
+ filelock==3.14.0
16
+ fonttools==4.51.0
17
+ frozenlist==1.4.1
18
+ fsspec==2024.3.1
19
+ gitdb==4.0.11
20
+ idna==3.7
21
+ intel-openmp==2021.4.0
22
+ kiwisolver==1.4.5
23
+ lightning-utilities==0.11.2
24
+ lightning==2.2.3
25
+ matplotlib==3.8.4
26
+ mkl==2021.4.0
27
+ mpmath==1.3.0
28
+ multidict==6.0.5
29
+ networkx==3.3
30
+ numpy==1.26.4
31
+ packaging==24.0
32
+ pandas==2.2.2
33
+ pillow==10.3.0
34
+ pip==23.2.1
35
+ platformdirs==4.2.1
36
+ pretty-errors==1.2.25
37
+ protobuf==4.25.3
38
+ psutil==5.9.8
39
+ pydicom==2.4.4
40
+ pyparsing==3.1.2
41
+ python-dateutil==2.9.0.post0
42
+ pytorch-lightning==2.2.4
43
+ pytz==2024.1
44
+ requests==2.31.0
45
+ sentry-sdk==2.1.1
46
+ setproctitle==1.3.3
47
+ setuptools==65.5.0
48
+ six==1.16.0
49
+ smmap==5.0.1
50
+ sympy==1.12
51
+ tbb==2021.12.0
52
+ torch==2.3.0
53
+ torchmetrics==1.4.0
54
+ torchsummary==1.5.1
55
+ torchvision==0.18.0
56
+ tqdm==4.66.4
57
+ typing_extensions==4.11.0
58
+ tzdata==2024.1
59
+ urllib3==2.2.1
60
+ wandb==0.17.0
61
+ yarl==1.9.4
src/wandb/run-20240511_204545-zlcauue2/files/wandb-metadata.json ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "os": "Windows-10-10.0.22631-SP0",
3
+ "python": "3.11.7",
4
+ "heartbeatAt": "2024-05-11T15:15:48.651401",
5
+ "startedAt": "2024-05-11T15:15:45.805161",
6
+ "docker": null,
7
+ "cuda": null,
8
+ "args": [
9
+ "--model_type",
10
+ "classifier",
11
+ "--image_size",
12
+ "512",
13
+ "--batch_size",
14
+ "4",
15
+ "--epochs",
16
+ "10",
17
+ "--train_dir",
18
+ "D:\\Official\\Reseach Projects\\Personal Projects\\Machine Learning\\Deep Learning\\Counterfactual-Image-Generation-using-CycleGAN\\data\\rsna-pneumonia-dataset\\train",
19
+ "--val_dir",
20
+ "D:\\Official\\Reseach Projects\\Personal Projects\\Machine Learning\\Deep Learning\\Counterfactual-Image-Generation-using-CycleGAN\\data\\rsna-pneumonia-dataset\\val",
21
+ "--project",
22
+ "CycleGAN-CFE",
23
+ "--job_name",
24
+ "swin_t-classifier-training",
25
+ "--checkpoint_dir",
26
+ "D:\\Official\\Reseach Projects\\Personal Projects\\Machine Learning\\Deep Learning\\Counterfactual-Image-Generation-using-CycleGAN\\models",
27
+ "--test_dir",
28
+ "D:\\Official\\Reseach Projects\\Personal Projects\\Machine Learning\\Deep Learning\\Counterfactual-Image-Generation-using-CycleGAN\\data\\rsna-pneumonia-dataset\\test"
29
+ ],
30
+ "state": "running",
31
+ "program": "D:\\Official\\Reseach Projects\\Personal Projects\\Machine Learning\\Deep Learning\\Counterfactual-Image-Generation-using-CycleGAN\\src\\pipeline.py",
32
+ "codePathLocal": "pipeline.py",
33
+ "codePath": "src\\pipeline.py",
34
+ "git": {
35
+ "remote": "https://github.com/anindyamitra2002/Counterfactual-Image-Generation-using-CycleGAN.git",
36
+ "commit": "a695a29e7ffc4a52a3e7abedae76632e7849a680"
37
+ },
38
+ "email": "[email protected]",
39
+ "root": "D:/Official/Reseach Projects/Personal Projects/Machine Learning/Deep Learning/Counterfactual-Image-Generation-using-CycleGAN",
40
+ "host": "LAPTOP-0QSMFF19",
41
+ "username": "Anind",
42
+ "executable": "D:\\Official\\Reseach Projects\\Personal Projects\\Machine Learning\\Deep Learning\\Counterfactual-Image-Generation-using-CycleGAN\\cfe\\Scripts\\python.exe",
43
+ "cpu_count": 2,
44
+ "cpu_count_logical": 4,
45
+ "cpu_freq": {
46
+ "current": 1190.0,
47
+ "min": 0.0,
48
+ "max": 1190.0
49
+ },
50
+ "cpu_freq_per_core": [
51
+ {
52
+ "current": 1190.0,
53
+ "min": 0.0,
54
+ "max": 1190.0
55
+ }
56
+ ],
57
+ "disk": {
58
+ "/": {
59
+ "total": 244.38378524780273,
60
+ "used": 121.69070053100586
61
+ }
62
+ },
63
+ "memory": {
64
+ "total": 7.7869110107421875
65
+ }
66
+ }
src/wandb/run-20240511_204545-zlcauue2/files/wandb-summary.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"_wandb": {"runtime": 374}}
src/wandb/run-20240511_204545-zlcauue2/logs/debug-internal.log ADDED
@@ -0,0 +1,279 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 2024-05-11 20:45:45,839 INFO StreamThr :1724 [internal.py:wandb_internal():85] W&B internal server running at pid: 1724, started at: 2024-05-11 20:45:45.837157
2
+ 2024-05-11 20:45:45,867 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status
3
+ 2024-05-11 20:45:45,869 INFO WriterThread:1724 [datastore.py:open_for_write():87] open: .\wandb\run-20240511_204545-zlcauue2\run-zlcauue2.wandb
4
+ 2024-05-11 20:45:45,871 DEBUG SenderThread:1724 [sender.py:send():378] send: header
5
+ 2024-05-11 20:45:45,971 DEBUG SenderThread:1724 [sender.py:send():378] send: run
6
+ 2024-05-11 20:45:45,977 INFO SenderThread:1724 [sender.py:_setup_resume():748] checking resume status for None/CycleGAN-CFE/zlcauue2
7
+ 2024-05-11 20:45:47,872 INFO SenderThread:1724 [dir_watcher.py:__init__():211] watching files in: .\wandb\run-20240511_204545-zlcauue2\files
8
+ 2024-05-11 20:45:47,872 INFO SenderThread:1724 [sender.py:_start_run_threads():1123] run started: zlcauue2 with start time 1715440545.843265
9
+ 2024-05-11 20:45:47,887 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: check_version
10
+ 2024-05-11 20:45:47,887 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: check_version
11
+ 2024-05-11 20:45:48,619 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: run_start
12
+ 2024-05-11 20:45:48,641 DEBUG HandlerThread:1724 [system_info.py:__init__():26] System info init
13
+ 2024-05-11 20:45:48,641 DEBUG HandlerThread:1724 [system_info.py:__init__():41] System info init done
14
+ 2024-05-11 20:45:48,641 INFO HandlerThread:1724 [system_monitor.py:start():194] Starting system monitor
15
+ 2024-05-11 20:45:48,641 INFO SystemMonitor:1724 [system_monitor.py:_start():158] Starting system asset monitoring threads
16
+ 2024-05-11 20:45:48,641 INFO HandlerThread:1724 [system_monitor.py:probe():214] Collecting system info
17
+ 2024-05-11 20:45:48,646 DEBUG HandlerThread:1724 [system_info.py:probe():150] Probing system
18
+ 2024-05-11 20:45:48,651 INFO SystemMonitor:1724 [interfaces.py:start():188] Started cpu monitoring
19
+ 2024-05-11 20:45:48,652 DEBUG HandlerThread:1724 [system_info.py:_probe_git():135] Probing git
20
+ 2024-05-11 20:45:48,655 INFO SystemMonitor:1724 [interfaces.py:start():188] Started disk monitoring
21
+ 2024-05-11 20:45:48,669 INFO SystemMonitor:1724 [interfaces.py:start():188] Started memory monitoring
22
+ 2024-05-11 20:45:48,684 INFO SystemMonitor:1724 [interfaces.py:start():188] Started network monitoring
23
+ 2024-05-11 20:45:48,766 DEBUG HandlerThread:1724 [system_info.py:_probe_git():143] Probing git done
24
+ 2024-05-11 20:45:48,766 DEBUG HandlerThread:1724 [system_info.py:probe():198] Probing system done
25
+ 2024-05-11 20:45:48,766 DEBUG HandlerThread:1724 [system_monitor.py:probe():223] {'os': 'Windows-10-10.0.22631-SP0', 'python': '3.11.7', 'heartbeatAt': '2024-05-11T15:15:48.651401', 'startedAt': '2024-05-11T15:15:45.805161', 'docker': None, 'cuda': None, 'args': ('--model_type', 'classifier', '--image_size', '512', '--batch_size', '4', '--epochs', '10', '--train_dir', 'D:\\Official\\Reseach Projects\\Personal Projects\\Machine Learning\\Deep Learning\\Counterfactual-Image-Generation-using-CycleGAN\\data\\rsna-pneumonia-dataset\\train', '--val_dir', 'D:\\Official\\Reseach Projects\\Personal Projects\\Machine Learning\\Deep Learning\\Counterfactual-Image-Generation-using-CycleGAN\\data\\rsna-pneumonia-dataset\\val', '--project', 'CycleGAN-CFE', '--job_name', 'swin_t-classifier-training', '--checkpoint_dir', 'D:\\Official\\Reseach Projects\\Personal Projects\\Machine Learning\\Deep Learning\\Counterfactual-Image-Generation-using-CycleGAN\\models', '--test_dir', 'D:\\Official\\Reseach Projects\\Personal Projects\\Machine Learning\\Deep Learning\\Counterfactual-Image-Generation-using-CycleGAN\\data\\rsna-pneumonia-dataset\\test'), 'state': 'running', 'program': 'D:\\Official\\Reseach Projects\\Personal Projects\\Machine Learning\\Deep Learning\\Counterfactual-Image-Generation-using-CycleGAN\\src\\pipeline.py', 'codePathLocal': 'pipeline.py', 'codePath': 'src\\pipeline.py', 'git': {'remote': 'https://github.com/anindyamitra2002/Counterfactual-Image-Generation-using-CycleGAN.git', 'commit': 'a695a29e7ffc4a52a3e7abedae76632e7849a680'}, 'email': '[email protected]', 'root': 'D:/Official/Reseach Projects/Personal Projects/Machine Learning/Deep Learning/Counterfactual-Image-Generation-using-CycleGAN', 'host': 'LAPTOP-0QSMFF19', 'username': 'Anind', 'executable': 'D:\\Official\\Reseach Projects\\Personal Projects\\Machine Learning\\Deep Learning\\Counterfactual-Image-Generation-using-CycleGAN\\cfe\\Scripts\\python.exe', 'cpu_count': 2, 'cpu_count_logical': 4, 'cpu_freq': {'current': 1190.0, 'min': 0.0, 'max': 1190.0}, 'cpu_freq_per_core': [{'current': 1190.0, 'min': 0.0, 'max': 1190.0}], 'disk': {'/': {'total': 244.38378524780273, 'used': 121.69070053100586}}, 'memory': {'total': 7.7869110107421875}}
26
+ 2024-05-11 20:45:48,766 INFO HandlerThread:1724 [system_monitor.py:probe():224] Finished collecting system info
27
+ 2024-05-11 20:45:48,766 INFO HandlerThread:1724 [system_monitor.py:probe():227] Publishing system info
28
+ 2024-05-11 20:45:48,767 DEBUG HandlerThread:1724 [system_info.py:_save_code():44] Saving code
29
+ 2024-05-11 20:45:48,825 DEBUG HandlerThread:1724 [system_info.py:_save_code():65] Saving code done
30
+ 2024-05-11 20:45:48,826 DEBUG HandlerThread:1724 [system_info.py:_save_patches():82] Saving git patches
31
+ 2024-05-11 20:45:48,888 INFO Thread-16 :1724 [dir_watcher.py:_on_file_created():271] file/dir created: .\wandb\run-20240511_204545-zlcauue2\files\code\src\pipeline.py
32
+ 2024-05-11 20:45:48,889 INFO Thread-16 :1724 [dir_watcher.py:_on_file_created():271] file/dir created: .\wandb\run-20240511_204545-zlcauue2\files\code
33
+ 2024-05-11 20:45:48,889 INFO Thread-16 :1724 [dir_watcher.py:_on_file_created():271] file/dir created: .\wandb\run-20240511_204545-zlcauue2\files\code\src
34
+ 2024-05-11 20:45:49,294 DEBUG HandlerThread:1724 [system_info.py:_save_patches():124] Saving git patches done
35
+ 2024-05-11 20:45:49,296 INFO HandlerThread:1724 [system_monitor.py:probe():229] Finished publishing system info
36
+ 2024-05-11 20:45:49,309 DEBUG SenderThread:1724 [sender.py:send():378] send: files
37
+ 2024-05-11 20:45:49,309 INFO SenderThread:1724 [sender.py:_save_file():1389] saving file wandb-metadata.json with policy now
38
+ 2024-05-11 20:45:49,311 INFO SenderThread:1724 [sender.py:_save_file():1389] saving file code\src\pipeline.py with policy now
39
+ 2024-05-11 20:45:49,312 INFO SenderThread:1724 [sender.py:_save_file():1389] saving file diff.patch with policy now
40
+ 2024-05-11 20:45:49,799 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: python_packages
41
+ 2024-05-11 20:45:49,799 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: python_packages
42
+ 2024-05-11 20:45:49,805 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: stop_status
43
+ 2024-05-11 20:45:49,805 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: stop_status
44
+ 2024-05-11 20:45:49,915 INFO Thread-16 :1724 [dir_watcher.py:_on_file_created():271] file/dir created: .\wandb\run-20240511_204545-zlcauue2\files\wandb-metadata.json
45
+ 2024-05-11 20:45:49,916 INFO Thread-16 :1724 [dir_watcher.py:_on_file_created():271] file/dir created: .\wandb\run-20240511_204545-zlcauue2\files\diff.patch
46
+ 2024-05-11 20:45:49,916 INFO Thread-16 :1724 [dir_watcher.py:_on_file_created():271] file/dir created: .\wandb\run-20240511_204545-zlcauue2\files\requirements.txt
47
+ 2024-05-11 20:45:51,321 DEBUG SenderThread:1724 [sender.py:send():378] send: telemetry
48
+ 2024-05-11 20:45:51,321 DEBUG SenderThread:1724 [sender.py:send():378] send: metric
49
+ 2024-05-11 20:45:51,321 DEBUG SenderThread:1724 [sender.py:send():378] send: telemetry
50
+ 2024-05-11 20:45:51,321 DEBUG SenderThread:1724 [sender.py:send():378] send: telemetry
51
+ 2024-05-11 20:45:51,321 DEBUG SenderThread:1724 [sender.py:send():378] send: metric
52
+ 2024-05-11 20:45:51,321 WARNING SenderThread:1724 [sender.py:send_metric():1340] Seen metric with glob (shouldn't happen)
53
+ 2024-05-11 20:45:51,323 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
54
+ 2024-05-11 20:45:51,525 INFO wandb-upload_0:1724 [upload_job.py:push():130] Uploaded file C:\Users\Anind\AppData\Local\Temp\tmp1u335h0vwandb\wd17oylj-wandb-metadata.json
55
+ 2024-05-11 20:45:51,933 INFO Thread-16 :1724 [dir_watcher.py:_on_file_created():271] file/dir created: .\wandb\run-20240511_204545-zlcauue2\files\output.log
56
+ 2024-05-11 20:45:52,357 INFO wandb-upload_1:1724 [upload_job.py:push():130] Uploaded file C:\Users\Anind\AppData\Local\Temp\tmp1u335h0vwandb\ahqjl4rf-code/src/pipeline.py
57
+ 2024-05-11 20:45:52,411 INFO wandb-upload_2:1724 [upload_job.py:push():130] Uploaded file C:\Users\Anind\AppData\Local\Temp\tmp1u335h0vwandb\fxguvjri-diff.patch
58
+ 2024-05-11 20:45:53,972 INFO Thread-16 :1724 [dir_watcher.py:_on_file_modified():288] file/dir modified: .\wandb\run-20240511_204545-zlcauue2\files\output.log
59
+ 2024-05-11 20:45:56,496 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
60
+ 2024-05-11 20:46:01,533 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
61
+ 2024-05-11 20:46:04,813 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: stop_status
62
+ 2024-05-11 20:46:04,814 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: stop_status
63
+ 2024-05-11 20:46:07,254 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
64
+ 2024-05-11 20:46:12,293 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
65
+ 2024-05-11 20:46:17,404 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
66
+ 2024-05-11 20:46:18,520 INFO Thread-16 :1724 [dir_watcher.py:_on_file_modified():288] file/dir modified: .\wandb\run-20240511_204545-zlcauue2\files\config.yaml
67
+ 2024-05-11 20:46:19,837 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: stop_status
68
+ 2024-05-11 20:46:19,838 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: stop_status
69
+ 2024-05-11 20:46:23,324 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
70
+ 2024-05-11 20:46:28,378 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
71
+ 2024-05-11 20:46:33,431 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
72
+ 2024-05-11 20:46:34,853 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: stop_status
73
+ 2024-05-11 20:46:34,854 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: stop_status
74
+ 2024-05-11 20:46:39,564 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
75
+ 2024-05-11 20:46:44,737 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
76
+ 2024-05-11 20:46:46,336 INFO Thread-16 :1724 [dir_watcher.py:_on_file_modified():288] file/dir modified: .\wandb\run-20240511_204545-zlcauue2\files\output.log
77
+ 2024-05-11 20:46:48,718 DEBUG SystemMonitor:1724 [system_monitor.py:_start():172] Starting system metrics aggregation loop
78
+ 2024-05-11 20:46:48,719 DEBUG SenderThread:1724 [sender.py:send():378] send: stats
79
+ 2024-05-11 20:46:49,863 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
80
+ 2024-05-11 20:46:49,884 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: stop_status
81
+ 2024-05-11 20:46:49,884 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: stop_status
82
+ 2024-05-11 20:46:55,357 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
83
+ 2024-05-11 20:47:00,459 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
84
+ 2024-05-11 20:47:04,899 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: stop_status
85
+ 2024-05-11 20:47:04,900 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: stop_status
86
+ 2024-05-11 20:47:06,361 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
87
+ 2024-05-11 20:47:08,942 INFO Thread-16 :1724 [dir_watcher.py:_on_file_modified():288] file/dir modified: .\wandb\run-20240511_204545-zlcauue2\files\output.log
88
+ 2024-05-11 20:47:12,327 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
89
+ 2024-05-11 20:47:17,418 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
90
+ 2024-05-11 20:47:18,731 DEBUG SenderThread:1724 [sender.py:send():378] send: stats
91
+ 2024-05-11 20:47:19,917 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: stop_status
92
+ 2024-05-11 20:47:19,918 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: stop_status
93
+ 2024-05-11 20:47:23,380 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
94
+ 2024-05-11 20:47:28,435 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
95
+ 2024-05-11 20:47:28,528 INFO Thread-16 :1724 [dir_watcher.py:_on_file_modified():288] file/dir modified: .\wandb\run-20240511_204545-zlcauue2\files\output.log
96
+ 2024-05-11 20:47:33,489 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
97
+ 2024-05-11 20:47:34,924 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: stop_status
98
+ 2024-05-11 20:47:34,927 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: stop_status
99
+ 2024-05-11 20:47:39,395 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
100
+ 2024-05-11 20:47:44,444 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
101
+ 2024-05-11 20:47:48,741 DEBUG SenderThread:1724 [sender.py:send():378] send: stats
102
+ 2024-05-11 20:47:49,747 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
103
+ 2024-05-11 20:47:49,920 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: stop_status
104
+ 2024-05-11 20:47:49,920 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: stop_status
105
+ 2024-05-11 20:47:55,514 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
106
+ 2024-05-11 20:48:00,570 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
107
+ 2024-05-11 20:48:04,918 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: stop_status
108
+ 2024-05-11 20:48:04,920 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: stop_status
109
+ 2024-05-11 20:48:06,371 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
110
+ 2024-05-11 20:48:11,439 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
111
+ 2024-05-11 20:48:16,477 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
112
+ 2024-05-11 20:48:18,755 DEBUG SenderThread:1724 [sender.py:send():378] send: stats
113
+ 2024-05-11 20:48:19,914 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: stop_status
114
+ 2024-05-11 20:48:19,915 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: stop_status
115
+ 2024-05-11 20:48:22,425 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
116
+ 2024-05-11 20:48:27,482 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
117
+ 2024-05-11 20:48:32,598 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
118
+ 2024-05-11 20:48:34,923 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: stop_status
119
+ 2024-05-11 20:48:34,925 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: stop_status
120
+ 2024-05-11 20:48:38,385 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
121
+ 2024-05-11 20:48:42,903 INFO Thread-16 :1724 [dir_watcher.py:_on_file_modified():288] file/dir modified: .\wandb\run-20240511_204545-zlcauue2\files\output.log
122
+ 2024-05-11 20:48:44,016 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
123
+ 2024-05-11 20:48:48,770 DEBUG SenderThread:1724 [sender.py:send():378] send: stats
124
+ 2024-05-11 20:48:49,775 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
125
+ 2024-05-11 20:48:49,950 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: stop_status
126
+ 2024-05-11 20:48:49,953 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: stop_status
127
+ 2024-05-11 20:48:55,460 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
128
+ 2024-05-11 20:49:00,494 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
129
+ 2024-05-11 20:49:04,962 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: stop_status
130
+ 2024-05-11 20:49:04,962 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: stop_status
131
+ 2024-05-11 20:49:06,480 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
132
+ 2024-05-11 20:49:07,254 INFO Thread-16 :1724 [dir_watcher.py:_on_file_modified():288] file/dir modified: .\wandb\run-20240511_204545-zlcauue2\files\output.log
133
+ 2024-05-11 20:49:11,530 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
134
+ 2024-05-11 20:49:16,589 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
135
+ 2024-05-11 20:49:18,784 DEBUG SenderThread:1724 [sender.py:send():378] send: stats
136
+ 2024-05-11 20:49:19,971 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: stop_status
137
+ 2024-05-11 20:49:19,972 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: stop_status
138
+ 2024-05-11 20:49:22,423 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
139
+ 2024-05-11 20:49:26,515 INFO Thread-16 :1724 [dir_watcher.py:_on_file_modified():288] file/dir modified: .\wandb\run-20240511_204545-zlcauue2\files\output.log
140
+ 2024-05-11 20:49:28,221 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
141
+ 2024-05-11 20:49:33,271 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
142
+ 2024-05-11 20:49:34,974 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: stop_status
143
+ 2024-05-11 20:49:34,975 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: stop_status
144
+ 2024-05-11 20:49:38,424 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
145
+ 2024-05-11 20:49:43,452 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
146
+ 2024-05-11 20:49:46,746 INFO Thread-16 :1724 [dir_watcher.py:_on_file_modified():288] file/dir modified: .\wandb\run-20240511_204545-zlcauue2\files\output.log
147
+ 2024-05-11 20:49:48,587 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
148
+ 2024-05-11 20:49:48,792 DEBUG SenderThread:1724 [sender.py:send():378] send: stats
149
+ 2024-05-11 20:49:49,992 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: stop_status
150
+ 2024-05-11 20:49:49,998 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: stop_status
151
+ 2024-05-11 20:49:54,455 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
152
+ 2024-05-11 20:49:59,499 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
153
+ 2024-05-11 20:50:04,888 INFO Thread-16 :1724 [dir_watcher.py:_on_file_modified():288] file/dir modified: .\wandb\run-20240511_204545-zlcauue2\files\output.log
154
+ 2024-05-11 20:50:05,003 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: stop_status
155
+ 2024-05-11 20:50:05,003 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
156
+ 2024-05-11 20:50:05,004 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: stop_status
157
+ 2024-05-11 20:50:10,414 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
158
+ 2024-05-11 20:50:15,453 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
159
+ 2024-05-11 20:50:18,806 DEBUG SenderThread:1724 [sender.py:send():378] send: stats
160
+ 2024-05-11 20:50:20,001 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: stop_status
161
+ 2024-05-11 20:50:20,002 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: stop_status
162
+ 2024-05-11 20:50:21,432 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
163
+ 2024-05-11 20:50:25,236 INFO Thread-16 :1724 [dir_watcher.py:_on_file_modified():288] file/dir modified: .\wandb\run-20240511_204545-zlcauue2\files\output.log
164
+ 2024-05-11 20:50:27,247 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
165
+ 2024-05-11 20:50:32,292 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
166
+ 2024-05-11 20:50:35,008 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: stop_status
167
+ 2024-05-11 20:50:35,008 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: stop_status
168
+ 2024-05-11 20:50:37,519 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
169
+ 2024-05-11 20:50:43,192 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
170
+ 2024-05-11 20:50:45,409 INFO Thread-16 :1724 [dir_watcher.py:_on_file_modified():288] file/dir modified: .\wandb\run-20240511_204545-zlcauue2\files\output.log
171
+ 2024-05-11 20:50:48,234 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
172
+ 2024-05-11 20:50:48,836 DEBUG SenderThread:1724 [sender.py:send():378] send: stats
173
+ 2024-05-11 20:50:50,024 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: stop_status
174
+ 2024-05-11 20:50:50,031 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: stop_status
175
+ 2024-05-11 20:50:53,458 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
176
+ 2024-05-11 20:50:58,491 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
177
+ 2024-05-11 20:51:02,543 INFO Thread-16 :1724 [dir_watcher.py:_on_file_modified():288] file/dir modified: .\wandb\run-20240511_204545-zlcauue2\files\output.log
178
+ 2024-05-11 20:51:04,405 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
179
+ 2024-05-11 20:51:05,036 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: stop_status
180
+ 2024-05-11 20:51:05,037 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: stop_status
181
+ 2024-05-11 20:51:09,525 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
182
+ 2024-05-11 20:51:14,547 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
183
+ 2024-05-11 20:51:18,842 DEBUG SenderThread:1724 [sender.py:send():378] send: stats
184
+ 2024-05-11 20:51:19,854 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
185
+ 2024-05-11 20:51:20,061 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: stop_status
186
+ 2024-05-11 20:51:20,062 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: stop_status
187
+ 2024-05-11 20:51:22,715 INFO Thread-16 :1724 [dir_watcher.py:_on_file_modified():288] file/dir modified: .\wandb\run-20240511_204545-zlcauue2\files\output.log
188
+ 2024-05-11 20:51:24,898 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
189
+ 2024-05-11 20:51:29,926 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
190
+ 2024-05-11 20:51:34,977 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
191
+ 2024-05-11 20:51:35,067 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: stop_status
192
+ 2024-05-11 20:51:35,068 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: stop_status
193
+ 2024-05-11 20:51:40,678 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
194
+ 2024-05-11 20:51:40,943 INFO Thread-16 :1724 [dir_watcher.py:_on_file_modified():288] file/dir modified: .\wandb\run-20240511_204545-zlcauue2\files\output.log
195
+ 2024-05-11 20:51:45,745 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
196
+ 2024-05-11 20:51:48,852 DEBUG SenderThread:1724 [sender.py:send():378] send: stats
197
+ 2024-05-11 20:51:50,087 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: stop_status
198
+ 2024-05-11 20:51:50,087 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: stop_status
199
+ 2024-05-11 20:51:51,458 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
200
+ 2024-05-11 20:51:56,515 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
201
+ 2024-05-11 20:52:01,988 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
202
+ 2024-05-11 20:52:03,507 DEBUG SenderThread:1724 [sender.py:send():378] send: telemetry
203
+ 2024-05-11 20:52:03,532 DEBUG SenderThread:1724 [sender.py:send():378] send: exit
204
+ 2024-05-11 20:52:03,533 INFO SenderThread:1724 [sender.py:send_exit():585] handling exit code: 0
205
+ 2024-05-11 20:52:03,563 INFO SenderThread:1724 [sender.py:send_exit():587] handling runtime: 374
206
+ 2024-05-11 20:52:03,566 INFO SenderThread:1724 [sender.py:_save_file():1389] saving file wandb-summary.json with policy end
207
+ 2024-05-11 20:52:03,571 INFO SenderThread:1724 [sender.py:send_exit():593] send defer
208
+ 2024-05-11 20:52:03,573 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: defer
209
+ 2024-05-11 20:52:03,575 INFO HandlerThread:1724 [handler.py:handle_request_defer():184] handle defer: 0
210
+ 2024-05-11 20:52:03,577 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: defer
211
+ 2024-05-11 20:52:03,577 INFO SenderThread:1724 [sender.py:send_request_defer():609] handle sender defer: 0
212
+ 2024-05-11 20:52:03,577 INFO SenderThread:1724 [sender.py:transition_state():613] send defer: 1
213
+ 2024-05-11 20:52:03,578 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: defer
214
+ 2024-05-11 20:52:03,578 INFO HandlerThread:1724 [handler.py:handle_request_defer():184] handle defer: 1
215
+ 2024-05-11 20:52:03,579 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: defer
216
+ 2024-05-11 20:52:03,579 INFO SenderThread:1724 [sender.py:send_request_defer():609] handle sender defer: 1
217
+ 2024-05-11 20:52:03,579 INFO SenderThread:1724 [sender.py:transition_state():613] send defer: 2
218
+ 2024-05-11 20:52:03,579 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: defer
219
+ 2024-05-11 20:52:03,580 INFO HandlerThread:1724 [handler.py:handle_request_defer():184] handle defer: 2
220
+ 2024-05-11 20:52:03,582 INFO HandlerThread:1724 [system_monitor.py:finish():203] Stopping system monitor
221
+ 2024-05-11 20:52:03,584 DEBUG SystemMonitor:1724 [system_monitor.py:_start():179] Finished system metrics aggregation loop
222
+ 2024-05-11 20:52:03,584 DEBUG SystemMonitor:1724 [system_monitor.py:_start():183] Publishing last batch of metrics
223
+ 2024-05-11 20:52:03,585 INFO HandlerThread:1724 [interfaces.py:finish():200] Joined cpu monitor
224
+ 2024-05-11 20:52:03,585 INFO HandlerThread:1724 [interfaces.py:finish():200] Joined disk monitor
225
+ 2024-05-11 20:52:03,586 INFO HandlerThread:1724 [interfaces.py:finish():200] Joined memory monitor
226
+ 2024-05-11 20:52:03,586 INFO HandlerThread:1724 [interfaces.py:finish():200] Joined network monitor
227
+ 2024-05-11 20:52:03,589 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: defer
228
+ 2024-05-11 20:52:03,589 INFO SenderThread:1724 [sender.py:send_request_defer():609] handle sender defer: 2
229
+ 2024-05-11 20:52:03,589 INFO SenderThread:1724 [sender.py:transition_state():613] send defer: 3
230
+ 2024-05-11 20:52:03,589 DEBUG SenderThread:1724 [sender.py:send():378] send: stats
231
+ 2024-05-11 20:52:03,589 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: defer
232
+ 2024-05-11 20:52:03,589 INFO HandlerThread:1724 [handler.py:handle_request_defer():184] handle defer: 3
233
+ 2024-05-11 20:52:03,591 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: defer
234
+ 2024-05-11 20:52:03,591 INFO SenderThread:1724 [sender.py:send_request_defer():609] handle sender defer: 3
235
+ 2024-05-11 20:52:03,591 INFO SenderThread:1724 [sender.py:transition_state():613] send defer: 4
236
+ 2024-05-11 20:52:03,592 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: defer
237
+ 2024-05-11 20:52:03,592 INFO HandlerThread:1724 [handler.py:handle_request_defer():184] handle defer: 4
238
+ 2024-05-11 20:52:03,592 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: defer
239
+ 2024-05-11 20:52:03,592 INFO SenderThread:1724 [sender.py:send_request_defer():609] handle sender defer: 4
240
+ 2024-05-11 20:52:03,592 INFO SenderThread:1724 [sender.py:transition_state():613] send defer: 5
241
+ 2024-05-11 20:52:03,592 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: defer
242
+ 2024-05-11 20:52:03,592 INFO HandlerThread:1724 [handler.py:handle_request_defer():184] handle defer: 5
243
+ 2024-05-11 20:52:03,594 DEBUG SenderThread:1724 [sender.py:send():378] send: summary
244
+ 2024-05-11 20:52:03,594 INFO SenderThread:1724 [sender.py:_save_file():1389] saving file wandb-summary.json with policy end
245
+ 2024-05-11 20:52:03,596 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: defer
246
+ 2024-05-11 20:52:03,596 INFO SenderThread:1724 [sender.py:send_request_defer():609] handle sender defer: 5
247
+ 2024-05-11 20:52:03,596 INFO SenderThread:1724 [sender.py:transition_state():613] send defer: 6
248
+ 2024-05-11 20:52:03,596 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: defer
249
+ 2024-05-11 20:52:03,596 INFO HandlerThread:1724 [handler.py:handle_request_defer():184] handle defer: 6
250
+ 2024-05-11 20:52:03,597 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: defer
251
+ 2024-05-11 20:52:03,597 INFO SenderThread:1724 [sender.py:send_request_defer():609] handle sender defer: 6
252
+ 2024-05-11 20:52:03,603 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: status_report
253
+ 2024-05-11 20:52:03,970 INFO SenderThread:1724 [sender.py:transition_state():613] send defer: 7
254
+ 2024-05-11 20:52:03,970 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: defer
255
+ 2024-05-11 20:52:03,970 INFO HandlerThread:1724 [handler.py:handle_request_defer():184] handle defer: 7
256
+ 2024-05-11 20:52:03,971 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: defer
257
+ 2024-05-11 20:52:03,971 INFO SenderThread:1724 [sender.py:send_request_defer():609] handle sender defer: 7
258
+ 2024-05-11 20:52:04,463 INFO Thread-16 :1724 [dir_watcher.py:_on_file_modified():288] file/dir modified: .\wandb\run-20240511_204545-zlcauue2\files\config.yaml
259
+ 2024-05-11 20:52:04,464 INFO Thread-16 :1724 [dir_watcher.py:_on_file_created():271] file/dir created: .\wandb\run-20240511_204545-zlcauue2\files\wandb-summary.json
260
+ 2024-05-11 20:52:04,536 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: poll_exit
261
+ 2024-05-11 20:52:05,475 INFO Thread-16 :1724 [dir_watcher.py:_on_file_modified():288] file/dir modified: .\wandb\run-20240511_204545-zlcauue2\files\output.log
262
+ 2024-05-11 20:52:06,606 INFO SenderThread:1724 [sender.py:transition_state():613] send defer: 8
263
+ 2024-05-11 20:52:06,607 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: poll_exit
264
+ 2024-05-11 20:52:06,607 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: defer
265
+ 2024-05-11 20:52:06,615 INFO HandlerThread:1724 [handler.py:handle_request_defer():184] handle defer: 8
266
+ 2024-05-11 20:52:06,616 DEBUG SenderThread:1724 [sender.py:send_request():405] send_request: defer
267
+ 2024-05-11 20:52:06,616 INFO SenderThread:1724 [sender.py:send_request_defer():609] handle sender defer: 8
268
+ 2024-05-11 20:52:06,619 INFO SenderThread:1724 [job_builder.py:build():432] Attempting to build job artifact
269
+ 2024-05-11 20:52:06,627 INFO SenderThread:1724 [job_builder.py:_get_source_type():565] is repo sourced job
270
+ 2024-05-11 20:52:06,772 INFO SenderThread:1724 [job_builder.py:build():541] adding wandb-job metadata file
271
+ 2024-05-11 20:52:06,866 INFO SenderThread:1724 [sender.py:transition_state():613] send defer: 9
272
+ 2024-05-11 20:52:06,866 DEBUG HandlerThread:1724 [handler.py:handle_request():158] handle_request: defer
273
+ 2024-05-11 20:52:06,867 INFO HandlerThread:1724 [handler.py:handle_request_defer():184] handle defer: 9
274
+ 2024-05-11 20:52:06,867 DEBUG SenderThread:1724 [sender.py:send():378] send: artifact
275
+ 2024-05-11 20:52:07,493 INFO Thread-16 :1724 [dir_watcher.py:_on_file_modified():288] file/dir modified: .\wandb\run-20240511_204545-zlcauue2\files\output.log
276
+ 2024-05-11 20:52:10,528 INFO wandb-upload_0:1724 [upload_job.py:push():88] Uploaded file C:\Users\Anind\AppData\Local\wandb\wandb\artifacts\staging\tmp9k54y15w
277
+ 2024-05-11 20:52:10,571 INFO wandb-upload_2:1724 [upload_job.py:push():88] Uploaded file C:\Users\Anind\AppData\Local\Temp\tmp2n1y9k3m\wandb-job.json
278
+ 2024-05-11 20:52:10,577 INFO wandb-upload_1:1724 [upload_job.py:push():88] Uploaded file C:\Users\Anind\AppData\Local\wandb\wandb\artifacts\staging\tmplrk1vi94
279
+ 2024-05-11 20:52:10,580 INFO MainThread:1724 [internal.py:handle_exit():75] Internal process exited
src/wandb/run-20240511_204545-zlcauue2/logs/debug.log ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 2024-05-11 20:45:45,821 INFO MainThread:12220 [wandb_setup.py:_flush():76] Current SDK version is 0.17.0
2
+ 2024-05-11 20:45:45,822 INFO MainThread:12220 [wandb_setup.py:_flush():76] Configure stats pid to 12220
3
+ 2024-05-11 20:45:45,822 INFO MainThread:12220 [wandb_setup.py:_flush():76] Loading settings from C:\Users\Anind\.config\wandb\settings
4
+ 2024-05-11 20:45:45,822 INFO MainThread:12220 [wandb_setup.py:_flush():76] Loading settings from D:\Official\Reseach Projects\Personal Projects\Machine Learning\Deep Learning\Counterfactual-Image-Generation-using-CycleGAN\src\wandb\settings
5
+ 2024-05-11 20:45:45,822 INFO MainThread:12220 [wandb_setup.py:_flush():76] Loading settings from environment variables: {}
6
+ 2024-05-11 20:45:45,823 INFO MainThread:12220 [wandb_setup.py:_flush():76] Applying setup settings: {'_disable_service': False}
7
+ 2024-05-11 20:45:45,823 INFO MainThread:12220 [wandb_setup.py:_flush():76] Inferring run settings from compute environment: {'program_relpath': 'src\\pipeline.py', 'program_abspath': 'D:\\Official\\Reseach Projects\\Personal Projects\\Machine Learning\\Deep Learning\\Counterfactual-Image-Generation-using-CycleGAN\\src\\pipeline.py', 'program': 'D:\\Official\\Reseach Projects\\Personal Projects\\Machine Learning\\Deep Learning\\Counterfactual-Image-Generation-using-CycleGAN\\src\\pipeline.py'}
8
+ 2024-05-11 20:45:45,824 INFO MainThread:12220 [wandb_setup.py:_flush():76] Applying login settings: {}
9
+ 2024-05-11 20:45:45,825 INFO MainThread:12220 [wandb_init.py:_log_setup():520] Logging user logs to .\wandb\run-20240511_204545-zlcauue2\logs\debug.log
10
+ 2024-05-11 20:45:45,825 INFO MainThread:12220 [wandb_init.py:_log_setup():521] Logging internal logs to .\wandb\run-20240511_204545-zlcauue2\logs\debug-internal.log
11
+ 2024-05-11 20:45:45,826 INFO MainThread:12220 [wandb_init.py:init():560] calling init triggers
12
+ 2024-05-11 20:45:45,826 INFO MainThread:12220 [wandb_init.py:init():567] wandb.init called with sweep_config: {}
13
+ config: {}
14
+ 2024-05-11 20:45:45,826 INFO MainThread:12220 [wandb_init.py:init():610] starting backend
15
+ 2024-05-11 20:45:45,826 INFO MainThread:12220 [wandb_init.py:init():614] setting up manager
16
+ 2024-05-11 20:45:45,833 INFO MainThread:12220 [backend.py:_multiprocessing_setup():105] multiprocessing start_methods=spawn, using: spawn
17
+ 2024-05-11 20:45:45,842 INFO MainThread:12220 [wandb_init.py:init():622] backend started and connected
18
+ 2024-05-11 20:45:45,852 INFO MainThread:12220 [wandb_init.py:init():711] updated telemetry
19
+ 2024-05-11 20:45:45,969 INFO MainThread:12220 [wandb_init.py:init():744] communicating run to backend with 90.0 second timeout
20
+ 2024-05-11 20:45:47,886 INFO MainThread:12220 [wandb_run.py:_on_init():2396] communicating current version
21
+ 2024-05-11 20:45:48,608 INFO MainThread:12220 [wandb_run.py:_on_init():2405] got version response
22
+ 2024-05-11 20:45:48,608 INFO MainThread:12220 [wandb_init.py:init():795] starting run threads in backend
23
+ 2024-05-11 20:45:49,815 INFO MainThread:12220 [wandb_run.py:_console_start():2374] atexit reg
24
+ 2024-05-11 20:45:49,816 INFO MainThread:12220 [wandb_run.py:_redirect():2229] redirect: wrap_raw
25
+ 2024-05-11 20:45:49,816 INFO MainThread:12220 [wandb_run.py:_redirect():2294] Wrapping output streams.
26
+ 2024-05-11 20:45:49,816 INFO MainThread:12220 [wandb_run.py:_redirect():2319] Redirects installed.
27
+ 2024-05-11 20:45:49,820 INFO MainThread:12220 [wandb_init.py:init():838] run started, returning control to user process
28
+ 2024-05-11 20:52:03,512 INFO MainThread:12220 [wandb_run.py:_finish():2103] finishing run anindyamitra2018/CycleGAN-CFE/zlcauue2
29
+ 2024-05-11 20:52:03,519 INFO MainThread:12220 [wandb_run.py:_atexit_cleanup():2343] got exitcode: 0
30
+ 2024-05-11 20:52:03,527 INFO MainThread:12220 [wandb_run.py:_restore():2326] restore
31
+ 2024-05-11 20:52:03,529 INFO MainThread:12220 [wandb_run.py:_restore():2332] restore done
src/wandb/run-20240511_204545-zlcauue2/run-zlcauue2.wandb ADDED
Binary file (15.4 kB). View file