HAMIM-ML commited on
Commit
3b1eb75
·
1 Parent(s): e623e7e

model traine upaded 2.O

Browse files
Files changed (45) hide show
  1. lightning_logs/version_20/events.out.tfevents.1724522693.Hakim.28412.1 +0 -0
  2. lightning_logs/version_20/hparams.yaml +7 -0
  3. lightning_logs/version_21/events.out.tfevents.1724522811.Hakim.28412.2 +0 -0
  4. lightning_logs/version_21/hparams.yaml +7 -0
  5. lightning_logs/version_22/events.out.tfevents.1724523857.Hakim.28412.3 +0 -0
  6. lightning_logs/version_22/hparams.yaml +7 -0
  7. lightning_logs/version_23/events.out.tfevents.1724524019.Hakim.28412.4 +0 -0
  8. lightning_logs/version_23/hparams.yaml +7 -0
  9. lightning_logs/version_24/events.out.tfevents.1724524378.Hakim.28412.5 +0 -0
  10. lightning_logs/version_24/hparams.yaml +7 -0
  11. lightning_logs/version_25/events.out.tfevents.1724524539.Hakim.21156.0 +0 -0
  12. lightning_logs/version_25/hparams.yaml +7 -0
  13. lightning_logs/version_26/events.out.tfevents.1724524673.Hakim.21156.1 +0 -0
  14. lightning_logs/version_26/hparams.yaml +7 -0
  15. lightning_logs/version_27/events.out.tfevents.1724524815.Hakim.21156.2 +0 -0
  16. lightning_logs/version_27/hparams.yaml +7 -0
  17. lightning_logs/version_28/events.out.tfevents.1724525159.Hakim.29576.0 +0 -0
  18. lightning_logs/version_28/hparams.yaml +7 -0
  19. lightning_logs/version_29/events.out.tfevents.1724525341.Hakim.17352.0 +0 -0
  20. lightning_logs/version_29/hparams.yaml +7 -0
  21. lightning_logs/version_30/events.out.tfevents.1724525743.Hakim.29360.0 +0 -0
  22. lightning_logs/version_30/hparams.yaml +7 -0
  23. lightning_logs/version_31/events.out.tfevents.1724525761.Hakim.29360.1 +0 -0
  24. lightning_logs/version_31/hparams.yaml +7 -0
  25. lightning_logs/version_32/events.out.tfevents.1724525864.Hakim.24228.0 +0 -0
  26. lightning_logs/version_32/hparams.yaml +7 -0
  27. lightning_logs/version_33/events.out.tfevents.1724526360.Hakim.28084.0 +0 -0
  28. lightning_logs/version_33/hparams.yaml +7 -0
  29. lightning_logs/version_34/events.out.tfevents.1724526444.Hakim.28084.1 +0 -0
  30. lightning_logs/version_34/hparams.yaml +7 -0
  31. lightning_logs/version_35/events.out.tfevents.1724526592.Hakim.26944.0 +0 -0
  32. lightning_logs/version_35/hparams.yaml +7 -0
  33. lightning_logs/version_36/events.out.tfevents.1724527309.Hakim.29344.0 +0 -0
  34. lightning_logs/version_36/hparams.yaml +7 -0
  35. params.yaml +0 -2
  36. research/data_transformation.ipynb +379 -22
  37. research/lightning_logs/version_0/events.out.tfevents.1724524991.Hakim.26396.0 +0 -0
  38. research/lightning_logs/version_0/hparams.yaml +7 -0
  39. research/lightning_logs/version_1/events.out.tfevents.1724525009.Hakim.26396.1 +0 -0
  40. research/lightning_logs/version_1/hparams.yaml +7 -0
  41. research/model_building.ipynb +2 -4
  42. src/imagecolorization/config/configuration.py +1 -0
  43. src/imagecolorization/conponents/model_building.py +39 -35
  44. src/imagecolorization/conponents/model_trainer.py +47 -41
  45. src/imagecolorization/pipeline/stage_04_model_trainer.py +1 -1
lightning_logs/version_20/events.out.tfevents.1724522693.Hakim.28412.1 ADDED
Binary file (683 Bytes). View file
 
lightning_logs/version_20/hparams.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ display_step: 10
2
+ in_channels: 1
3
+ lambda_gp: 10
4
+ lambda_r1: 10
5
+ lambda_recon: 100
6
+ learning_rate: 0.0002
7
+ out_channels: 2
lightning_logs/version_21/events.out.tfevents.1724522811.Hakim.28412.2 ADDED
Binary file (683 Bytes). View file
 
lightning_logs/version_21/hparams.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ display_step: 10
2
+ in_channels: 1
3
+ lambda_gp: 10
4
+ lambda_r1: 10
5
+ lambda_recon: 100
6
+ learning_rate: 0.0002
7
+ out_channels: 2
lightning_logs/version_22/events.out.tfevents.1724523857.Hakim.28412.3 ADDED
Binary file (683 Bytes). View file
 
lightning_logs/version_22/hparams.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ display_step: 10
2
+ in_channels: 1
3
+ lambda_gp: 10
4
+ lambda_r1: 10
5
+ lambda_recon: 100
6
+ learning_rate: 0.0002
7
+ out_channels: 2
lightning_logs/version_23/events.out.tfevents.1724524019.Hakim.28412.4 ADDED
Binary file (683 Bytes). View file
 
lightning_logs/version_23/hparams.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ display_step: 10
2
+ in_channels: 1
3
+ lambda_gp: 10
4
+ lambda_r1: 10
5
+ lambda_recon: 100
6
+ learning_rate: 0.0002
7
+ out_channels: 2
lightning_logs/version_24/events.out.tfevents.1724524378.Hakim.28412.5 ADDED
Binary file (683 Bytes). View file
 
lightning_logs/version_24/hparams.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ display_step: 10
2
+ in_channels: 1
3
+ lambda_gp: 10
4
+ lambda_r1: 10
5
+ lambda_recon: 100
6
+ learning_rate: 0.0002
7
+ out_channels: 2
lightning_logs/version_25/events.out.tfevents.1724524539.Hakim.21156.0 ADDED
Binary file (683 Bytes). View file
 
lightning_logs/version_25/hparams.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ display_step: 10
2
+ in_channels: 1
3
+ lambda_gp: 10
4
+ lambda_r1: 10
5
+ lambda_recon: 100
6
+ learning_rate: 0.0002
7
+ out_channels: 2
lightning_logs/version_26/events.out.tfevents.1724524673.Hakim.21156.1 ADDED
Binary file (683 Bytes). View file
 
lightning_logs/version_26/hparams.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ display_step: 10
2
+ in_channels: 1
3
+ lambda_gp: 10
4
+ lambda_r1: 10
5
+ lambda_recon: 100
6
+ learning_rate: 0.0002
7
+ out_channels: 2
lightning_logs/version_27/events.out.tfevents.1724524815.Hakim.21156.2 ADDED
Binary file (683 Bytes). View file
 
lightning_logs/version_27/hparams.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ display_step: 10
2
+ in_channels: 1
3
+ lambda_gp: 10
4
+ lambda_r1: 10
5
+ lambda_recon: 100
6
+ learning_rate: 0.0002
7
+ out_channels: 2
lightning_logs/version_28/events.out.tfevents.1724525159.Hakim.29576.0 ADDED
Binary file (683 Bytes). View file
 
lightning_logs/version_28/hparams.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ display_step: 10
2
+ in_channels: 1
3
+ lambda_gp: 10
4
+ lambda_r1: 10
5
+ lambda_recon: 100
6
+ learning_rate: 0.0002
7
+ out_channels: 2
lightning_logs/version_29/events.out.tfevents.1724525341.Hakim.17352.0 ADDED
Binary file (683 Bytes). View file
 
lightning_logs/version_29/hparams.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ display_step: 10
2
+ in_channels: 1
3
+ lambda_gp: 10
4
+ lambda_r1: 10
5
+ lambda_recon: 100
6
+ learning_rate: 0.0002
7
+ out_channels: 2
lightning_logs/version_30/events.out.tfevents.1724525743.Hakim.29360.0 ADDED
Binary file (683 Bytes). View file
 
lightning_logs/version_30/hparams.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ display_step: 10
2
+ in_channels: 1
3
+ lambda_gp: 10
4
+ lambda_r1: 10
5
+ lambda_recon: 100
6
+ learning_rate: 0.0002
7
+ out_channels: 2
lightning_logs/version_31/events.out.tfevents.1724525761.Hakim.29360.1 ADDED
Binary file (683 Bytes). View file
 
lightning_logs/version_31/hparams.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ display_step: 10
2
+ in_channels: 1
3
+ lambda_gp: 10
4
+ lambda_r1: 10
5
+ lambda_recon: 100
6
+ learning_rate: 0.0002
7
+ out_channels: 2
lightning_logs/version_32/events.out.tfevents.1724525864.Hakim.24228.0 ADDED
Binary file (683 Bytes). View file
 
lightning_logs/version_32/hparams.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ display_step: 10
2
+ in_channels: 1
3
+ lambda_gp: 10
4
+ lambda_r1: 10
5
+ lambda_recon: 100
6
+ learning_rate: 0.0002
7
+ out_channels: 2
lightning_logs/version_33/events.out.tfevents.1724526360.Hakim.28084.0 ADDED
Binary file (683 Bytes). View file
 
lightning_logs/version_33/hparams.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ display_step: 10
2
+ in_channels: 1
3
+ lambda_gp: 10
4
+ lambda_r1: 10
5
+ lambda_recon: 100
6
+ learning_rate: 0.0002
7
+ out_channels: 3
lightning_logs/version_34/events.out.tfevents.1724526444.Hakim.28084.1 ADDED
Binary file (683 Bytes). View file
 
lightning_logs/version_34/hparams.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ display_step: 10
2
+ in_channels: 1
3
+ lambda_gp: 10
4
+ lambda_r1: 10
5
+ lambda_recon: 100
6
+ learning_rate: 0.0002
7
+ out_channels: 2
lightning_logs/version_35/events.out.tfevents.1724526592.Hakim.26944.0 ADDED
Binary file (683 Bytes). View file
 
lightning_logs/version_35/hparams.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ display_step: 10
2
+ in_channels: 1
3
+ lambda_gp: 10
4
+ lambda_r1: 10
5
+ lambda_recon: 100
6
+ learning_rate: 0.0002
7
+ out_channels: 2
lightning_logs/version_36/events.out.tfevents.1724527309.Hakim.29344.0 ADDED
Binary file (683 Bytes). View file
 
lightning_logs/version_36/hparams.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ display_step: 10
2
+ in_channels: 1
3
+ lambda_gp: 10
4
+ lambda_r1: 10
5
+ lambda_recon: 100
6
+ learning_rate: 0.0002
7
+ out_channels: 2
params.yaml CHANGED
@@ -28,6 +28,4 @@ IN_CHANNELS: 3
28
  LEARNING_RATE : 2e-4
29
  LAMBDA_RECON : 100
30
  DISPLAY_STEP : 10
31
- INPUT_CHANNELS : 1
32
- OUTPUT_CHANNELS : 2
33
  EPOCH : 1
 
28
  LEARNING_RATE : 2e-4
29
  LAMBDA_RECON : 100
30
  DISPLAY_STEP : 10
 
 
31
  EPOCH : 1
research/data_transformation.ipynb CHANGED
@@ -2,7 +2,7 @@
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
- "execution_count": 2,
6
  "metadata": {},
7
  "outputs": [],
8
  "source": [
@@ -12,7 +12,7 @@
12
  },
13
  {
14
  "cell_type": "code",
15
- "execution_count": 3,
16
  "metadata": {},
17
  "outputs": [
18
  {
@@ -21,7 +21,7 @@
21
  "'c:\\\\mlops project\\\\image-colorization-mlops'"
22
  ]
23
  },
24
- "execution_count": 3,
25
  "metadata": {},
26
  "output_type": "execute_result"
27
  }
@@ -32,7 +32,7 @@
32
  },
33
  {
34
  "cell_type": "code",
35
- "execution_count": 4,
36
  "metadata": {},
37
  "outputs": [],
38
  "source": [
@@ -51,7 +51,7 @@
51
  },
52
  {
53
  "cell_type": "code",
54
- "execution_count": 5,
55
  "metadata": {},
56
  "outputs": [],
57
  "source": [
@@ -88,7 +88,7 @@
88
  },
89
  {
90
  "cell_type": "code",
91
- "execution_count": 6,
92
  "metadata": {},
93
  "outputs": [],
94
  "source": [
@@ -97,27 +97,31 @@
97
  "from torch.utils.data import Dataset\n",
98
  "from torchvision import transforms\n",
99
  "\n",
100
- "class ImageColorizationDataset(Dataset):\n",
101
- " def __init__(self, dataset, image_size, transform=None):\n",
 
 
 
102
  " self.dataset = dataset\n",
103
  " self.transform = transform\n",
104
- " self.image_size = tuple(image_size) \n",
 
105
  " def __len__(self):\n",
106
  " return len(self.dataset[0])\n",
107
  " \n",
108
  " def __getitem__(self, idx):\n",
109
- " L = np.array(self.dataset[0][idx]).reshape(self.image_size)\n",
110
  " L = transforms.ToTensor()(L)\n",
111
  " \n",
112
  " ab = np.array(self.dataset[1][idx])\n",
113
  " ab = transforms.ToTensor()(ab)\n",
114
  " \n",
115
- " return ab, L"
116
  ]
117
  },
118
  {
119
  "cell_type": "code",
120
- "execution_count": 11,
121
  "metadata": {},
122
  "outputs": [],
123
  "source": [
@@ -142,9 +146,11 @@
142
  " def get_datasets(self, dataset):\n",
143
  " train_dataset = ImageColorizationDataset(\n",
144
  " dataset=dataset,\n",
 
145
  " )\n",
146
  " test_dataset = ImageColorizationDataset(\n",
147
  " dataset=dataset,\n",
 
148
  " )\n",
149
  " \n",
150
  " return train_dataset, test_dataset\n",
@@ -172,18 +178,41 @@
172
  },
173
  {
174
  "cell_type": "code",
175
- "execution_count": 12,
176
  "metadata": {},
177
  "outputs": [
178
  {
179
  "name": "stdout",
180
  "output_type": "stream",
181
  "text": [
182
- "[2024-08-24 19:09:25,021: INFO: common: yaml file: config\\config.yaml loaded successfully]\n",
183
- "[2024-08-24 19:09:25,024: INFO: common: yaml file: params.yaml loaded successfully]\n",
184
- "[2024-08-24 19:09:25,026: INFO: common: created directory at: artifacts]\n",
185
- "[2024-08-24 19:09:43,417: INFO: 3400243030: Train dataset saved at: artifacts/data_transformation\\train_dataset.pt]\n",
186
- "[2024-08-24 19:09:43,440: INFO: 3400243030: Test dataset saved at: artifacts/data_transformation\\test_dataset.pt]\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
187
  ]
188
  }
189
  ],
@@ -196,22 +225,350 @@
196
  " # Load the dataset\n",
197
  " dataset = data_transformation.load_data()\n",
198
  " \n",
199
- " # Get the dataloader using the loaded dataset\n",
200
  " train_dataset, test_dataset = data_transformation.get_datasets(dataset)\n",
201
  " \n",
202
  " # Perform any further operations (e.g., saving the dataset)\n",
203
  " data_transformation.save_datasets(train_dataset, test_dataset)\n",
204
  " \n",
 
 
 
 
 
205
  "except Exception as e:\n",
206
- " raise e\n"
207
  ]
208
  },
209
  {
210
  "cell_type": "code",
211
- "execution_count": null,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212
  "metadata": {},
213
  "outputs": [],
214
- "source": []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
  },
216
  {
217
  "cell_type": "code",
 
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
+ "execution_count": 1,
6
  "metadata": {},
7
  "outputs": [],
8
  "source": [
 
12
  },
13
  {
14
  "cell_type": "code",
15
+ "execution_count": 2,
16
  "metadata": {},
17
  "outputs": [
18
  {
 
21
  "'c:\\\\mlops project\\\\image-colorization-mlops'"
22
  ]
23
  },
24
+ "execution_count": 2,
25
  "metadata": {},
26
  "output_type": "execute_result"
27
  }
 
32
  },
33
  {
34
  "cell_type": "code",
35
+ "execution_count": 3,
36
  "metadata": {},
37
  "outputs": [],
38
  "source": [
 
51
  },
52
  {
53
  "cell_type": "code",
54
+ "execution_count": 4,
55
  "metadata": {},
56
  "outputs": [],
57
  "source": [
 
88
  },
89
  {
90
  "cell_type": "code",
91
+ "execution_count": 5,
92
  "metadata": {},
93
  "outputs": [],
94
  "source": [
 
97
  "from torch.utils.data import Dataset\n",
98
  "from torchvision import transforms\n",
99
  "\n",
100
+ " \n",
101
+ " \n",
102
+ " \n",
103
+ "class ImageColorizationDataset:\n",
104
+ " def __init__(self, dataset, image_size, transform = None):\n",
105
  " self.dataset = dataset\n",
106
  " self.transform = transform\n",
107
+ " self.image_size = tuple(image_size)\n",
108
+ " \n",
109
  " def __len__(self):\n",
110
  " return len(self.dataset[0])\n",
111
  " \n",
112
  " def __getitem__(self, idx):\n",
113
+ " L = np.array(self.dataset[0][idx]).reshape(self.image_size)\n",
114
  " L = transforms.ToTensor()(L)\n",
115
  " \n",
116
  " ab = np.array(self.dataset[1][idx])\n",
117
  " ab = transforms.ToTensor()(ab)\n",
118
  " \n",
119
+ " return ab , L"
120
  ]
121
  },
122
  {
123
  "cell_type": "code",
124
+ "execution_count": 12,
125
  "metadata": {},
126
  "outputs": [],
127
  "source": [
 
146
  " def get_datasets(self, dataset):\n",
147
  " train_dataset = ImageColorizationDataset(\n",
148
  " dataset=dataset,\n",
149
+ " image_size=self.config.IMAGE_SIZE\n",
150
  " )\n",
151
  " test_dataset = ImageColorizationDataset(\n",
152
  " dataset=dataset,\n",
153
+ " image_size=self.config.IMAGE_SIZE\n",
154
  " )\n",
155
  " \n",
156
  " return train_dataset, test_dataset\n",
 
178
  },
179
  {
180
  "cell_type": "code",
181
+ "execution_count": 13,
182
  "metadata": {},
183
  "outputs": [
184
  {
185
  "name": "stdout",
186
  "output_type": "stream",
187
  "text": [
188
+ "[2024-08-24 23:35:18,235: INFO: common: yaml file: config\\config.yaml loaded successfully]\n",
189
+ "[2024-08-24 23:35:18,243: INFO: common: yaml file: params.yaml loaded successfully]\n",
190
+ "[2024-08-24 23:35:18,245: INFO: common: created directory at: artifacts]\n",
191
+ "[2024-08-24 23:35:34,541: INFO: 2411080742: Train dataset saved at: artifacts/data_transformation\\train_dataset.pt]\n",
192
+ "[2024-08-24 23:35:34,552: INFO: 2411080742: Test dataset saved at: artifacts/data_transformation\\test_dataset.pt]\n",
193
+ "Train dataset type: <class '__main__.ImageColorizationDataset'>\n",
194
+ "Train dataset length: 5000\n",
195
+ "First item in train dataset: (tensor([[[0.5059, 0.4941, 0.4941, ..., 0.4902, 0.4863, 0.4863],\n",
196
+ " [0.4980, 0.4941, 0.4941, ..., 0.4980, 0.4902, 0.4824],\n",
197
+ " [0.4980, 0.4980, 0.4980, ..., 0.4902, 0.4941, 0.5020],\n",
198
+ " ...,\n",
199
+ " [0.4941, 0.4941, 0.4980, ..., 0.4941, 0.4941, 0.4941],\n",
200
+ " [0.4941, 0.4980, 0.4941, ..., 0.4941, 0.4941, 0.4941],\n",
201
+ " [0.4980, 0.4980, 0.5020, ..., 0.4941, 0.4863, 0.4941]],\n",
202
+ "\n",
203
+ " [[0.5333, 0.5255, 0.5294, ..., 0.5176, 0.5255, 0.5294],\n",
204
+ " [0.5373, 0.5333, 0.5216, ..., 0.5137, 0.5216, 0.5373],\n",
205
+ " [0.5412, 0.5255, 0.5255, ..., 0.5137, 0.5137, 0.5216],\n",
206
+ " ...,\n",
207
+ " [0.5137, 0.5137, 0.5137, ..., 0.5098, 0.5098, 0.5098],\n",
208
+ " [0.5137, 0.5137, 0.5176, ..., 0.5098, 0.5098, 0.5098],\n",
209
+ " [0.5137, 0.5216, 0.5294, ..., 0.5098, 0.5098, 0.5098]]]), tensor([[[0.9294, 0.5294, 0.2941, ..., 0.1373, 0.1451, 0.2471],\n",
210
+ " [0.9176, 0.5961, 0.2824, ..., 0.1608, 0.1922, 0.1843],\n",
211
+ " [0.8431, 0.8471, 0.4078, ..., 0.2863, 0.1882, 0.3216],\n",
212
+ " ...,\n",
213
+ " [0.1569, 0.1765, 0.1490, ..., 0.0431, 0.0314, 0.0314],\n",
214
+ " [0.1569, 0.2196, 0.1843, ..., 0.0314, 0.0275, 0.0392],\n",
215
+ " [0.1647, 0.2353, 0.3098, ..., 0.0471, 0.0510, 0.0588]]]))\n"
216
  ]
217
  }
218
  ],
 
225
  " # Load the dataset\n",
226
  " dataset = data_transformation.load_data()\n",
227
  " \n",
228
+ " # Get the datasets using the loaded dataset\n",
229
  " train_dataset, test_dataset = data_transformation.get_datasets(dataset)\n",
230
  " \n",
231
  " # Perform any further operations (e.g., saving the dataset)\n",
232
  " data_transformation.save_datasets(train_dataset, test_dataset)\n",
233
  " \n",
234
+ " # Print information about the train dataset\n",
235
+ " print(f\"Train dataset type: {type(train_dataset)}\")\n",
236
+ " print(f\"Train dataset length: {len(train_dataset)}\")\n",
237
+ " print(f\"First item in train dataset: {train_dataset[0]}\")\n",
238
+ " \n",
239
  "except Exception as e:\n",
240
+ " raise e"
241
  ]
242
  },
243
  {
244
  "cell_type": "code",
245
+ "execution_count": 6,
246
+ "metadata": {},
247
+ "outputs": [
248
+ {
249
+ "name": "stderr",
250
+ "output_type": "stream",
251
+ "text": [
252
+ "C:\\Users\\azizu\\AppData\\Local\\Temp\\ipykernel_28412\\4121028732.py:4: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.\n",
253
+ " test_dataset = torch.load('artifacts/data_transformation/test_dataset.pt')\n",
254
+ "C:\\Users\\azizu\\AppData\\Local\\Temp\\ipykernel_28412\\4121028732.py:5: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.\n",
255
+ " train_dataset = torch.load('artifacts/data_transformation/train_dataset.pt')\n"
256
+ ]
257
+ }
258
+ ],
259
+ "source": [
260
+ "from torch.utils.data import Dataset, DataLoader\n",
261
+ "\n",
262
+ "\n",
263
+ "test_dataset = torch.load('artifacts/data_transformation/test_dataset.pt')\n",
264
+ "train_dataset = torch.load('artifacts/data_transformation/train_dataset.pt')\n",
265
+ "\n",
266
+ "\n",
267
+ "train_loader1 = DataLoader(\n",
268
+ " train_dataset,\n",
269
+ " shuffle=True,\n",
270
+ " batch_size=1\n",
271
+ ")\n",
272
+ "test_loader1 = DataLoader(\n",
273
+ " test_dataset,\n",
274
+ " shuffle=True,\n",
275
+ " batch_size=1\n",
276
+ ")\n",
277
+ "\n"
278
+ ]
279
+ },
280
+ {
281
+ "cell_type": "code",
282
+ "execution_count": 7,
283
+ "metadata": {},
284
+ "outputs": [
285
+ {
286
+ "name": "stdout",
287
+ "output_type": "stream",
288
+ "text": [
289
+ "Train loader batch - ab shape: torch.Size([1, 2, 224, 224]), L shape: torch.Size([1, 1, 224, 224])\n",
290
+ "Test loader batch - ab shape: torch.Size([1, 2, 224, 224]), L shape: torch.Size([1, 1, 224, 224])\n"
291
+ ]
292
+ }
293
+ ],
294
+ "source": [
295
+ "# Print shapes for train dataloader\n",
296
+ "for batch in train_loader1:\n",
297
+ " ab, L = batch\n",
298
+ " print(f\"Train loader batch - ab shape: {ab.shape}, L shape: {L.shape}\")\n",
299
+ " break # We only need to check one batch\n",
300
+ "\n",
301
+ "# Print shapes for test dataloader\n",
302
+ "for batch in test_loader1:\n",
303
+ " ab, L = batch\n",
304
+ " print(f\"Test loader batch - ab shape: {ab.shape}, L shape: {L.shape}\")\n",
305
+ " break # We only need to check one batch"
306
+ ]
307
+ },
308
+ {
309
+ "cell_type": "code",
310
+ "execution_count": 8,
311
  "metadata": {},
312
  "outputs": [],
313
+ "source": [
314
+ "from skimage.color import rgb2lab, lab2rgb\n",
315
+ "import gc\n",
316
+ "import matplotlib.pylab as plt\n",
317
+ "\n",
318
+ "def lab_to_rgb(L, ab):\n",
319
+ " L = L * 100\n",
320
+ " ab = (ab - 0.5) * 128 * 2\n",
321
+ " Lab = torch.cat([L, ab], dim = 2).numpy()\n",
322
+ " rgb_img = []\n",
323
+ " for img in Lab:\n",
324
+ " img_rgb = lab2rgb(img)\n",
325
+ " rgb_img.append(img_rgb)\n",
326
+ " \n",
327
+ " return np.stack(rgb_img, axis = 0)\n",
328
+ "\n",
329
+ "\n"
330
+ ]
331
+ },
332
+ {
333
+ "cell_type": "code",
334
+ "execution_count": 9,
335
+ "metadata": {},
336
+ "outputs": [],
337
+ "source": [
338
+ "def display_progress(cond, real, fake, current_epoch = 0, figsize=(20,15)):\n",
339
+ " \"\"\"\n",
340
+ " Save cond, real (original) and generated (fake)\n",
341
+ " images in one panel \n",
342
+ " \"\"\"\n",
343
+ " cond = cond.detach().cpu().permute(1, 2, 0) \n",
344
+ " real = real.detach().cpu().permute(1, 2, 0)\n",
345
+ " fake = fake.detach().cpu().permute(1, 2, 0)\n",
346
+ " \n",
347
+ " images = [cond, real, fake]\n",
348
+ " titles = ['input','real','generated']\n",
349
+ " print(f'Epoch: {current_epoch}')\n",
350
+ " fig, ax = plt.subplots(1, 3, figsize=figsize)\n",
351
+ " for idx,img in enumerate(images):\n",
352
+ " if idx == 0:\n",
353
+ " ab = torch.zeros((224,224,2))\n",
354
+ " img = torch.cat([images[0]* 100, ab], dim=2).numpy()\n",
355
+ " imgan = lab2rgb(img)\n",
356
+ " else:\n",
357
+ " imgan = lab_to_rgb(images[0],img)\n",
358
+ " ax[idx].imshow(imgan)\n",
359
+ " ax[idx].axis(\"off\")\n",
360
+ " for idx, title in enumerate(titles): \n",
361
+ " ax[idx].set_title('{}'.format(title))\n",
362
+ " plt.show()\n"
363
+ ]
364
+ },
365
+ {
366
+ "cell_type": "code",
367
+ "execution_count": 13,
368
+ "metadata": {},
369
+ "outputs": [],
370
+ "source": [
371
+ "import pytorch_lightning as pl\n",
372
+ "from src.imagecolorization.conponents.model_trainer import Generator,Critic\n",
373
+ "from torch import nn, optim\n",
374
+ "\n",
375
+ "class CWGAN(pl.LightningModule):\n",
376
+ " def __init__(self, in_channels, out_channels, learning_rate=0.0002, lambda_recon=100, display_step=10, lambda_gp=10, lambda_r1=10):\n",
377
+ " super().__init__()\n",
378
+ " self.save_hyperparameters()\n",
379
+ " self.display_step = display_step\n",
380
+ " self.generator = Generator(in_channels, out_channels)\n",
381
+ " self.critic = Critic(in_channels + out_channels) # Ensure Critic is initialized with the correct input channels\n",
382
+ " self.lambda_recon = lambda_recon\n",
383
+ " self.lambda_gp = lambda_gp\n",
384
+ " self.lambda_r1 = lambda_r1\n",
385
+ " self.recon_criterion = nn.L1Loss()\n",
386
+ " self.generator_losses, self.critic_losses = [], []\n",
387
+ " self.automatic_optimization = False\n",
388
+ " \n",
389
+ " def configure_optimizers(self):\n",
390
+ " optimizer_G = optim.Adam(self.generator.parameters(), lr=self.hparams.learning_rate, betas=(0.5, 0.9))\n",
391
+ " optimizer_C = optim.Adam(self.critic.parameters(), lr=self.hparams.learning_rate, betas=(0.5, 0.9))\n",
392
+ " return [optimizer_C, optimizer_G]\n",
393
+ " \n",
394
+ " def generator_step(self, real_images, conditioned_images, optimizer_G):\n",
395
+ " # WGAN has only a reconstruction loss\n",
396
+ " optimizer_G.zero_grad()\n",
397
+ " fake_images = self.generator(conditioned_images)\n",
398
+ " recon_loss = self.recon_criterion(fake_images, real_images)\n",
399
+ " recon_loss.backward()\n",
400
+ " optimizer_G.step()\n",
401
+ " self.generator_losses.append(recon_loss.item())\n",
402
+ " \n",
403
+ " def critic_step(self, real_images, conditioned_images, optimizer_C):\n",
404
+ " optimizer_C.zero_grad()\n",
405
+ " fake_images = self.generator(conditioned_images)\n",
406
+ " fake_input = torch.cat((fake_images, conditioned_images), 1)\n",
407
+ " real_input = torch.cat((real_images, conditioned_images), 1)\n",
408
+ " fake_logits = self.critic(fake_input)\n",
409
+ " real_logits = self.critic(real_input)\n",
410
+ "\n",
411
+ " # Compute the loss for the critic\n",
412
+ " loss_C = real_logits.mean() - fake_logits.mean()\n",
413
+ "\n",
414
+ " # Compute the gradient penalty\n",
415
+ " alpha = torch.rand(real_images.size(0), 1, 1, 1, requires_grad=True).to(real_images.device)\n",
416
+ " interpolated = (alpha * real_images + (1 - alpha) * fake_images.detach()).requires_grad_(True)\n",
417
+ " interpolated_logits = self.critic(interpolated, conditioned_images)\n",
418
+ " \n",
419
+ " gradients = torch.autograd.grad(outputs=interpolated_logits, inputs=interpolated,\n",
420
+ " grad_outputs=torch.ones_like(interpolated_logits), create_graph=True, retain_graph=True)[0]\n",
421
+ " gradients = gradients.view(len(gradients), -1)\n",
422
+ " gradients_penalty = ((gradients.norm(2, dim=1) - 1) ** 2).mean()\n",
423
+ " loss_C += self.lambda_gp * gradients_penalty\n",
424
+ " \n",
425
+ " # Compute the R1 regularization loss\n",
426
+ " r1_reg = gradients.pow(2).sum(1).mean()\n",
427
+ " loss_C += self.lambda_r1 * r1_reg\n",
428
+ "\n",
429
+ " # Backpropagation\n",
430
+ " loss_C.backward()\n",
431
+ " optimizer_C.step()\n",
432
+ " self.critic_losses.append(loss_C.item())\n",
433
+ "\n",
434
+ " \n",
435
+ " def training_step(self, batch, batch_idx):\n",
436
+ " real, condition = batch\n",
437
+ " optimizer_C, optimizer_G = self.optimizers() # Access optimizers\n",
438
+ " \n",
439
+ " # Debugging shapes\n",
440
+ " print(f\"Real images shape: {real.shape}\")\n",
441
+ " print(f\"Conditioned images shape: {condition.shape}\")\n",
442
+ " \n",
443
+ " # Update the critic\n",
444
+ " self.critic_step(real, condition, optimizer_C)\n",
445
+ " \n",
446
+ " # Update the generator\n",
447
+ " self.generator_step(real, condition, optimizer_G)\n",
448
+ " \n",
449
+ " \n",
450
+ " # Logging and saving models\n",
451
+ " gen_mean = sum(self.generator_losses[-self.display_step:]) / self.display_step\n",
452
+ " crit_mean = sum(self.critic_losses[-self.display_step:]) / self.display_step\n",
453
+ " if self.current_epoch % self.display_step == 0 and batch_idx == 0:\n",
454
+ " fake = self.generator(condition).detach()\n",
455
+ " print(f\"Epoch {self.current_epoch}: Generator loss: {gen_mean}, Critic loss: {crit_mean}\")\n",
456
+ " display_progress(condition[0], real[0], fake[0], self.current_epoch)\n",
457
+ " \n",
458
+ " # Save models every 10 epochs\n",
459
+ " if (self.current_epoch + 1) % 10 == 0 and batch_idx == self.trainer.num_training_batches - 1:\n",
460
+ " torch.save(self.generator.state_dict(), f\"/kaggle/working/cwgan_generator_epoch_{self.current_epoch+1}.pt\")\n",
461
+ " torch.save(self.critic.state_dict(), f\"/kaggle/working/cwgan_critic_epoch_{self.current_epoch+1}.pt\")\n",
462
+ " print(f\"Saved models at epoch {self.current_epoch+1}\")\n",
463
+ "\n",
464
+ " # Final save at epoch 150\n",
465
+ " if self.current_epoch == 149 and batch_idx == self.trainer.num_training_batches - 1:\n",
466
+ " torch.save(self.generator.state_dict(), \"cwgan_generator_final.pt\")\n",
467
+ " torch.save(self.critic.state_dict(), \"cwgan_critic_final.pt\")\n",
468
+ " print(\"Saved final models at epoch 150\")\n",
469
+ " "
470
+ ]
471
+ },
472
+ {
473
+ "cell_type": "code",
474
+ "execution_count": 14,
475
+ "metadata": {},
476
+ "outputs": [],
477
+ "source": [
478
+ "from torch import nn, optim\n",
479
+ "\n",
480
+ "gc.collect()\n",
481
+ "cwgan = CWGAN(in_channels = 1, out_channels = 2 ,learning_rate=2e-4, lambda_recon=100, display_step=10)"
482
+ ]
483
+ },
484
+ {
485
+ "cell_type": "code",
486
+ "execution_count": 15,
487
+ "metadata": {},
488
+ "outputs": [
489
+ {
490
+ "name": "stdout",
491
+ "output_type": "stream",
492
+ "text": [
493
+ "[2024-08-25 00:04:53,828: INFO: rank_zero: GPU available: True (cuda), used: True]\n",
494
+ "[2024-08-25 00:04:53,829: INFO: rank_zero: TPU available: False, using: 0 TPU cores]\n",
495
+ "[2024-08-25 00:04:53,830: INFO: rank_zero: IPU available: False, using: 0 IPUs]\n",
496
+ "[2024-08-25 00:04:53,831: INFO: rank_zero: HPU available: False, using: 0 HPUs]\n"
497
+ ]
498
+ },
499
+ {
500
+ "name": "stdout",
501
+ "output_type": "stream",
502
+ "text": [
503
+ "[2024-08-25 00:04:54,549: INFO: cuda: LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]]\n",
504
+ "[2024-08-25 00:04:54,552: INFO: model_summary: \n",
505
+ " | Name | Type | Params\n",
506
+ "----------------------------------------------\n",
507
+ "0 | generator | Generator | 8.2 M \n",
508
+ "1 | critic | Critic | 2.8 M \n",
509
+ "2 | recon_criterion | L1Loss | 0 \n",
510
+ "----------------------------------------------\n",
511
+ "11.0 M Trainable params\n",
512
+ "0 Non-trainable params\n",
513
+ "11.0 M Total params\n",
514
+ "43.893 Total estimated model params size (MB)]\n"
515
+ ]
516
+ },
517
+ {
518
+ "data": {
519
+ "application/vnd.jupyter.widget-view+json": {
520
+ "model_id": "a1c97e80cdd746b2afa3ae30771ee058",
521
+ "version_major": 2,
522
+ "version_minor": 0
523
+ },
524
+ "text/plain": [
525
+ "Training: | | 0/? [00:00<?, ?it/s]"
526
+ ]
527
+ },
528
+ "metadata": {},
529
+ "output_type": "display_data"
530
+ },
531
+ {
532
+ "name": "stdout",
533
+ "output_type": "stream",
534
+ "text": [
535
+ "Real images shape: torch.Size([1, 2, 224, 224])\n",
536
+ "Conditioned images shape: torch.Size([1, 1, 224, 224])\n"
537
+ ]
538
+ },
539
+ {
540
+ "ename": "TypeError",
541
+ "evalue": "Critic.forward() missing 1 required positional argument: 'l'",
542
+ "output_type": "error",
543
+ "traceback": [
544
+ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
545
+ "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
546
+ "Cell \u001b[1;32mIn[15], line 2\u001b[0m\n\u001b[0;32m 1\u001b[0m trainer \u001b[38;5;241m=\u001b[39m pl\u001b[38;5;241m.\u001b[39mTrainer(max_epochs\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m150\u001b[39m)\n\u001b[1;32m----> 2\u001b[0m \u001b[43mtrainer\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfit\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcwgan\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtrain_loader1\u001b[49m\u001b[43m)\u001b[49m\n",
547
+ "File \u001b[1;32mc:\\Users\\azizu\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\pytorch_lightning\\trainer\\trainer.py:545\u001b[0m, in \u001b[0;36mTrainer.fit\u001b[1;34m(self, model, train_dataloaders, val_dataloaders, datamodule, ckpt_path)\u001b[0m\n\u001b[0;32m 543\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mstate\u001b[38;5;241m.\u001b[39mstatus \u001b[38;5;241m=\u001b[39m TrainerStatus\u001b[38;5;241m.\u001b[39mRUNNING\n\u001b[0;32m 544\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtraining \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mTrue\u001b[39;00m\n\u001b[1;32m--> 545\u001b[0m \u001b[43mcall\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_call_and_handle_interrupt\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 546\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_fit_impl\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmodel\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtrain_dataloaders\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mval_dataloaders\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdatamodule\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mckpt_path\u001b[49m\n\u001b[0;32m 547\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n",
548
+ "File \u001b[1;32mc:\\Users\\azizu\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\pytorch_lightning\\trainer\\call.py:44\u001b[0m, in \u001b[0;36m_call_and_handle_interrupt\u001b[1;34m(trainer, trainer_fn, *args, **kwargs)\u001b[0m\n\u001b[0;32m 42\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m trainer\u001b[38;5;241m.\u001b[39mstrategy\u001b[38;5;241m.\u001b[39mlauncher \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m 43\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m trainer\u001b[38;5;241m.\u001b[39mstrategy\u001b[38;5;241m.\u001b[39mlauncher\u001b[38;5;241m.\u001b[39mlaunch(trainer_fn, \u001b[38;5;241m*\u001b[39margs, trainer\u001b[38;5;241m=\u001b[39mtrainer, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m---> 44\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mtrainer_fn\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 46\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m _TunerExitException:\n\u001b[0;32m 47\u001b[0m _call_teardown_hook(trainer)\n",
549
+ "File \u001b[1;32mc:\\Users\\azizu\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\pytorch_lightning\\trainer\\trainer.py:581\u001b[0m, in \u001b[0;36mTrainer._fit_impl\u001b[1;34m(self, model, train_dataloaders, val_dataloaders, datamodule, ckpt_path)\u001b[0m\n\u001b[0;32m 574\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mstate\u001b[38;5;241m.\u001b[39mfn \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[0;32m 575\u001b[0m ckpt_path \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_checkpoint_connector\u001b[38;5;241m.\u001b[39m_select_ckpt_path(\n\u001b[0;32m 576\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mstate\u001b[38;5;241m.\u001b[39mfn,\n\u001b[0;32m 577\u001b[0m ckpt_path,\n\u001b[0;32m 578\u001b[0m model_provided\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m,\n\u001b[0;32m 579\u001b[0m model_connected\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mlightning_module \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[0;32m 580\u001b[0m )\n\u001b[1;32m--> 581\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_run\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmodel\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mckpt_path\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mckpt_path\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 583\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mstate\u001b[38;5;241m.\u001b[39mstopped\n\u001b[0;32m 584\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtraining \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mFalse\u001b[39;00m\n",
550
+ "File \u001b[1;32mc:\\Users\\azizu\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\pytorch_lightning\\trainer\\trainer.py:990\u001b[0m, in \u001b[0;36mTrainer._run\u001b[1;34m(self, model, ckpt_path)\u001b[0m\n\u001b[0;32m 985\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_signal_connector\u001b[38;5;241m.\u001b[39mregister_signal_handlers()\n\u001b[0;32m 987\u001b[0m \u001b[38;5;66;03m# ----------------------------\u001b[39;00m\n\u001b[0;32m 988\u001b[0m \u001b[38;5;66;03m# RUN THE TRAINER\u001b[39;00m\n\u001b[0;32m 989\u001b[0m \u001b[38;5;66;03m# ----------------------------\u001b[39;00m\n\u001b[1;32m--> 990\u001b[0m results \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_run_stage\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 992\u001b[0m \u001b[38;5;66;03m# ----------------------------\u001b[39;00m\n\u001b[0;32m 993\u001b[0m \u001b[38;5;66;03m# POST-Training CLEAN UP\u001b[39;00m\n\u001b[0;32m 994\u001b[0m \u001b[38;5;66;03m# ----------------------------\u001b[39;00m\n\u001b[0;32m 995\u001b[0m log\u001b[38;5;241m.\u001b[39mdebug(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__class__\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m: trainer tearing down\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
551
+ "File \u001b[1;32mc:\\Users\\azizu\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\pytorch_lightning\\trainer\\trainer.py:1036\u001b[0m, in \u001b[0;36mTrainer._run_stage\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 1034\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_run_sanity_check()\n\u001b[0;32m 1035\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m torch\u001b[38;5;241m.\u001b[39mautograd\u001b[38;5;241m.\u001b[39mset_detect_anomaly(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_detect_anomaly):\n\u001b[1;32m-> 1036\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfit_loop\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1037\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[0;32m 1038\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mRuntimeError\u001b[39;00m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mUnexpected state \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mstate\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n",
552
+ "File \u001b[1;32mc:\\Users\\azizu\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\pytorch_lightning\\loops\\fit_loop.py:202\u001b[0m, in \u001b[0;36m_FitLoop.run\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 200\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m 201\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mon_advance_start()\n\u001b[1;32m--> 202\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43madvance\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 203\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mon_advance_end()\n\u001b[0;32m 204\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_restarting \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mFalse\u001b[39;00m\n",
553
+ "File \u001b[1;32mc:\\Users\\azizu\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\pytorch_lightning\\loops\\fit_loop.py:359\u001b[0m, in \u001b[0;36m_FitLoop.advance\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 357\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtrainer\u001b[38;5;241m.\u001b[39mprofiler\u001b[38;5;241m.\u001b[39mprofile(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mrun_training_epoch\u001b[39m\u001b[38;5;124m\"\u001b[39m):\n\u001b[0;32m 358\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_data_fetcher \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m--> 359\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mepoch_loop\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_data_fetcher\u001b[49m\u001b[43m)\u001b[49m\n",
554
+ "File \u001b[1;32mc:\\Users\\azizu\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\pytorch_lightning\\loops\\training_epoch_loop.py:136\u001b[0m, in \u001b[0;36m_TrainingEpochLoop.run\u001b[1;34m(self, data_fetcher)\u001b[0m\n\u001b[0;32m 134\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdone:\n\u001b[0;32m 135\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 136\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43madvance\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdata_fetcher\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 137\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mon_advance_end(data_fetcher)\n\u001b[0;32m 138\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_restarting \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mFalse\u001b[39;00m\n",
555
+ "File \u001b[1;32mc:\\Users\\azizu\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\pytorch_lightning\\loops\\training_epoch_loop.py:242\u001b[0m, in \u001b[0;36m_TrainingEpochLoop.advance\u001b[1;34m(self, data_fetcher)\u001b[0m\n\u001b[0;32m 240\u001b[0m batch_output \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mautomatic_optimization\u001b[38;5;241m.\u001b[39mrun(trainer\u001b[38;5;241m.\u001b[39moptimizers[\u001b[38;5;241m0\u001b[39m], batch_idx, kwargs)\n\u001b[0;32m 241\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m--> 242\u001b[0m batch_output \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmanual_optimization\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 244\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mbatch_progress\u001b[38;5;241m.\u001b[39mincrement_processed()\n\u001b[0;32m 246\u001b[0m \u001b[38;5;66;03m# update non-plateau LR schedulers\u001b[39;00m\n\u001b[0;32m 247\u001b[0m \u001b[38;5;66;03m# update epoch-interval ones only when we are at the end of training epoch\u001b[39;00m\n",
556
+ "File \u001b[1;32mc:\\Users\\azizu\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\pytorch_lightning\\loops\\optimization\\manual.py:92\u001b[0m, in \u001b[0;36m_ManualOptimization.run\u001b[1;34m(self, kwargs)\u001b[0m\n\u001b[0;32m 90\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mon_run_start()\n\u001b[0;32m 91\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m suppress(\u001b[38;5;167;01mStopIteration\u001b[39;00m): \u001b[38;5;66;03m# no loop to break at this level\u001b[39;00m\n\u001b[1;32m---> 92\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43madvance\u001b[49m\u001b[43m(\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 93\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_restarting \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mFalse\u001b[39;00m\n\u001b[0;32m 94\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mon_run_end()\n",
557
+ "File \u001b[1;32mc:\\Users\\azizu\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\pytorch_lightning\\loops\\optimization\\manual.py:112\u001b[0m, in \u001b[0;36m_ManualOptimization.advance\u001b[1;34m(self, kwargs)\u001b[0m\n\u001b[0;32m 109\u001b[0m trainer \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtrainer\n\u001b[0;32m 111\u001b[0m \u001b[38;5;66;03m# manually capture logged metrics\u001b[39;00m\n\u001b[1;32m--> 112\u001b[0m training_step_output \u001b[38;5;241m=\u001b[39m \u001b[43mcall\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_call_strategy_hook\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtrainer\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mtraining_step\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mvalues\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 113\u001b[0m \u001b[38;5;28;01mdel\u001b[39;00m kwargs \u001b[38;5;66;03m# release the batch from memory\u001b[39;00m\n\u001b[0;32m 114\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtrainer\u001b[38;5;241m.\u001b[39mstrategy\u001b[38;5;241m.\u001b[39mpost_training_step() \u001b[38;5;66;03m# unused hook - call anyway for backward compatibility\u001b[39;00m\n",
558
+ "File \u001b[1;32mc:\\Users\\azizu\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\pytorch_lightning\\trainer\\call.py:309\u001b[0m, in \u001b[0;36m_call_strategy_hook\u001b[1;34m(trainer, hook_name, *args, **kwargs)\u001b[0m\n\u001b[0;32m 306\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[0;32m 308\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m trainer\u001b[38;5;241m.\u001b[39mprofiler\u001b[38;5;241m.\u001b[39mprofile(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m[Strategy]\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mtrainer\u001b[38;5;241m.\u001b[39mstrategy\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__class__\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m.\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mhook_name\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m):\n\u001b[1;32m--> 309\u001b[0m output \u001b[38;5;241m=\u001b[39m \u001b[43mfn\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 311\u001b[0m \u001b[38;5;66;03m# restore current_fx when nested context\u001b[39;00m\n\u001b[0;32m 312\u001b[0m pl_module\u001b[38;5;241m.\u001b[39m_current_fx_name \u001b[38;5;241m=\u001b[39m prev_fx_name\n",
559
+ "File \u001b[1;32mc:\\Users\\azizu\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\pytorch_lightning\\strategies\\strategy.py:382\u001b[0m, in \u001b[0;36mStrategy.training_step\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 380\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mmodel \u001b[38;5;241m!=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mlightning_module:\n\u001b[0;32m 381\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_redirection(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mmodel, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mlightning_module, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtraining_step\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m--> 382\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mlightning_module\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtraining_step\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
560
+ "Cell \u001b[1;32mIn[13], line 74\u001b[0m, in \u001b[0;36mCWGAN.training_step\u001b[1;34m(self, batch, batch_idx)\u001b[0m\n\u001b[0;32m 71\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mConditioned images shape: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mcondition\u001b[38;5;241m.\u001b[39mshape\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 73\u001b[0m \u001b[38;5;66;03m# Update the critic\u001b[39;00m\n\u001b[1;32m---> 74\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcritic_step\u001b[49m\u001b[43m(\u001b[49m\u001b[43mreal\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcondition\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43moptimizer_C\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 76\u001b[0m \u001b[38;5;66;03m# Update the generator\u001b[39;00m\n\u001b[0;32m 77\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mgenerator_step(real, condition, optimizer_G)\n",
561
+ "Cell \u001b[1;32mIn[13], line 38\u001b[0m, in \u001b[0;36mCWGAN.critic_step\u001b[1;34m(self, real_images, conditioned_images, optimizer_C)\u001b[0m\n\u001b[0;32m 36\u001b[0m fake_input \u001b[38;5;241m=\u001b[39m torch\u001b[38;5;241m.\u001b[39mcat((fake_images, conditioned_images), \u001b[38;5;241m1\u001b[39m)\n\u001b[0;32m 37\u001b[0m real_input \u001b[38;5;241m=\u001b[39m torch\u001b[38;5;241m.\u001b[39mcat((real_images, conditioned_images), \u001b[38;5;241m1\u001b[39m)\n\u001b[1;32m---> 38\u001b[0m fake_logits \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcritic\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfake_input\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 39\u001b[0m real_logits \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcritic(real_input)\n\u001b[0;32m 41\u001b[0m \u001b[38;5;66;03m# Compute the loss for the critic\u001b[39;00m\n",
562
+ "File \u001b[1;32mc:\\Users\\azizu\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\torch\\nn\\modules\\module.py:1553\u001b[0m, in \u001b[0;36mModule._wrapped_call_impl\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 1551\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_compiled_call_impl(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs) \u001b[38;5;66;03m# type: ignore[misc]\u001b[39;00m\n\u001b[0;32m 1552\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m-> 1553\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_call_impl\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
563
+ "File \u001b[1;32mc:\\Users\\azizu\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\torch\\nn\\modules\\module.py:1562\u001b[0m, in \u001b[0;36mModule._call_impl\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 1557\u001b[0m \u001b[38;5;66;03m# If we don't have any hooks, we want to skip the rest of the logic in\u001b[39;00m\n\u001b[0;32m 1558\u001b[0m \u001b[38;5;66;03m# this function, and just call forward.\u001b[39;00m\n\u001b[0;32m 1559\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m (\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_backward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_backward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_forward_pre_hooks\n\u001b[0;32m 1560\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m _global_backward_pre_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_backward_hooks\n\u001b[0;32m 1561\u001b[0m \u001b[38;5;129;01mor\u001b[39;00m _global_forward_hooks \u001b[38;5;129;01mor\u001b[39;00m _global_forward_pre_hooks):\n\u001b[1;32m-> 1562\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mforward_call\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1564\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m 1565\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n",
564
+ "\u001b[1;31mTypeError\u001b[0m: Critic.forward() missing 1 required positional argument: 'l'"
565
+ ]
566
+ }
567
+ ],
568
+ "source": [
569
+ "trainer = pl.Trainer(max_epochs=150)\n",
570
+ "trainer.fit(cwgan, train_loader1)"
571
+ ]
572
  },
573
  {
574
  "cell_type": "code",
research/lightning_logs/version_0/events.out.tfevents.1724524991.Hakim.26396.0 ADDED
Binary file (683 Bytes). View file
 
research/lightning_logs/version_0/hparams.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ display_step: 10
2
+ in_channels: 1
3
+ lambda_gp: 10
4
+ lambda_r1: 10
5
+ lambda_recon: 100
6
+ learning_rate: 0.0002
7
+ out_channels: 2
research/lightning_logs/version_1/events.out.tfevents.1724525009.Hakim.26396.1 ADDED
Binary file (683 Bytes). View file
 
research/lightning_logs/version_1/hparams.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ display_step: 10
2
+ in_channels: 1
3
+ lambda_gp: 10
4
+ lambda_r1: 10
5
+ lambda_recon: 100
6
+ learning_rate: 0.0002
7
+ out_channels: 2
research/model_building.ipynb CHANGED
@@ -183,7 +183,7 @@
183
  " \n",
184
  " \n",
185
  "class Critic(nn.Module):\n",
186
- " def __init__(self, in_channels=3):\n",
187
  " super(Critic, self).__init__()\n",
188
  "\n",
189
  " def critic_block(in_filters, out_filters, normalization=True):\n",
@@ -203,11 +203,9 @@
203
  " nn.Linear(512, 1)\n",
204
  " )\n",
205
  "\n",
206
- " def forward(self, ab, l):\n",
207
- " img_input = torch.cat((ab, l), 1)\n",
208
  " output = self.model(img_input)\n",
209
  " return output\n",
210
- " \n",
211
  " "
212
  ]
213
  },
 
183
  " \n",
184
  " \n",
185
  "class Critic(nn.Module):\n",
186
+ " def __init__(self, in_channels):\n",
187
  " super(Critic, self).__init__()\n",
188
  "\n",
189
  " def critic_block(in_filters, out_filters, normalization=True):\n",
 
203
  " nn.Linear(512, 1)\n",
204
  " )\n",
205
  "\n",
206
+ " def forward(self, img_input):\n",
 
207
  " output = self.model(img_input)\n",
208
  " return output\n",
 
209
  " "
210
  ]
211
  },
src/imagecolorization/config/configuration.py CHANGED
@@ -91,6 +91,7 @@ class ConfigurationManager:
91
  BATCH_SIZE= params.BATCH_SIZE
92
  )
93
  return model_trainer_config
 
94
 
95
 
96
 
 
91
  BATCH_SIZE= params.BATCH_SIZE
92
  )
93
  return model_trainer_config
94
+
95
 
96
 
97
 
src/imagecolorization/conponents/model_building.py CHANGED
@@ -4,67 +4,68 @@ from pathlib import Path
4
  from torchsummary import summary
5
  from src.imagecolorization.entity.config_entity import ModelBuildingConfig
6
  class ResBlock(nn.Module):
7
- def __init__(self, in_channles, out_channels, stride = 1, kerenl_size = 3, padding = 1, bias = False):
8
  super().__init__()
9
  self.layer = nn.Sequential(
10
- nn.Conv2d(in_channles, out_channels, kernel_size=kerenl_size, padding=padding, stride=stride, bias = bias),
11
  nn.BatchNorm2d(out_channels),
12
  nn.ReLU(inplace=True),
13
- nn.Conv2d(out_channels, out_channels, kernel_size=kerenl_size, padding=padding, stride = 1, bias = bias),
14
  nn.BatchNorm2d(out_channels),
15
  nn.ReLU(inplace=True)
16
  )
17
-
18
- self.identity_map = nn.Conv2d(in_channles, out_channels,kernel_size=1, stride=stride)
19
- self.relu = nn.ReLU(inplace= True)
20
-
21
  def forward(self, inputs):
22
  x = inputs.clone().detach()
23
  out = self.layer(x)
24
- residual = self.identity_map(inputs)
25
- skip = out + residual
26
  return self.relu(skip)
27
 
28
 
29
- class DownsampleConv(nn.Module):
30
- def __init__(self, in_channels, out_channels, stride = 1):
31
  super().__init__()
32
  self.layer = nn.Sequential(
33
  nn.MaxPool2d(2),
34
  ResBlock(in_channels, out_channels)
35
  )
36
-
37
  def forward(self, inputs):
38
  return self.layer(inputs)
39
 
40
 
41
 
42
- class UpsampleConv(nn.Module):
43
- def __init__(self, in_channels, out_channels, scale_factor=2):
44
  super().__init__()
45
- self.upsample = nn.Upsample(scale_factor=scale_factor,mode = 'bilinear', align_corners=True)
 
46
  self.res_block = ResBlock(in_channels + out_channels, out_channels)
47
-
48
  def forward(self, inputs, skip):
49
  x = self.upsample(inputs)
50
- x = torch.cat([x, skip], dim = 1)
51
  x = self.res_block(x)
52
  return x
53
 
54
  class Generator(nn.Module):
55
- def __init__(self, input_channels, output_channels, dropout_rate = 0.2):
56
  super().__init__()
57
- self.encoding_layer1_= ResBlock(input_channels, 64)
58
- self.encoding_layer2_ = DownsampleConv(64, 128)
59
- self.encoding_layer3_ = DownsampleConv(128, 256)
60
- self.bridge = DownsampleConv(256, 512)
61
- self.decoding_layer3 = UpsampleConv(512, 256)
62
- self.decoding_layer2 = UpsampleConv(256, 128)
63
- self.decoding_layer1 = UpsampleConv(128 , 64)
64
- self.output = nn.Conv2d(64, output_channels, kernel_size = 1)
65
  self.dropout = nn.Dropout2d(dropout_rate)
66
 
67
  def forward(self, inputs):
 
68
  e1 = self.encoding_layer1_(inputs)
69
  e1 = self.dropout(e1)
70
  e2 = self.encoding_layer2_(e1)
@@ -72,22 +73,25 @@ class Generator(nn.Module):
72
  e3 = self.encoding_layer3_(e2)
73
  e3 = self.dropout(e3)
74
 
 
75
  bridge = self.bridge(e3)
76
  bridge = self.dropout(bridge)
77
 
78
- d3 = self.decoding_layer3(bridge, e3)
79
- d2 =self.decoding_layer2(d3, e2)
80
- d1 = self.decoding_layer1(d2, e1)
 
81
 
82
- output = self.dropout(d1)
 
83
  return output
84
 
85
-
86
  class Critic(nn.Module):
87
  def __init__(self, in_channels=3):
88
  super(Critic, self).__init__()
89
 
90
  def critic_block(in_filters, out_filters, normalization=True):
 
91
  layers = [nn.Conv2d(in_filters, out_filters, 4, stride=2, padding=1)]
92
  if normalization:
93
  layers.append(nn.InstanceNorm2d(out_filters))
@@ -105,12 +109,12 @@ class Critic(nn.Module):
105
  )
106
 
107
  def forward(self, ab, l):
 
108
  img_input = torch.cat((ab, l), 1)
109
  output = self.model(img_input)
110
  return output
111
 
112
-
113
- from torchsummary import summary
114
  import torch
115
  import os
116
 
@@ -127,8 +131,8 @@ class ModelBuilding:
127
 
128
  def get_generator(self):
129
  return Generator(
130
- input_channels=self.config.INPUT_CHANNELS, # corrected argument name
131
- output_channels=self.config.OUTPUT_CHANNELS, # corrected argument name
132
  dropout_rate=self.config.DROPOUT_RATE
133
  ).to(self.device)
134
 
 
4
  from torchsummary import summary
5
  from src.imagecolorization.entity.config_entity import ModelBuildingConfig
6
  class ResBlock(nn.Module):
7
+ def __init__(self, in_channels, out_channels, stride=1):
8
  super().__init__()
9
  self.layer = nn.Sequential(
10
+ nn.Conv2d(in_channels,out_channels,kernel_size=3, padding=1, stride=stride, bias=False),
11
  nn.BatchNorm2d(out_channels),
12
  nn.ReLU(inplace=True),
13
+ nn.Conv2d(out_channels, out_channels,kernel_size=3,padding=1, stride=1, bias=False),
14
  nn.BatchNorm2d(out_channels),
15
  nn.ReLU(inplace=True)
16
  )
17
+
18
+ self.identity_map = nn.Conv2d(in_channels, out_channels,kernel_size=1,stride=stride)
19
+ self.relu = nn.ReLU(inplace=True)
 
20
  def forward(self, inputs):
21
  x = inputs.clone().detach()
22
  out = self.layer(x)
23
+ residual = self.identity_map(inputs)
24
+ skip = out + residual
25
  return self.relu(skip)
26
 
27
 
28
+ class DownSampleConv(nn.Module):
29
+ def __init__(self, in_channels, out_channels, stride=1):
30
  super().__init__()
31
  self.layer = nn.Sequential(
32
  nn.MaxPool2d(2),
33
  ResBlock(in_channels, out_channels)
34
  )
35
+
36
  def forward(self, inputs):
37
  return self.layer(inputs)
38
 
39
 
40
 
41
+ class UpSampleConv(nn.Module):
42
+ def __init__(self, in_channels, out_channels):
43
  super().__init__()
44
+
45
+ self.upsample = nn.Upsample(scale_factor=2, mode="bilinear", align_corners=True)
46
  self.res_block = ResBlock(in_channels + out_channels, out_channels)
47
+
48
  def forward(self, inputs, skip):
49
  x = self.upsample(inputs)
50
+ x = torch.cat([x, skip], dim=1)
51
  x = self.res_block(x)
52
  return x
53
 
54
  class Generator(nn.Module):
55
+ def __init__(self, input_channel, output_channel, dropout_rate = 0.2):
56
  super().__init__()
57
+ self.encoding_layer1_ = ResBlock(input_channel,64)
58
+ self.encoding_layer2_ = DownSampleConv(64, 128)
59
+ self.encoding_layer3_ = DownSampleConv(128, 256)
60
+ self.bridge = DownSampleConv(256, 512)
61
+ self.decoding_layer3_ = UpSampleConv(512, 256)
62
+ self.decoding_layer2_ = UpSampleConv(256, 128)
63
+ self.decoding_layer1_ = UpSampleConv(128, 64)
64
+ self.output = nn.Conv2d(64, output_channel, kernel_size=1)
65
  self.dropout = nn.Dropout2d(dropout_rate)
66
 
67
  def forward(self, inputs):
68
+ ###################### Enocoder #########################
69
  e1 = self.encoding_layer1_(inputs)
70
  e1 = self.dropout(e1)
71
  e2 = self.encoding_layer2_(e1)
 
73
  e3 = self.encoding_layer3_(e2)
74
  e3 = self.dropout(e3)
75
 
76
+ ###################### Bridge #########################
77
  bridge = self.bridge(e3)
78
  bridge = self.dropout(bridge)
79
 
80
+ ###################### Decoder #########################
81
+ d3 = self.decoding_layer3_(bridge, e3)
82
+ d2 = self.decoding_layer2_(d3, e2)
83
+ d1 = self.decoding_layer1_(d2, e1)
84
 
85
+ ###################### Output #########################
86
+ output = self.output(d1)
87
  return output
88
 
 
89
  class Critic(nn.Module):
90
  def __init__(self, in_channels=3):
91
  super(Critic, self).__init__()
92
 
93
  def critic_block(in_filters, out_filters, normalization=True):
94
+ """Returns layers of each critic block"""
95
  layers = [nn.Conv2d(in_filters, out_filters, 4, stride=2, padding=1)]
96
  if normalization:
97
  layers.append(nn.InstanceNorm2d(out_filters))
 
109
  )
110
 
111
  def forward(self, ab, l):
112
+ # Concatenate image and condition image by channels to produce input
113
  img_input = torch.cat((ab, l), 1)
114
  output = self.model(img_input)
115
  return output
116
 
117
+ from torchsummary import summary
 
118
  import torch
119
  import os
120
 
 
131
 
132
  def get_generator(self):
133
  return Generator(
134
+ input_channel=self.config.INPUT_CHANNELS, # corrected argument name
135
+ output_channel=self.config.OUTPUT_CHANNELS, # corrected argument name
136
  dropout_rate=self.config.DROPOUT_RATE
137
  ).to(self.device)
138
 
src/imagecolorization/conponents/model_trainer.py CHANGED
@@ -73,47 +73,41 @@ class CWGAN(pl.LightningModule):
73
  self.recon_criterion = nn.L1Loss()
74
  self.generator_losses, self.critic_losses = [], []
75
  self.automatic_optimization = False # Disable automatic optimization
76
-
77
  def configure_optimizers(self):
78
  optimizer_G = optim.Adam(self.generator.parameters(), lr=self.hparams.learning_rate, betas=(0.5, 0.9))
79
  optimizer_C = optim.Adam(self.critic.parameters(), lr=self.hparams.learning_rate, betas=(0.5, 0.9))
80
  return [optimizer_C, optimizer_G]
81
-
82
  def generator_step(self, real_images, conditioned_images, optimizer_G):
 
83
  optimizer_G.zero_grad()
84
  fake_images = self.generator(conditioned_images)
85
  recon_loss = self.recon_criterion(fake_images, real_images)
86
  recon_loss.backward()
87
  optimizer_G.step()
88
  self.generator_losses.append(recon_loss.item())
89
-
90
  def critic_step(self, real_images, conditioned_images, optimizer_C):
91
  optimizer_C.zero_grad()
92
  fake_images = self.generator(conditioned_images)
93
-
94
- # Separate L and ab channels
95
- l_real = conditioned_images
96
- ab_real = real_images
97
- ab_fake = fake_images
98
-
99
- # Compute logits
100
- fake_logits = self.critic(ab_fake, l_real) # Pass two arguments
101
- real_logits = self.critic(ab_real, l_real) # Pass two arguments
102
-
103
  # Compute the loss for the critic
104
  loss_C = real_logits.mean() - fake_logits.mean()
105
 
106
  # Compute the gradient penalty
107
  alpha = torch.rand(real_images.size(0), 1, 1, 1, requires_grad=True).to(real_images.device)
108
- interpolated = (alpha * ab_real + (1 - alpha) * ab_fake.detach()).requires_grad_(True)
109
- interpolated_logits = self.critic(interpolated, l_real)
110
-
111
  gradients = torch.autograd.grad(outputs=interpolated_logits, inputs=interpolated,
112
  grad_outputs=torch.ones_like(interpolated_logits), create_graph=True, retain_graph=True)[0]
113
  gradients = gradients.view(len(gradients), -1)
114
  gradients_penalty = ((gradients.norm(2, dim=1) - 1) ** 2).mean()
115
  loss_C += self.lambda_gp * gradients_penalty
116
-
117
  # Compute the R1 regularization loss
118
  r1_reg = gradients.pow(2).sum(1).mean()
119
  loss_C += self.lambda_r1 * r1_reg
@@ -122,53 +116,65 @@ class CWGAN(pl.LightningModule):
122
  loss_C.backward()
123
  optimizer_C.step()
124
  self.critic_losses.append(loss_C.item())
125
-
126
  def training_step(self, batch, batch_idx):
127
- optimizer_C, optimizer_G = self.optimizers()
128
- real_images, conditioned_images = batch
129
-
130
- self.critic_step(real_images, conditioned_images, optimizer_C)
131
- self.generator_step(real_images, conditioned_images, optimizer_G)
132
-
 
 
 
 
 
 
133
  if self.current_epoch % self.display_step == 0 and batch_idx == 0:
134
- with torch.no_grad():
135
- fake_images = self.generator(conditioned_images)
136
- display_progress(conditioned_images[0], real_images[0], fake_images[0], self.current_epoch)
137
-
138
- def on_epoch_end(self):
139
- gc.collect()
140
- torch.cuda.empty_cache()
141
-
142
- def forward(self, x):
143
- return self.generator(x)
144
 
145
 
146
  import os
147
  class ModelTrainer:
148
- def __init__(self, config : ModelTrainerConfig):
149
  self.config = config
150
 
151
  def load_datasets(self):
152
  self.train_dataset = torch.load(self.config.train_data_path)
153
  self.test_dataset = torch.load(self.config.test_data_path)
 
 
 
 
 
 
154
 
155
  def create_dataloaders(self):
156
  self.train_dataloader = DataLoader(
157
- self.train_dataset, batch_size=self.config.BATCH_SIZE, shuffle=True
 
 
158
  )
159
  self.test_dataloader = DataLoader(
160
- self.test_dataset, batch_size=self.config.BATCH_SIZE, shuffle=False
 
 
161
  )
 
 
 
 
162
 
163
  def initialize_model(self):
164
  self.model = CWGAN(
165
- in_channels=self.config.INPUT_CHANNELS,
166
- out_channels=self.config.OUTPUT_CHANNELS,
167
  learning_rate=self.config.LEARNING_RATE,
168
  lambda_recon=self.config.LAMBDA_RECON,
169
  display_step=self.config.DISPLAY_STEP,
170
- lambda_gp=10, # Default value, you can make it configurable
171
- lambda_r1=10 # Default value, you can make it configurable
172
  )
173
 
174
  def train_model(self):
 
73
  self.recon_criterion = nn.L1Loss()
74
  self.generator_losses, self.critic_losses = [], []
75
  self.automatic_optimization = False # Disable automatic optimization
76
+
77
  def configure_optimizers(self):
78
  optimizer_G = optim.Adam(self.generator.parameters(), lr=self.hparams.learning_rate, betas=(0.5, 0.9))
79
  optimizer_C = optim.Adam(self.critic.parameters(), lr=self.hparams.learning_rate, betas=(0.5, 0.9))
80
  return [optimizer_C, optimizer_G]
81
+
82
  def generator_step(self, real_images, conditioned_images, optimizer_G):
83
+ # WGAN has only a reconstruction loss
84
  optimizer_G.zero_grad()
85
  fake_images = self.generator(conditioned_images)
86
  recon_loss = self.recon_criterion(fake_images, real_images)
87
  recon_loss.backward()
88
  optimizer_G.step()
89
  self.generator_losses.append(recon_loss.item())
90
+
91
  def critic_step(self, real_images, conditioned_images, optimizer_C):
92
  optimizer_C.zero_grad()
93
  fake_images = self.generator(conditioned_images)
94
+ fake_logits = self.critic(fake_images, conditioned_images)
95
+ real_logits = self.critic(real_images, conditioned_images)
96
+
 
 
 
 
 
 
 
97
  # Compute the loss for the critic
98
  loss_C = real_logits.mean() - fake_logits.mean()
99
 
100
  # Compute the gradient penalty
101
  alpha = torch.rand(real_images.size(0), 1, 1, 1, requires_grad=True).to(real_images.device)
102
+ interpolated = (alpha * real_images + (1 - alpha) * fake_images.detach()).requires_grad_(True)
103
+ interpolated_logits = self.critic(interpolated, conditioned_images)
104
+
105
  gradients = torch.autograd.grad(outputs=interpolated_logits, inputs=interpolated,
106
  grad_outputs=torch.ones_like(interpolated_logits), create_graph=True, retain_graph=True)[0]
107
  gradients = gradients.view(len(gradients), -1)
108
  gradients_penalty = ((gradients.norm(2, dim=1) - 1) ** 2).mean()
109
  loss_C += self.lambda_gp * gradients_penalty
110
+
111
  # Compute the R1 regularization loss
112
  r1_reg = gradients.pow(2).sum(1).mean()
113
  loss_C += self.lambda_r1 * r1_reg
 
116
  loss_C.backward()
117
  optimizer_C.step()
118
  self.critic_losses.append(loss_C.item())
119
+
120
  def training_step(self, batch, batch_idx):
121
+ real, condition = batch
122
+ optimizer_C, optimizer_G = self.optimizers() # Access optimizers
123
+
124
+ # Update the critic
125
+ self.critic_step(real, condition, optimizer_C)
126
+
127
+ # Update the generator
128
+ self.generator_step(real, condition, optimizer_G)
129
+
130
+ # Logging and saving models
131
+ gen_mean = sum(self.generator_losses[-self.display_step:]) / self.display_step
132
+ crit_mean = sum(self.critic_losses[-self.display_step:]) / self.display_step
133
  if self.current_epoch % self.display_step == 0 and batch_idx == 0:
134
+ fake = self.generator(condition).detach()
135
+ logger.info(f"Epoch {self.current_epoch}: Generator loss: {gen_mean}, Critic loss: {crit_mean}")
136
+ display_progress(condition[0], real[0], fake[0], self.current_epoch)
 
 
 
 
 
 
 
137
 
138
 
139
  import os
140
  class ModelTrainer:
141
+ def __init__(self, config):
142
  self.config = config
143
 
144
  def load_datasets(self):
145
  self.train_dataset = torch.load(self.config.train_data_path)
146
  self.test_dataset = torch.load(self.config.test_data_path)
147
+
148
+ # Ensure these are actually datasets, not dataloaders
149
+ if isinstance(self.train_dataset, DataLoader):
150
+ self.train_dataset = self.train_dataset.dataset
151
+ if isinstance(self.test_dataset, DataLoader):
152
+ self.test_dataset = self.test_dataset.dataset
153
 
154
  def create_dataloaders(self):
155
  self.train_dataloader = DataLoader(
156
+ self.train_dataset,
157
+ batch_size=self.config.BATCH_SIZE,
158
+ shuffle=True,
159
  )
160
  self.test_dataloader = DataLoader(
161
+ self.test_dataset,
162
+ batch_size=self.config.BATCH_SIZE,
163
+ shuffle=False,
164
  )
165
+
166
+
167
+
168
+
169
 
170
  def initialize_model(self):
171
  self.model = CWGAN(
172
+ in_channels=1,
173
+ out_channels=2,
174
  learning_rate=self.config.LEARNING_RATE,
175
  lambda_recon=self.config.LAMBDA_RECON,
176
  display_step=self.config.DISPLAY_STEP,
177
+
 
178
  )
179
 
180
  def train_model(self):
src/imagecolorization/pipeline/stage_04_model_trainer.py CHANGED
@@ -14,4 +14,4 @@ class ModelTrainerPipeline:
14
  model_trainer.create_dataloaders()
15
  model_trainer.initialize_model()
16
  model_trainer.train_model()
17
- model_trainer.save_model()
 
14
  model_trainer.create_dataloaders()
15
  model_trainer.initialize_model()
16
  model_trainer.train_model()
17
+ model_trainer.save_model()