summaryrefslogtreecommitdiff
path: root/notebooks
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2021-06-25 01:19:12 +0200
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2021-06-25 01:19:12 +0200
commite9753c0c1476d4c5aa614e1f65a8dd4302a1ce5b (patch)
treec2ccfe314e61f0bd24b23acf046e733e723919a2 /notebooks
parent1d7f674236d0622addc243d15c05a1dd30ca8121 (diff)
Efficientnet working
Diffstat (limited to 'notebooks')
-rw-r--r--notebooks/00-scratch-pad.ipynb198
1 files changed, 172 insertions, 26 deletions
diff --git a/notebooks/00-scratch-pad.ipynb b/notebooks/00-scratch-pad.ipynb
index 1816021..32f96d1 100644
--- a/notebooks/00-scratch-pad.ipynb
+++ b/notebooks/00-scratch-pad.ipynb
@@ -2,18 +2,9 @@
"cells": [
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 1,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "The autoreload extension is already loaded. To reload it, use:\n",
- " %reload_ext autoreload\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"%load_ext autoreload\n",
"%autoreload 2\n",
@@ -39,13 +30,180 @@
},
{
"cell_type": "code",
+ "execution_count": 2,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from text_recognizer.networks.encoders.efficientnet.efficientnet import EfficientNet"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 63,
+ "metadata": {
+ "scrolled": false
+ },
+ "outputs": [],
+ "source": [
+ "en = EfficientNet(\"b0\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 64,
+ "metadata": {
+ "scrolled": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "==========================================================================================\n",
+ "Layer (type:depth-idx) Output Shape Param #\n",
+ "==========================================================================================\n",
+ "├─Sequential: 1-1 [-1, 32, 111, 111] --\n",
+ "| └─Conv2d: 2-1 [-1, 32, 111, 111] 288\n",
+ "| └─BatchNorm2d: 2-2 [-1, 32, 111, 111] 64\n",
+ "| └─Mish: 2-3 [-1, 32, 111, 111] --\n",
+ "├─ModuleList: 1 [] --\n",
+ "| └─MBConvBlock: 2-4 [-1, 16, 111, 111] --\n",
+ "| | └─Sequential: 3-1 [-1, 32, 111, 111] 352\n",
+ "| | └─Sequential: 3-2 [-1, 32, 111, 111] 552\n",
+ "| | └─Sequential: 3-3 [-1, 16, 111, 111] 544\n",
+ "| └─MBConvBlock: 2-5 [-1, 24, 55, 55] --\n",
+ "| | └─Sequential: 3-4 [-1, 96, 111, 111] 1,728\n",
+ "| | └─Sequential: 3-5 [-1, 96, 55, 55] 1,056\n",
+ "| | └─Sequential: 3-6 [-1, 96, 55, 55] 4,728\n",
+ "| | └─Sequential: 3-7 [-1, 24, 55, 55] 2,352\n",
+ "| └─MBConvBlock: 2-6 [-1, 24, 55, 55] --\n",
+ "| | └─Sequential: 3-8 [-1, 144, 55, 55] 3,744\n",
+ "| | └─Sequential: 3-9 [-1, 144, 55, 55] 1,584\n",
+ "| | └─Sequential: 3-10 [-1, 144, 55, 55] 10,548\n",
+ "| | └─Sequential: 3-11 [-1, 24, 55, 55] 3,504\n",
+ "| └─MBConvBlock: 2-7 [-1, 40, 27, 27] --\n",
+ "| | └─Sequential: 3-12 [-1, 144, 55, 55] 3,744\n",
+ "| | └─Sequential: 3-13 [-1, 144, 27, 27] 3,888\n",
+ "| | └─Sequential: 3-14 [-1, 144, 27, 27] 10,548\n",
+ "| | └─Sequential: 3-15 [-1, 40, 27, 27] 5,840\n",
+ "| └─MBConvBlock: 2-8 [-1, 40, 27, 27] --\n",
+ "| | └─Sequential: 3-16 [-1, 240, 27, 27] 10,080\n",
+ "| | └─Sequential: 3-17 [-1, 240, 27, 27] 6,480\n",
+ "| | └─Sequential: 3-18 [-1, 240, 27, 27] 29,100\n",
+ "| | └─Sequential: 3-19 [-1, 40, 27, 27] 9,680\n",
+ "| └─MBConvBlock: 2-9 [-1, 80, 13, 13] --\n",
+ "| | └─Sequential: 3-20 [-1, 240, 27, 27] 10,080\n",
+ "| | └─Sequential: 3-21 [-1, 240, 13, 13] 2,640\n",
+ "| | └─Sequential: 3-22 [-1, 240, 13, 13] 29,100\n",
+ "| | └─Sequential: 3-23 [-1, 80, 13, 13] 19,360\n",
+ "| └─MBConvBlock: 2-10 [-1, 80, 13, 13] --\n",
+ "| | └─Sequential: 3-24 [-1, 480, 13, 13] 39,360\n",
+ "| | └─Sequential: 3-25 [-1, 480, 13, 13] 5,280\n",
+ "| | └─Sequential: 3-26 [-1, 480, 13, 13] 115,800\n",
+ "| | └─Sequential: 3-27 [-1, 80, 13, 13] 38,560\n",
+ "| └─MBConvBlock: 2-11 [-1, 80, 13, 13] --\n",
+ "| | └─Sequential: 3-28 [-1, 480, 13, 13] 39,360\n",
+ "| | └─Sequential: 3-29 [-1, 480, 13, 13] 5,280\n",
+ "| | └─Sequential: 3-30 [-1, 480, 13, 13] 115,800\n",
+ "| | └─Sequential: 3-31 [-1, 80, 13, 13] 38,560\n",
+ "| └─MBConvBlock: 2-12 [-1, 112, 13, 13] --\n",
+ "| | └─Sequential: 3-32 [-1, 480, 13, 13] 39,360\n",
+ "| | └─Sequential: 3-33 [-1, 480, 13, 13] 12,960\n",
+ "| | └─Sequential: 3-34 [-1, 480, 13, 13] 115,800\n",
+ "| | └─Sequential: 3-35 [-1, 112, 13, 13] 53,984\n",
+ "| └─MBConvBlock: 2-13 [-1, 112, 13, 13] --\n",
+ "| | └─Sequential: 3-36 [-1, 672, 13, 13] 76,608\n",
+ "| | └─Sequential: 3-37 [-1, 672, 13, 13] 18,144\n",
+ "| | └─Sequential: 3-38 [-1, 672, 13, 13] 226,632\n",
+ "| | └─Sequential: 3-39 [-1, 112, 13, 13] 75,488\n",
+ "| └─MBConvBlock: 2-14 [-1, 112, 13, 13] --\n",
+ "| | └─Sequential: 3-40 [-1, 672, 13, 13] 76,608\n",
+ "| | └─Sequential: 3-41 [-1, 672, 13, 13] 18,144\n",
+ "| | └─Sequential: 3-42 [-1, 672, 13, 13] 226,632\n",
+ "| | └─Sequential: 3-43 [-1, 112, 13, 13] 75,488\n",
+ "| └─MBConvBlock: 2-15 [-1, 192, 6, 6] --\n",
+ "| | └─Sequential: 3-44 [-1, 672, 13, 13] 76,608\n",
+ "| | └─Sequential: 3-45 [-1, 672, 6, 6] 18,144\n",
+ "| | └─Sequential: 3-46 [-1, 672, 6, 6] 226,632\n",
+ "| | └─Sequential: 3-47 [-1, 192, 6, 6] 129,408\n",
+ "| └─MBConvBlock: 2-16 [-1, 192, 6, 6] --\n",
+ "| | └─Sequential: 3-48 [-1, 1152, 6, 6] 223,488\n",
+ "| | └─Sequential: 3-49 [-1, 1152, 6, 6] 31,104\n",
+ "| | └─Sequential: 3-50 [-1, 1152, 6, 6] 664,992\n",
+ "| | └─Sequential: 3-51 [-1, 192, 6, 6] 221,568\n",
+ "| └─MBConvBlock: 2-17 [-1, 192, 6, 6] --\n",
+ "| | └─Sequential: 3-52 [-1, 1152, 6, 6] 223,488\n",
+ "| | └─Sequential: 3-53 [-1, 1152, 6, 6] 31,104\n",
+ "| | └─Sequential: 3-54 [-1, 1152, 6, 6] 664,992\n",
+ "| | └─Sequential: 3-55 [-1, 192, 6, 6] 221,568\n",
+ "| └─MBConvBlock: 2-18 [-1, 192, 6, 6] --\n",
+ "| | └─Sequential: 3-56 [-1, 1152, 6, 6] 223,488\n",
+ "| | └─Sequential: 3-57 [-1, 1152, 6, 6] 31,104\n",
+ "| | └─Sequential: 3-58 [-1, 1152, 6, 6] 664,992\n",
+ "| | └─Sequential: 3-59 [-1, 192, 6, 6] 221,568\n",
+ "| └─MBConvBlock: 2-19 [-1, 320, 6, 6] --\n",
+ "| | └─Sequential: 3-60 [-1, 1152, 6, 6] 223,488\n",
+ "| | └─Sequential: 3-61 [-1, 1152, 6, 6] 12,672\n",
+ "| | └─Sequential: 3-62 [-1, 1152, 6, 6] 664,992\n",
+ "| | └─Sequential: 3-63 [-1, 320, 6, 6] 369,280\n",
+ "├─Sequential: 1-2 [-1, 1280, 6, 6] --\n",
+ "| └─Conv2d: 2-20 [-1, 1280, 6, 6] 409,600\n",
+ "| └─BatchNorm2d: 2-21 [-1, 1280, 6, 6] 2,560\n",
+ "==========================================================================================\n",
+ "Total params: 7,142,272\n",
+ "Trainable params: 7,142,272\n",
+ "Non-trainable params: 0\n",
+ "Total mult-adds (M): 657.05\n",
+ "==========================================================================================\n",
+ "Input size (MB): 0.19\n",
+ "Forward/backward pass size (MB): 115.14\n",
+ "Params size (MB): 27.25\n",
+ "Estimated Total Size (MB): 142.58\n",
+ "==========================================================================================\n"
+ ]
+ }
+ ],
+ "source": [
+ "summary(en, (1, 224, 224));"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 54,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "(2, 2)"
+ ]
+ },
+ "execution_count": 54,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "(2,) * 2"
+ ]
+ },
+ {
+ "cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "/home/aktersnurra/.cache/pypoetry/virtualenvs/text-recognizer-ejNaVa9M-py3.9/lib/python3.9/site-packages/torch/cuda/__init__.py:52: UserWarning: CUDA initialization: CUDA unknown error - this may be due to an incorrectly set up environment, e.g. changing env variable CUDA_VISIBLE_DEVICES after program start. Setting the available devices to be zero. (Triggered internally at /pytorch/c10/cuda/CUDAFunctions.cpp:115.)\n",
+ " return torch._C._cuda_getDeviceCount() > 0\n"
+ ]
+ },
+ {
"data": {
"text/plain": [
- "True"
+ "False"
]
},
"execution_count": 4,
@@ -195,21 +353,9 @@
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "ename": "ModuleNotFoundError",
- "evalue": "No module named 'text_recognizer.networks.encoders.efficientnet.efficientnet'",
- "output_type": "error",
- "traceback": [
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
- "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
- "\u001b[0;32m<ipython-input-6-c209d858dfb1>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mtext_recognizer\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mnetworks\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mencoders\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mefficientnet\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mefficientnet\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mEfficientNet\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
- "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'text_recognizer.networks.encoders.efficientnet.efficientnet'"
- ]
- }
- ],
+ "outputs": [],
"source": [
"from text_recognizer.networks.encoders.efficientnet.efficientnet import EfficientNet"
]