Skip to content

Commit

Permalink
added 'cpu' to the summary function in torchsummary as it assumes 'cu…
Browse files Browse the repository at this point in the history
…da' by default,

cosmetic changes,
added requirements.txt
  • Loading branch information
johschmidt42 committed Apr 14, 2021
1 parent 82383d8 commit fe8967a
Show file tree
Hide file tree
Showing 9 changed files with 298 additions and 3,501 deletions.
23 changes: 17 additions & 6 deletions Part1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
{
"data": {
"text/plain": [
"<napari.viewer.Viewer at 0x21663894a00>"
"Viewer(axes=Axes(visible=False, labels=True, colored=True, dashed=False, arrows=True), camera=Camera(center=(0.0, 639.5, 958.5), zoom=0.2859415753781951, angles=(0.0, 0.0, 90.0), interactive=True), cursor=Cursor(position=(0.0, 0.0), scaled=True, size=10, style='standard'), dims=Dims(ndim=2, ndisplay=2, last_used=1, range=((0.0, 1279.0, 1.0), (0.0, 1917.0, 1.0)), current_step=(0, 0), order=(0, 1), axis_labels=('0', '1')), grid=GridCanvas(enabled=False, stride=1, shape=(-1, -1)), layers=[<Image layer 'input_training' at 0x20a86a790a0>, <Labels layer 'target_training' at 0x20a86a79b50>], scale_bar=ScaleBar(visible=False, colored=False, ticks=True, position='bottom_right'), active_layer=<Labels layer 'target_training' at 0x20a86a79b50>, help='enter paint or fill mode to edit labels', status='Ready', theme='dark', title='napari', mouse_move_callbacks=[], mouse_drag_callbacks=[], mouse_wheel_callbacks=[<function dims_scroll at 0x0000020A80C60790>], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, keymap={'T': <function show_input_target_pair_napari.<locals>.next_batch_training at 0x0000020A8FDD9670>})"
]
},
"execution_count": 3,
Expand Down Expand Up @@ -176,9 +176,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"Viewer(axes=Axes(visible=False, labels=True, colored=True, dashed=False, arrows=True), camera=Camera(center=(0.0, 639.5, 958.5), zoom=0.2859415753781951, angles=(0.0, 0.0, 90.0), interactive=True), cursor=Cursor(position=(0.0, 0.0), scaled=True, size=10, style='standard'), dims=Dims(ndim=2, ndisplay=2, last_used=1, range=((0.0, 1279.0, 1.0), (0.0, 1917.0, 1.0)), current_step=(0, 0), order=(0, 1), axis_labels=('0', '1')), grid=GridCanvas(enabled=False, stride=1, shape=(-1, -1)), layers=[<Image layer 'input_training' at 0x20a97119760>, <Labels layer 'target_training' at 0x20a97060be0>], scale_bar=ScaleBar(visible=False, colored=False, ticks=True, position='bottom_right'), active_layer=<Labels layer 'target_training' at 0x20a97060be0>, help='enter paint or fill mode to edit labels', status='Ready', theme='dark', title='napari', mouse_move_callbacks=[], mouse_drag_callbacks=[], mouse_wheel_callbacks=[<function dims_scroll at 0x0000020A80C60790>], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, keymap={'T': <function show_input_target_pair_napari.<locals>.next_batch_training at 0x0000020A9D207AF0>, 'V': <function show_input_target_pair_napari.<locals>.next_batch_validation at 0x0000020A9D207B80>})"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%gui qt\n",
"from visual import Input_Target_Pair_Generator\n",
Expand All @@ -205,9 +216,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.8"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
"nbformat_minor": 4
}
203 changes: 104 additions & 99 deletions Part2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,101 +41,90 @@
"name": "stdout",
"output_type": "stream",
"text": [
"==========================================================================================\n",
"Layer (type:depth-idx) Output Shape Param #\n",
"==========================================================================================\n",
"├─ModuleList: 1 [] --\n",
"| └─DownBlock: 2-1 [-1, 32, 256, 256] --\n",
"| | └─Conv2d: 3-1 [-1, 32, 512, 512] 320\n",
"| | └─ReLU: 3-2 [-1, 32, 512, 512] --\n",
"| | └─BatchNorm2d: 3-3 [-1, 32, 512, 512] 64\n",
"| | └─Conv2d: 3-4 [-1, 32, 512, 512] 9,248\n",
"| | └─ReLU: 3-5 [-1, 32, 512, 512] --\n",
"| | └─BatchNorm2d: 3-6 [-1, 32, 512, 512] 64\n",
"| | └─MaxPool2d: 3-7 [-1, 32, 256, 256] --\n",
"| └─DownBlock: 2-2 [-1, 64, 128, 128] --\n",
"| | └─Conv2d: 3-8 [-1, 64, 256, 256] 18,496\n",
"| | └─ReLU: 3-9 [-1, 64, 256, 256] --\n",
"| | └─BatchNorm2d: 3-10 [-1, 64, 256, 256] 128\n",
"| | └─Conv2d: 3-11 [-1, 64, 256, 256] 36,928\n",
"| | └─ReLU: 3-12 [-1, 64, 256, 256] --\n",
"| | └─BatchNorm2d: 3-13 [-1, 64, 256, 256] 128\n",
"| | └─MaxPool2d: 3-14 [-1, 64, 128, 128] --\n",
"| └─DownBlock: 2-3 [-1, 128, 64, 64] --\n",
"| | └─Conv2d: 3-15 [-1, 128, 128, 128] 73,856\n",
"| | └─ReLU: 3-16 [-1, 128, 128, 128] --\n",
"| | └─BatchNorm2d: 3-17 [-1, 128, 128, 128] 256\n",
"| | └─Conv2d: 3-18 [-1, 128, 128, 128] 147,584\n",
"| | └─ReLU: 3-19 [-1, 128, 128, 128] --\n",
"| | └─BatchNorm2d: 3-20 [-1, 128, 128, 128] 256\n",
"| | └─MaxPool2d: 3-21 [-1, 128, 64, 64] --\n",
"| └─DownBlock: 2-4 [-1, 256, 64, 64] --\n",
"| | └─Conv2d: 3-22 [-1, 256, 64, 64] 295,168\n",
"| | └─ReLU: 3-23 [-1, 256, 64, 64] --\n",
"| | └─BatchNorm2d: 3-24 [-1, 256, 64, 64] 512\n",
"| | └─Conv2d: 3-25 [-1, 256, 64, 64] 590,080\n",
"| | └─ReLU: 3-26 [-1, 256, 64, 64] --\n",
"| | └─BatchNorm2d: 3-27 [-1, 256, 64, 64] 512\n",
"├─ModuleList: 1 [] --\n",
"| └─UpBlock: 2-5 [-1, 128, 128, 128] --\n",
"| | └─ConvTranspose2d: 3-28 [-1, 128, 128, 128] 131,200\n",
"| | └─ReLU: 3-29 [-1, 128, 128, 128] --\n",
"| | └─BatchNorm2d: 3-30 [-1, 128, 128, 128] 256\n",
"| | └─Concatenate: 3-31 [-1, 256, 128, 128] --\n",
"| | └─Conv2d: 3-32 [-1, 128, 128, 128] 295,040\n",
"| | └─ReLU: 3-33 [-1, 128, 128, 128] --\n",
"| | └─BatchNorm2d: 3-34 [-1, 128, 128, 128] 256\n",
"| | └─Conv2d: 3-35 [-1, 128, 128, 128] 147,584\n",
"| | └─ReLU: 3-36 [-1, 128, 128, 128] --\n",
"| | └─BatchNorm2d: 3-37 [-1, 128, 128, 128] 256\n",
"| └─UpBlock: 2-6 [-1, 64, 256, 256] --\n",
"| | └─ConvTranspose2d: 3-38 [-1, 64, 256, 256] 32,832\n",
"| | └─ReLU: 3-39 [-1, 64, 256, 256] --\n",
"| | └─BatchNorm2d: 3-40 [-1, 64, 256, 256] 128\n",
"| | └─Concatenate: 3-41 [-1, 128, 256, 256] --\n",
"| | └─Conv2d: 3-42 [-1, 64, 256, 256] 73,792\n",
"| | └─ReLU: 3-43 [-1, 64, 256, 256] --\n",
"| | └─BatchNorm2d: 3-44 [-1, 64, 256, 256] 128\n",
"| | └─Conv2d: 3-45 [-1, 64, 256, 256] 36,928\n",
"| | └─ReLU: 3-46 [-1, 64, 256, 256] --\n",
"| | └─BatchNorm2d: 3-47 [-1, 64, 256, 256] 128\n",
"| └─UpBlock: 2-7 [-1, 32, 512, 512] --\n",
"| | └─ConvTranspose2d: 3-48 [-1, 32, 512, 512] 8,224\n",
"| | └─ReLU: 3-49 [-1, 32, 512, 512] --\n",
"| | └─BatchNorm2d: 3-50 [-1, 32, 512, 512] 64\n",
"| | └─Concatenate: 3-51 [-1, 64, 512, 512] --\n",
"| | └─Conv2d: 3-52 [-1, 32, 512, 512] 18,464\n",
"| | └─ReLU: 3-53 [-1, 32, 512, 512] --\n",
"| | └─BatchNorm2d: 3-54 [-1, 32, 512, 512] 64\n",
"| | └─Conv2d: 3-55 [-1, 32, 512, 512] 9,248\n",
"| | └─ReLU: 3-56 [-1, 32, 512, 512] --\n",
"| | └─BatchNorm2d: 3-57 [-1, 32, 512, 512] 64\n",
"├─Conv2d: 1-1 [-1, 2, 512, 512] 66\n",
"==========================================================================================\n",
"----------------------------------------------------------------\n",
" Layer (type) Output Shape Param #\n",
"================================================================\n",
" Conv2d-1 [-1, 32, 512, 512] 320\n",
" ReLU-2 [-1, 32, 512, 512] 0\n",
" BatchNorm2d-3 [-1, 32, 512, 512] 64\n",
" Conv2d-4 [-1, 32, 512, 512] 9,248\n",
" ReLU-5 [-1, 32, 512, 512] 0\n",
" BatchNorm2d-6 [-1, 32, 512, 512] 64\n",
" MaxPool2d-7 [-1, 32, 256, 256] 0\n",
" DownBlock-8 [[-1, 32, 256, 256], [-1, 32, 512, 512]] 0\n",
" Conv2d-9 [-1, 64, 256, 256] 18,496\n",
" ReLU-10 [-1, 64, 256, 256] 0\n",
" BatchNorm2d-11 [-1, 64, 256, 256] 128\n",
" Conv2d-12 [-1, 64, 256, 256] 36,928\n",
" ReLU-13 [-1, 64, 256, 256] 0\n",
" BatchNorm2d-14 [-1, 64, 256, 256] 128\n",
" MaxPool2d-15 [-1, 64, 128, 128] 0\n",
" DownBlock-16 [[-1, 64, 128, 128], [-1, 64, 256, 256]] 0\n",
" Conv2d-17 [-1, 128, 128, 128] 73,856\n",
" ReLU-18 [-1, 128, 128, 128] 0\n",
" BatchNorm2d-19 [-1, 128, 128, 128] 256\n",
" Conv2d-20 [-1, 128, 128, 128] 147,584\n",
" ReLU-21 [-1, 128, 128, 128] 0\n",
" BatchNorm2d-22 [-1, 128, 128, 128] 256\n",
" MaxPool2d-23 [-1, 128, 64, 64] 0\n",
" DownBlock-24 [[-1, 128, 64, 64], [-1, 128, 128, 128]] 0\n",
" Conv2d-25 [-1, 256, 64, 64] 295,168\n",
" ReLU-26 [-1, 256, 64, 64] 0\n",
" BatchNorm2d-27 [-1, 256, 64, 64] 512\n",
" Conv2d-28 [-1, 256, 64, 64] 590,080\n",
" ReLU-29 [-1, 256, 64, 64] 0\n",
" BatchNorm2d-30 [-1, 256, 64, 64] 512\n",
" DownBlock-31 [[-1, 256, 64, 64], [-1, 256, 64, 64]] 0\n",
" ConvTranspose2d-32 [-1, 128, 128, 128] 131,200\n",
" ReLU-33 [-1, 128, 128, 128] 0\n",
" BatchNorm2d-34 [-1, 128, 128, 128] 256\n",
" Concatenate-35 [-1, 256, 128, 128] 0\n",
" Conv2d-36 [-1, 128, 128, 128] 295,040\n",
" ReLU-37 [-1, 128, 128, 128] 0\n",
" BatchNorm2d-38 [-1, 128, 128, 128] 256\n",
" Conv2d-39 [-1, 128, 128, 128] 147,584\n",
" ReLU-40 [-1, 128, 128, 128] 0\n",
" BatchNorm2d-41 [-1, 128, 128, 128] 256\n",
" UpBlock-42 [-1, 128, 128, 128] 0\n",
" ConvTranspose2d-43 [-1, 64, 256, 256] 32,832\n",
" ReLU-44 [-1, 64, 256, 256] 0\n",
" BatchNorm2d-45 [-1, 64, 256, 256] 128\n",
" Concatenate-46 [-1, 128, 256, 256] 0\n",
" Conv2d-47 [-1, 64, 256, 256] 73,792\n",
" ReLU-48 [-1, 64, 256, 256] 0\n",
" BatchNorm2d-49 [-1, 64, 256, 256] 128\n",
" Conv2d-50 [-1, 64, 256, 256] 36,928\n",
" ReLU-51 [-1, 64, 256, 256] 0\n",
" BatchNorm2d-52 [-1, 64, 256, 256] 128\n",
" UpBlock-53 [-1, 64, 256, 256] 0\n",
" ConvTranspose2d-54 [-1, 32, 512, 512] 8,224\n",
" ReLU-55 [-1, 32, 512, 512] 0\n",
" BatchNorm2d-56 [-1, 32, 512, 512] 64\n",
" Concatenate-57 [-1, 64, 512, 512] 0\n",
" Conv2d-58 [-1, 32, 512, 512] 18,464\n",
" ReLU-59 [-1, 32, 512, 512] 0\n",
" BatchNorm2d-60 [-1, 32, 512, 512] 64\n",
" Conv2d-61 [-1, 32, 512, 512] 9,248\n",
" ReLU-62 [-1, 32, 512, 512] 0\n",
" BatchNorm2d-63 [-1, 32, 512, 512] 64\n",
" UpBlock-64 [-1, 32, 512, 512] 0\n",
" Conv2d-65 [-1, 2, 512, 512] 66\n",
"================================================================\n",
"Total params: 1,928,322\n",
"Trainable params: 1,928,322\n",
"Non-trainable params: 0\n",
"Total mult-adds (M): -14267.05\n",
"==========================================================================================\n",
"----------------------------------------------------------------\n",
"Input size (MB): 1.00\n",
"Forward/backward pass size (MB): 1156.00\n",
"Forward/backward pass size (MB): 2096.00\n",
"Params size (MB): 7.36\n",
"Estimated Total Size (MB): 1164.36\n",
"==========================================================================================\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\ProgramData\\Miniconda3\\envs\\test_env\\lib\\site-packages\\torchsummary\\layer_info.py:122: RuntimeWarning: overflow encountered in long_scalars\n",
" self.macs += int(param.nelement() * np.prod(self.output_size[2:]))\n"
"Estimated Total Size (MB): 2104.36\n",
"----------------------------------------------------------------\n"
]
}
],
"source": [
"from torchsummary import summary\n",
"summary = summary(model, (1, 512, 512))"
"summary = summary(model, (1, 512, 512), device='cpu')"
]
},
{
Expand Down Expand Up @@ -183,8 +172,30 @@
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"execution_count": 4,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"data": {
"text/plain": [
"{256: [256, 128.0, 64.0, 32.0, 16.0, 8.0, 4.0, 2.0],\n",
" 384: [384, 192.0, 96.0, 48.0, 24.0, 12.0, 6.0, 3.0],\n",
" 512: [512, 256.0, 128.0, 64.0, 32.0, 16.0, 8.0, 4.0]}"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"low = 10\n",
"high = 512\n",
Expand All @@ -203,17 +214,11 @@
" return possible_shapes\n",
"possible_shapes = compute_possible_shapes(low, high, depth)\n",
"possible_shapes"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand All @@ -224,7 +229,7 @@
" 512: [512, 256.0, 128.0, 64.0, 32.0, 16.0, 8.0, 4.0]}"
]
},
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -266,9 +271,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.8"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
"nbformat_minor": 4
}
Loading

0 comments on commit fe8967a

Please sign in to comment.