Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-174
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abdurrahumaan A N
2022-174
Commits
3728851b
Commit
3728851b
authored
Apr 06, 2022
by
nazeerxexagen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit Dependencies
parent
541d2c43
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
93 additions
and
0 deletions
+93
-0
backend/ImageSearch.ipynb
backend/ImageSearch.ipynb
+93
-0
No files found.
backend/ImageSearch.ipynb
View file @
3728851b
...
...
@@ -62,6 +62,99 @@
"FEATURE_PATH = 'weights/ImageSearch/Features.pt'\n",
"FEATURE_MODEL_WEIGHT_PATH = 'weights/ImageSearch/FeatureExtractorCNN.pt'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# **Import Dependencies**"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": [
"import os\n",
"import sys\n",
"import tqdm \n",
"import random\n",
"\n",
"import warnings\n",
"warnings.filterwarnings(\"ignore\")\n",
"\n",
"import numpy as np\n",
"from PIL import Image\n",
"from subprocess import call\n",
"import matplotlib.pyplot as plt\n",
"from collections import Counter\n",
"from sklearn.utils import shuffle, class_weight\n",
"\n",
"import torch\n",
"torch.cuda.empty_cache()\n",
"\n",
"import torchsummary \n",
"from torch import nn\n",
"from torch import optim\n",
"from torch.nn import functional as F\n",
"from torchvision import datasets, transforms, models\n",
"from torch.utils.data import DataLoader, random_split, Dataset"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": [
"gpu_flag = torch.cuda.is_available()\n",
"device = torch.device(\"cuda:0\" if gpu_flag else \"cpu\")\n",
"\n",
"if gpu_flag:\n",
" print(\"Device Type : {}\".format(torch.cuda.get_device_name(0)))\n",
"else:\n",
" print(\"Device Type : CPU\")\n",
" \n",
"print('Python VERSION:', sys.version)\n",
"print('pyTorch VERSION:', torch.__version__)\n",
"\n",
"print('CUDNN VERSION:', torch.backends.cudnn.version())\n",
"print('Number CUDA Devices:', torch.cuda.device_count())\n",
"print('Active CUDA Device: GPU', torch.cuda.current_device())\n",
"\n",
"print ('Available devices ', torch.cuda.device_count())\n",
"print ('Current cuda device ', torch.cuda.current_device())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": [
"def setup_seed(seed):\n",
" np.random.seed(seed)\n",
" random.seed(seed)\n",
" torch.manual_seed(seed) # cpu\n",
" torch.cuda.manual_seed_all(seed) \n",
" torch.backends.cudnn.deterministic = True \n",
" torch.backends.cudnn.benchmark = True \n",
" \n",
"setup_seed(seed)"
]
}
],
"metadata": {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment