Skip to content

Commit

Permalink
Created using Colaboratory
Browse files Browse the repository at this point in the history
  • Loading branch information
kuanyshbakytuly committed Dec 4, 2022
1 parent 816932a commit 83a8e96
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {
"id": "uCHnWyJk0Q5G"
},
Expand All @@ -27,7 +27,7 @@
"from PIL import Image\n",
"import numpy as np\n",
"from torch import optim\n",
"device = 'cuda' if torch.cuda.is_available() else 'cpu'\n",
"device = 'cuda' if torch.cuda.is_available() else 'cpu' #turn on gpu manually on google.colab\n",
"import cv2, glob, numpy as np, pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline\n",
Expand All @@ -37,7 +37,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {
"id": "T0BOBLZp5duS"
},
Expand All @@ -63,7 +63,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {
"id": "56HMIL8K0poZ"
},
Expand All @@ -77,7 +77,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {
"id": "dR2RSeYk1Of6"
},
Expand Down Expand Up @@ -130,22 +130,18 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {
"id": "IXyRQg4y2Kb4"
},
"outputs": [],
"source": [
"def get_model():\n",
" #Returning the pretrained model - ResNET34\n",
" model = models.resnet34(pretrained=True)\n",
"\n",
" #Freezing all parameters\n",
" model = models.vgg16(pretrained=True)\n",
" for param in model.parameters():\n",
" param.requires_grad = False\n",
"\n",
" model.avgpool = nn.AdaptiveAvgPool2d(output_size=(1,1))\n",
" model.fc = nn.Sequential(nn.Flatten(),\n",
" model.classifier = nn.Sequential(nn.Flatten(),\n",
" nn.Linear(512, 128),\n",
" nn.ReLU(),\n",
" nn.Dropout(0.2),\n",
Expand Down Expand Up @@ -176,12 +172,12 @@
"metadata": {
"id": "K2wNQoIsaJ7k"
},
"execution_count": 8,
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {
"id": "MqzB9Zqm27WG"
},
Expand Down Expand Up @@ -293,7 +289,7 @@
"metadata": {
"id": "W1RlDVvcnW3S"
},
"execution_count": 50,
"execution_count": null,
"outputs": []
},
{
Expand Down Expand Up @@ -338,7 +334,7 @@
"metadata": {
"id": "CvmukBsHDra6"
},
"execution_count": 50,
"execution_count": null,
"outputs": []
},
{
Expand All @@ -357,7 +353,7 @@
"metadata": {
"id": "EilsGs-KFWc8"
},
"execution_count": 51,
"execution_count": null,
"outputs": []
},
{
Expand All @@ -369,12 +365,12 @@
"metadata": {
"id": "3uEnEbGfESXV"
},
"execution_count": 52,
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"execution_count": 55,
"execution_count": null,
"metadata": {
"id": "vI845UuqC1xX"
},
Expand Down Expand Up @@ -405,7 +401,7 @@
"colab": {
"provenance": [],
"mount_file_id": "1vhxvWcfW-qM5DiYNadxexVNyUnCBRCxR",
"authorship_tag": "ABX9TyOjYpj3SRUZIRuOe+pkrV1n",
"authorship_tag": "ABX9TyNyuCuyZUaAn8Sa78hxszP2",
"include_colab_link": true
},
"kernelspec": {
Expand Down

0 comments on commit 83a8e96

Please sign in to comment.