Upload classificationn.ipynb
Browse files- classificationn.ipynb +1137 -0
classificationn.ipynb
ADDED
@@ -0,0 +1,1137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": null,
|
6 |
+
"metadata": {
|
7 |
+
"colab": {
|
8 |
+
"base_uri": "https://localhost:8080/"
|
9 |
+
},
|
10 |
+
"id": "e9tLVH2veLrg",
|
11 |
+
"outputId": "d7d0d808-46aa-40db-be05-5d27d2e26bce"
|
12 |
+
},
|
13 |
+
"outputs": [
|
14 |
+
{
|
15 |
+
"output_type": "stream",
|
16 |
+
"name": "stdout",
|
17 |
+
"text": [
|
18 |
+
"Requirement already satisfied: torchvision in /usr/local/lib/python3.10/dist-packages (0.18.0+cu121)\n",
|
19 |
+
"Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from torchvision) (1.25.2)\n",
|
20 |
+
"Requirement already satisfied: torch==2.3.0 in /usr/local/lib/python3.10/dist-packages (from torchvision) (2.3.0+cu121)\n",
|
21 |
+
"Requirement already satisfied: pillow!=8.3.*,>=5.3.0 in /usr/local/lib/python3.10/dist-packages (from torchvision) (9.4.0)\n",
|
22 |
+
"Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from torch==2.3.0->torchvision) (3.14.0)\n",
|
23 |
+
"Requirement already satisfied: typing-extensions>=4.8.0 in /usr/local/lib/python3.10/dist-packages (from torch==2.3.0->torchvision) (4.12.2)\n",
|
24 |
+
"Requirement already satisfied: sympy in /usr/local/lib/python3.10/dist-packages (from torch==2.3.0->torchvision) (1.12.1)\n",
|
25 |
+
"Requirement already satisfied: networkx in /usr/local/lib/python3.10/dist-packages (from torch==2.3.0->torchvision) (3.3)\n",
|
26 |
+
"Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/dist-packages (from torch==2.3.0->torchvision) (3.1.4)\n",
|
27 |
+
"Requirement already satisfied: fsspec in /usr/local/lib/python3.10/dist-packages (from torch==2.3.0->torchvision) (2023.6.0)\n",
|
28 |
+
"Collecting nvidia-cuda-nvrtc-cu12==12.1.105 (from torch==2.3.0->torchvision)\n",
|
29 |
+
" Using cached nvidia_cuda_nvrtc_cu12-12.1.105-py3-none-manylinux1_x86_64.whl (23.7 MB)\n",
|
30 |
+
"Collecting nvidia-cuda-runtime-cu12==12.1.105 (from torch==2.3.0->torchvision)\n",
|
31 |
+
" Using cached nvidia_cuda_runtime_cu12-12.1.105-py3-none-manylinux1_x86_64.whl (823 kB)\n",
|
32 |
+
"Collecting nvidia-cuda-cupti-cu12==12.1.105 (from torch==2.3.0->torchvision)\n",
|
33 |
+
" Using cached nvidia_cuda_cupti_cu12-12.1.105-py3-none-manylinux1_x86_64.whl (14.1 MB)\n",
|
34 |
+
"Collecting nvidia-cudnn-cu12==8.9.2.26 (from torch==2.3.0->torchvision)\n",
|
35 |
+
" Using cached nvidia_cudnn_cu12-8.9.2.26-py3-none-manylinux1_x86_64.whl (731.7 MB)\n",
|
36 |
+
"Collecting nvidia-cublas-cu12==12.1.3.1 (from torch==2.3.0->torchvision)\n",
|
37 |
+
" Using cached nvidia_cublas_cu12-12.1.3.1-py3-none-manylinux1_x86_64.whl (410.6 MB)\n",
|
38 |
+
"Collecting nvidia-cufft-cu12==11.0.2.54 (from torch==2.3.0->torchvision)\n",
|
39 |
+
" Using cached nvidia_cufft_cu12-11.0.2.54-py3-none-manylinux1_x86_64.whl (121.6 MB)\n",
|
40 |
+
"Collecting nvidia-curand-cu12==10.3.2.106 (from torch==2.3.0->torchvision)\n",
|
41 |
+
" Using cached nvidia_curand_cu12-10.3.2.106-py3-none-manylinux1_x86_64.whl (56.5 MB)\n",
|
42 |
+
"Collecting nvidia-cusolver-cu12==11.4.5.107 (from torch==2.3.0->torchvision)\n",
|
43 |
+
" Using cached nvidia_cusolver_cu12-11.4.5.107-py3-none-manylinux1_x86_64.whl (124.2 MB)\n",
|
44 |
+
"Collecting nvidia-cusparse-cu12==12.1.0.106 (from torch==2.3.0->torchvision)\n",
|
45 |
+
" Using cached nvidia_cusparse_cu12-12.1.0.106-py3-none-manylinux1_x86_64.whl (196.0 MB)\n",
|
46 |
+
"Collecting nvidia-nccl-cu12==2.20.5 (from torch==2.3.0->torchvision)\n",
|
47 |
+
" Using cached nvidia_nccl_cu12-2.20.5-py3-none-manylinux2014_x86_64.whl (176.2 MB)\n",
|
48 |
+
"Collecting nvidia-nvtx-cu12==12.1.105 (from torch==2.3.0->torchvision)\n",
|
49 |
+
" Using cached nvidia_nvtx_cu12-12.1.105-py3-none-manylinux1_x86_64.whl (99 kB)\n",
|
50 |
+
"Requirement already satisfied: triton==2.3.0 in /usr/local/lib/python3.10/dist-packages (from torch==2.3.0->torchvision) (2.3.0)\n",
|
51 |
+
"Collecting nvidia-nvjitlink-cu12 (from nvidia-cusolver-cu12==11.4.5.107->torch==2.3.0->torchvision)\n",
|
52 |
+
" Downloading nvidia_nvjitlink_cu12-12.5.40-py3-none-manylinux2014_x86_64.whl (21.3 MB)\n",
|
53 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m21.3/21.3 MB\u001b[0m \u001b[31m22.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
54 |
+
"\u001b[?25hRequirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from jinja2->torch==2.3.0->torchvision) (2.1.5)\n",
|
55 |
+
"Requirement already satisfied: mpmath<1.4.0,>=1.1.0 in /usr/local/lib/python3.10/dist-packages (from sympy->torch==2.3.0->torchvision) (1.3.0)\n",
|
56 |
+
"Installing collected packages: nvidia-nvtx-cu12, nvidia-nvjitlink-cu12, nvidia-nccl-cu12, nvidia-curand-cu12, nvidia-cufft-cu12, nvidia-cuda-runtime-cu12, nvidia-cuda-nvrtc-cu12, nvidia-cuda-cupti-cu12, nvidia-cublas-cu12, nvidia-cusparse-cu12, nvidia-cudnn-cu12, nvidia-cusolver-cu12\n",
|
57 |
+
"Successfully installed nvidia-cublas-cu12-12.1.3.1 nvidia-cuda-cupti-cu12-12.1.105 nvidia-cuda-nvrtc-cu12-12.1.105 nvidia-cuda-runtime-cu12-12.1.105 nvidia-cudnn-cu12-8.9.2.26 nvidia-cufft-cu12-11.0.2.54 nvidia-curand-cu12-10.3.2.106 nvidia-cusolver-cu12-11.4.5.107 nvidia-cusparse-cu12-12.1.0.106 nvidia-nccl-cu12-2.20.5 nvidia-nvjitlink-cu12-12.5.40 nvidia-nvtx-cu12-12.1.105\n"
|
58 |
+
]
|
59 |
+
},
|
60 |
+
{
|
61 |
+
"output_type": "execute_result",
|
62 |
+
"data": {
|
63 |
+
"text/plain": [
|
64 |
+
"['AlexNet',\n",
|
65 |
+
" 'AlexNet_Weights',\n",
|
66 |
+
" 'ConvNeXt',\n",
|
67 |
+
" 'ConvNeXt_Base_Weights',\n",
|
68 |
+
" 'ConvNeXt_Large_Weights',\n",
|
69 |
+
" 'ConvNeXt_Small_Weights',\n",
|
70 |
+
" 'ConvNeXt_Tiny_Weights',\n",
|
71 |
+
" 'DenseNet',\n",
|
72 |
+
" 'DenseNet121_Weights',\n",
|
73 |
+
" 'DenseNet161_Weights',\n",
|
74 |
+
" 'DenseNet169_Weights',\n",
|
75 |
+
" 'DenseNet201_Weights',\n",
|
76 |
+
" 'EfficientNet',\n",
|
77 |
+
" 'EfficientNet_B0_Weights',\n",
|
78 |
+
" 'EfficientNet_B1_Weights',\n",
|
79 |
+
" 'EfficientNet_B2_Weights',\n",
|
80 |
+
" 'EfficientNet_B3_Weights',\n",
|
81 |
+
" 'EfficientNet_B4_Weights',\n",
|
82 |
+
" 'EfficientNet_B5_Weights',\n",
|
83 |
+
" 'EfficientNet_B6_Weights',\n",
|
84 |
+
" 'EfficientNet_B7_Weights',\n",
|
85 |
+
" 'EfficientNet_V2_L_Weights',\n",
|
86 |
+
" 'EfficientNet_V2_M_Weights',\n",
|
87 |
+
" 'EfficientNet_V2_S_Weights',\n",
|
88 |
+
" 'GoogLeNet',\n",
|
89 |
+
" 'GoogLeNetOutputs',\n",
|
90 |
+
" 'GoogLeNet_Weights',\n",
|
91 |
+
" 'Inception3',\n",
|
92 |
+
" 'InceptionOutputs',\n",
|
93 |
+
" 'Inception_V3_Weights',\n",
|
94 |
+
" 'MNASNet',\n",
|
95 |
+
" 'MNASNet0_5_Weights',\n",
|
96 |
+
" 'MNASNet0_75_Weights',\n",
|
97 |
+
" 'MNASNet1_0_Weights',\n",
|
98 |
+
" 'MNASNet1_3_Weights',\n",
|
99 |
+
" 'MaxVit',\n",
|
100 |
+
" 'MaxVit_T_Weights',\n",
|
101 |
+
" 'MobileNetV2',\n",
|
102 |
+
" 'MobileNetV3',\n",
|
103 |
+
" 'MobileNet_V2_Weights',\n",
|
104 |
+
" 'MobileNet_V3_Large_Weights',\n",
|
105 |
+
" 'MobileNet_V3_Small_Weights',\n",
|
106 |
+
" 'RegNet',\n",
|
107 |
+
" 'RegNet_X_16GF_Weights',\n",
|
108 |
+
" 'RegNet_X_1_6GF_Weights',\n",
|
109 |
+
" 'RegNet_X_32GF_Weights',\n",
|
110 |
+
" 'RegNet_X_3_2GF_Weights',\n",
|
111 |
+
" 'RegNet_X_400MF_Weights',\n",
|
112 |
+
" 'RegNet_X_800MF_Weights',\n",
|
113 |
+
" 'RegNet_X_8GF_Weights',\n",
|
114 |
+
" 'RegNet_Y_128GF_Weights',\n",
|
115 |
+
" 'RegNet_Y_16GF_Weights',\n",
|
116 |
+
" 'RegNet_Y_1_6GF_Weights',\n",
|
117 |
+
" 'RegNet_Y_32GF_Weights',\n",
|
118 |
+
" 'RegNet_Y_3_2GF_Weights',\n",
|
119 |
+
" 'RegNet_Y_400MF_Weights',\n",
|
120 |
+
" 'RegNet_Y_800MF_Weights',\n",
|
121 |
+
" 'RegNet_Y_8GF_Weights',\n",
|
122 |
+
" 'ResNeXt101_32X8D_Weights',\n",
|
123 |
+
" 'ResNeXt101_64X4D_Weights',\n",
|
124 |
+
" 'ResNeXt50_32X4D_Weights',\n",
|
125 |
+
" 'ResNet',\n",
|
126 |
+
" 'ResNet101_Weights',\n",
|
127 |
+
" 'ResNet152_Weights',\n",
|
128 |
+
" 'ResNet18_Weights',\n",
|
129 |
+
" 'ResNet34_Weights',\n",
|
130 |
+
" 'ResNet50_Weights',\n",
|
131 |
+
" 'ShuffleNetV2',\n",
|
132 |
+
" 'ShuffleNet_V2_X0_5_Weights',\n",
|
133 |
+
" 'ShuffleNet_V2_X1_0_Weights',\n",
|
134 |
+
" 'ShuffleNet_V2_X1_5_Weights',\n",
|
135 |
+
" 'ShuffleNet_V2_X2_0_Weights',\n",
|
136 |
+
" 'SqueezeNet',\n",
|
137 |
+
" 'SqueezeNet1_0_Weights',\n",
|
138 |
+
" 'SqueezeNet1_1_Weights',\n",
|
139 |
+
" 'SwinTransformer',\n",
|
140 |
+
" 'Swin_B_Weights',\n",
|
141 |
+
" 'Swin_S_Weights',\n",
|
142 |
+
" 'Swin_T_Weights',\n",
|
143 |
+
" 'Swin_V2_B_Weights',\n",
|
144 |
+
" 'Swin_V2_S_Weights',\n",
|
145 |
+
" 'Swin_V2_T_Weights',\n",
|
146 |
+
" 'VGG',\n",
|
147 |
+
" 'VGG11_BN_Weights',\n",
|
148 |
+
" 'VGG11_Weights',\n",
|
149 |
+
" 'VGG13_BN_Weights',\n",
|
150 |
+
" 'VGG13_Weights',\n",
|
151 |
+
" 'VGG16_BN_Weights',\n",
|
152 |
+
" 'VGG16_Weights',\n",
|
153 |
+
" 'VGG19_BN_Weights',\n",
|
154 |
+
" 'VGG19_Weights',\n",
|
155 |
+
" 'ViT_B_16_Weights',\n",
|
156 |
+
" 'ViT_B_32_Weights',\n",
|
157 |
+
" 'ViT_H_14_Weights',\n",
|
158 |
+
" 'ViT_L_16_Weights',\n",
|
159 |
+
" 'ViT_L_32_Weights',\n",
|
160 |
+
" 'VisionTransformer',\n",
|
161 |
+
" 'Weights',\n",
|
162 |
+
" 'WeightsEnum',\n",
|
163 |
+
" 'Wide_ResNet101_2_Weights',\n",
|
164 |
+
" 'Wide_ResNet50_2_Weights',\n",
|
165 |
+
" '_GoogLeNetOutputs',\n",
|
166 |
+
" '_InceptionOutputs',\n",
|
167 |
+
" '__builtins__',\n",
|
168 |
+
" '__cached__',\n",
|
169 |
+
" '__doc__',\n",
|
170 |
+
" '__file__',\n",
|
171 |
+
" '__loader__',\n",
|
172 |
+
" '__name__',\n",
|
173 |
+
" '__package__',\n",
|
174 |
+
" '__path__',\n",
|
175 |
+
" '__spec__',\n",
|
176 |
+
" '_api',\n",
|
177 |
+
" '_meta',\n",
|
178 |
+
" '_utils',\n",
|
179 |
+
" 'alexnet',\n",
|
180 |
+
" 'convnext',\n",
|
181 |
+
" 'convnext_base',\n",
|
182 |
+
" 'convnext_large',\n",
|
183 |
+
" 'convnext_small',\n",
|
184 |
+
" 'convnext_tiny',\n",
|
185 |
+
" 'densenet',\n",
|
186 |
+
" 'densenet121',\n",
|
187 |
+
" 'densenet161',\n",
|
188 |
+
" 'densenet169',\n",
|
189 |
+
" 'densenet201',\n",
|
190 |
+
" 'detection',\n",
|
191 |
+
" 'efficientnet',\n",
|
192 |
+
" 'efficientnet_b0',\n",
|
193 |
+
" 'efficientnet_b1',\n",
|
194 |
+
" 'efficientnet_b2',\n",
|
195 |
+
" 'efficientnet_b3',\n",
|
196 |
+
" 'efficientnet_b4',\n",
|
197 |
+
" 'efficientnet_b5',\n",
|
198 |
+
" 'efficientnet_b6',\n",
|
199 |
+
" 'efficientnet_b7',\n",
|
200 |
+
" 'efficientnet_v2_l',\n",
|
201 |
+
" 'efficientnet_v2_m',\n",
|
202 |
+
" 'efficientnet_v2_s',\n",
|
203 |
+
" 'get_model',\n",
|
204 |
+
" 'get_model_builder',\n",
|
205 |
+
" 'get_model_weights',\n",
|
206 |
+
" 'get_weight',\n",
|
207 |
+
" 'googlenet',\n",
|
208 |
+
" 'inception',\n",
|
209 |
+
" 'inception_v3',\n",
|
210 |
+
" 'list_models',\n",
|
211 |
+
" 'maxvit',\n",
|
212 |
+
" 'maxvit_t',\n",
|
213 |
+
" 'mnasnet',\n",
|
214 |
+
" 'mnasnet0_5',\n",
|
215 |
+
" 'mnasnet0_75',\n",
|
216 |
+
" 'mnasnet1_0',\n",
|
217 |
+
" 'mnasnet1_3',\n",
|
218 |
+
" 'mobilenet',\n",
|
219 |
+
" 'mobilenet_v2',\n",
|
220 |
+
" 'mobilenet_v3_large',\n",
|
221 |
+
" 'mobilenet_v3_small',\n",
|
222 |
+
" 'mobilenetv2',\n",
|
223 |
+
" 'mobilenetv3',\n",
|
224 |
+
" 'optical_flow',\n",
|
225 |
+
" 'quantization',\n",
|
226 |
+
" 'regnet',\n",
|
227 |
+
" 'regnet_x_16gf',\n",
|
228 |
+
" 'regnet_x_1_6gf',\n",
|
229 |
+
" 'regnet_x_32gf',\n",
|
230 |
+
" 'regnet_x_3_2gf',\n",
|
231 |
+
" 'regnet_x_400mf',\n",
|
232 |
+
" 'regnet_x_800mf',\n",
|
233 |
+
" 'regnet_x_8gf',\n",
|
234 |
+
" 'regnet_y_128gf',\n",
|
235 |
+
" 'regnet_y_16gf',\n",
|
236 |
+
" 'regnet_y_1_6gf',\n",
|
237 |
+
" 'regnet_y_32gf',\n",
|
238 |
+
" 'regnet_y_3_2gf',\n",
|
239 |
+
" 'regnet_y_400mf',\n",
|
240 |
+
" 'regnet_y_800mf',\n",
|
241 |
+
" 'regnet_y_8gf',\n",
|
242 |
+
" 'resnet',\n",
|
243 |
+
" 'resnet101',\n",
|
244 |
+
" 'resnet152',\n",
|
245 |
+
" 'resnet18',\n",
|
246 |
+
" 'resnet34',\n",
|
247 |
+
" 'resnet50',\n",
|
248 |
+
" 'resnext101_32x8d',\n",
|
249 |
+
" 'resnext101_64x4d',\n",
|
250 |
+
" 'resnext50_32x4d',\n",
|
251 |
+
" 'segmentation',\n",
|
252 |
+
" 'shufflenet_v2_x0_5',\n",
|
253 |
+
" 'shufflenet_v2_x1_0',\n",
|
254 |
+
" 'shufflenet_v2_x1_5',\n",
|
255 |
+
" 'shufflenet_v2_x2_0',\n",
|
256 |
+
" 'shufflenetv2',\n",
|
257 |
+
" 'squeezenet',\n",
|
258 |
+
" 'squeezenet1_0',\n",
|
259 |
+
" 'squeezenet1_1',\n",
|
260 |
+
" 'swin_b',\n",
|
261 |
+
" 'swin_s',\n",
|
262 |
+
" 'swin_t',\n",
|
263 |
+
" 'swin_transformer',\n",
|
264 |
+
" 'swin_v2_b',\n",
|
265 |
+
" 'swin_v2_s',\n",
|
266 |
+
" 'swin_v2_t',\n",
|
267 |
+
" 'vgg',\n",
|
268 |
+
" 'vgg11',\n",
|
269 |
+
" 'vgg11_bn',\n",
|
270 |
+
" 'vgg13',\n",
|
271 |
+
" 'vgg13_bn',\n",
|
272 |
+
" 'vgg16',\n",
|
273 |
+
" 'vgg16_bn',\n",
|
274 |
+
" 'vgg19',\n",
|
275 |
+
" 'vgg19_bn',\n",
|
276 |
+
" 'video',\n",
|
277 |
+
" 'vision_transformer',\n",
|
278 |
+
" 'vit_b_16',\n",
|
279 |
+
" 'vit_b_32',\n",
|
280 |
+
" 'vit_h_14',\n",
|
281 |
+
" 'vit_l_16',\n",
|
282 |
+
" 'vit_l_32',\n",
|
283 |
+
" 'wide_resnet101_2',\n",
|
284 |
+
" 'wide_resnet50_2']"
|
285 |
+
]
|
286 |
+
},
|
287 |
+
"metadata": {},
|
288 |
+
"execution_count": 1
|
289 |
+
}
|
290 |
+
],
|
291 |
+
"source": [
|
292 |
+
"#Loading Pre-Trained Network using TorchVision\n",
|
293 |
+
"!pip install torchvision\n",
|
294 |
+
"from torchvision import models\n",
|
295 |
+
"import torch\n",
|
296 |
+
"\n",
|
297 |
+
"dir(models)"
|
298 |
+
]
|
299 |
+
},
|
300 |
+
{
|
301 |
+
"cell_type": "code",
|
302 |
+
"execution_count": null,
|
303 |
+
"metadata": {
|
304 |
+
"id": "48_BUp-Kfrn-",
|
305 |
+
"colab": {
|
306 |
+
"base_uri": "https://localhost:8080/"
|
307 |
+
},
|
308 |
+
"outputId": "8c759ed5-ead3-4490-e22b-39c9066aa86a"
|
309 |
+
},
|
310 |
+
"outputs": [
|
311 |
+
{
|
312 |
+
"output_type": "stream",
|
313 |
+
"name": "stderr",
|
314 |
+
"text": [
|
315 |
+
"/usr/local/lib/python3.10/dist-packages/torchvision/models/_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and may be removed in the future, please use 'weights' instead.\n",
|
316 |
+
" warnings.warn(\n",
|
317 |
+
"/usr/local/lib/python3.10/dist-packages/torchvision/models/_utils.py:223: UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing `weights=AlexNet_Weights.IMAGENET1K_V1`. You can also use `weights=AlexNet_Weights.DEFAULT` to get the most up-to-date weights.\n",
|
318 |
+
" warnings.warn(msg)\n",
|
319 |
+
"Downloading: \"https://download.pytorch.org/models/alexnet-owt-7be5be79.pth\" to /root/.cache/torch/hub/checkpoints/alexnet-owt-7be5be79.pth\n",
|
320 |
+
"100%|██████████| 233M/233M [00:01<00:00, 124MB/s]\n"
|
321 |
+
]
|
322 |
+
}
|
323 |
+
],
|
324 |
+
"source": [
|
325 |
+
"# Using AlexNet for Image Classification\n",
|
326 |
+
"# Load the pre-trained model\n",
|
327 |
+
"alexnet = models.alexnet(pretrained=True)"
|
328 |
+
]
|
329 |
+
},
|
330 |
+
{
|
331 |
+
"cell_type": "code",
|
332 |
+
"execution_count": null,
|
333 |
+
"metadata": {
|
334 |
+
"colab": {
|
335 |
+
"base_uri": "https://localhost:8080/"
|
336 |
+
},
|
337 |
+
"id": "M4Lkuk4lgDMJ",
|
338 |
+
"outputId": "190a9c05-9c27-46ec-fac4-602cc6dddce7"
|
339 |
+
},
|
340 |
+
"outputs": [
|
341 |
+
{
|
342 |
+
"output_type": "stream",
|
343 |
+
"name": "stdout",
|
344 |
+
"text": [
|
345 |
+
"AlexNet(\n",
|
346 |
+
" (features): Sequential(\n",
|
347 |
+
" (0): Conv2d(3, 64, kernel_size=(11, 11), stride=(4, 4), padding=(2, 2))\n",
|
348 |
+
" (1): ReLU(inplace=True)\n",
|
349 |
+
" (2): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)\n",
|
350 |
+
" (3): Conv2d(64, 192, kernel_size=(5, 5), stride=(1, 1), padding=(2, 2))\n",
|
351 |
+
" (4): ReLU(inplace=True)\n",
|
352 |
+
" (5): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)\n",
|
353 |
+
" (6): Conv2d(192, 384, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))\n",
|
354 |
+
" (7): ReLU(inplace=True)\n",
|
355 |
+
" (8): Conv2d(384, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))\n",
|
356 |
+
" (9): ReLU(inplace=True)\n",
|
357 |
+
" (10): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))\n",
|
358 |
+
" (11): ReLU(inplace=True)\n",
|
359 |
+
" (12): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)\n",
|
360 |
+
" )\n",
|
361 |
+
" (avgpool): AdaptiveAvgPool2d(output_size=(6, 6))\n",
|
362 |
+
" (classifier): Sequential(\n",
|
363 |
+
" (0): Dropout(p=0.5, inplace=False)\n",
|
364 |
+
" (1): Linear(in_features=9216, out_features=4096, bias=True)\n",
|
365 |
+
" (2): ReLU(inplace=True)\n",
|
366 |
+
" (3): Dropout(p=0.5, inplace=False)\n",
|
367 |
+
" (4): Linear(in_features=4096, out_features=4096, bias=True)\n",
|
368 |
+
" (5): ReLU(inplace=True)\n",
|
369 |
+
" (6): Linear(in_features=4096, out_features=1000, bias=True)\n",
|
370 |
+
" )\n",
|
371 |
+
")\n"
|
372 |
+
]
|
373 |
+
}
|
374 |
+
],
|
375 |
+
"source": [
|
376 |
+
"print(alexnet)"
|
377 |
+
]
|
378 |
+
},
|
379 |
+
{
|
380 |
+
"cell_type": "code",
|
381 |
+
"execution_count": null,
|
382 |
+
"metadata": {
|
383 |
+
"id": "BYGBAm4bgRrG"
|
384 |
+
},
|
385 |
+
"outputs": [],
|
386 |
+
"source": [
|
387 |
+
"#make sure that data transforms into the right shape\n",
|
388 |
+
"from torchvision import transforms\n",
|
389 |
+
"transform = transforms.Compose([\n",
|
390 |
+
" transforms.Resize(256),\n",
|
391 |
+
" transforms.CenterCrop(224),\n",
|
392 |
+
" transforms.ToTensor(),\n",
|
393 |
+
" transforms.Normalize(\n",
|
394 |
+
" mean=[0.485, 0.456, 0.406],\n",
|
395 |
+
" std=[0.229, 0.224, 0.225]\n",
|
396 |
+
" )])"
|
397 |
+
]
|
398 |
+
},
|
399 |
+
{
|
400 |
+
"cell_type": "code",
|
401 |
+
"execution_count": null,
|
402 |
+
"metadata": {
|
403 |
+
"colab": {
|
404 |
+
"base_uri": "https://localhost:8080/"
|
405 |
+
},
|
406 |
+
"id": "QjAr0XAw4y8S",
|
407 |
+
"outputId": "523c603e-f6e0-4ee5-a4c4-736f97e5975e"
|
408 |
+
},
|
409 |
+
"outputs": [
|
410 |
+
{
|
411 |
+
"output_type": "stream",
|
412 |
+
"name": "stdout",
|
413 |
+
"text": [
|
414 |
+
"Mounted at /content/gdrive\n"
|
415 |
+
]
|
416 |
+
}
|
417 |
+
],
|
418 |
+
"source": [
|
419 |
+
"#connect colab to google drive\n",
|
420 |
+
"from google.colab import drive\n",
|
421 |
+
"drive.mount('/content/gdrive')"
|
422 |
+
]
|
423 |
+
},
|
424 |
+
{
|
425 |
+
"cell_type": "code",
|
426 |
+
"execution_count": null,
|
427 |
+
"metadata": {
|
428 |
+
"colab": {
|
429 |
+
"base_uri": "https://localhost:8080/"
|
430 |
+
},
|
431 |
+
"id": "UrVD0SbACHrd",
|
432 |
+
"outputId": "4ef343c7-2bc2-4d34-ea31-d9c7a11ef3e3"
|
433 |
+
},
|
434 |
+
"outputs": [
|
435 |
+
{
|
436 |
+
"output_type": "stream",
|
437 |
+
"name": "stdout",
|
438 |
+
"text": [
|
439 |
+
"Collecting pixellib==0.5.2\n",
|
440 |
+
" Downloading pixellib-0.5.2-py3-none-any.whl (66 kB)\n",
|
441 |
+
"\u001b[?25l \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/66.9 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r\u001b[2K \u001b[91m━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[90m╺\u001b[0m\u001b[90m━━━━━━━━━━━━━━━\u001b[0m \u001b[32m41.0/66.9 kB\u001b[0m \u001b[31m1.1 MB/s\u001b[0m eta \u001b[36m0:00:01\u001b[0m\r\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m66.9/66.9 kB\u001b[0m \u001b[31m1.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
442 |
+
"\u001b[?25hRequirement already satisfied: pillow in /usr/local/lib/python3.10/dist-packages (from pixellib==0.5.2) (9.4.0)\n",
|
443 |
+
"Requirement already satisfied: scikit-image in /usr/local/lib/python3.10/dist-packages (from pixellib==0.5.2) (0.19.3)\n",
|
444 |
+
"Requirement already satisfied: opencv-python in /usr/local/lib/python3.10/dist-packages (from pixellib==0.5.2) (4.8.0.76)\n",
|
445 |
+
"Requirement already satisfied: matplotlib in /usr/local/lib/python3.10/dist-packages (from pixellib==0.5.2) (3.7.1)\n",
|
446 |
+
"Requirement already satisfied: imgaug in /usr/local/lib/python3.10/dist-packages (from pixellib==0.5.2) (0.4.0)\n",
|
447 |
+
"Collecting labelme2coco (from pixellib==0.5.2)\n",
|
448 |
+
" Downloading labelme2coco-0.2.6-py3-none-any.whl (19 kB)\n",
|
449 |
+
"Collecting imantics (from pixellib==0.5.2)\n",
|
450 |
+
" Downloading imantics-0.1.12.tar.gz (13 kB)\n",
|
451 |
+
" Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
|
452 |
+
"Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from imantics->pixellib==0.5.2) (1.25.2)\n",
|
453 |
+
"Requirement already satisfied: lxml in /usr/local/lib/python3.10/dist-packages (from imantics->pixellib==0.5.2) (4.9.4)\n",
|
454 |
+
"Collecting xmljson (from imantics->pixellib==0.5.2)\n",
|
455 |
+
" Downloading xmljson-0.2.1-py2.py3-none-any.whl (10 kB)\n",
|
456 |
+
"Requirement already satisfied: six in /usr/local/lib/python3.10/dist-packages (from imgaug->pixellib==0.5.2) (1.16.0)\n",
|
457 |
+
"Requirement already satisfied: scipy in /usr/local/lib/python3.10/dist-packages (from imgaug->pixellib==0.5.2) (1.11.4)\n",
|
458 |
+
"Requirement already satisfied: imageio in /usr/local/lib/python3.10/dist-packages (from imgaug->pixellib==0.5.2) (2.31.6)\n",
|
459 |
+
"Requirement already satisfied: Shapely in /usr/local/lib/python3.10/dist-packages (from imgaug->pixellib==0.5.2) (2.0.4)\n",
|
460 |
+
"Requirement already satisfied: networkx>=2.2 in /usr/local/lib/python3.10/dist-packages (from scikit-image->pixellib==0.5.2) (3.3)\n",
|
461 |
+
"Requirement already satisfied: tifffile>=2019.7.26 in /usr/local/lib/python3.10/dist-packages (from scikit-image->pixellib==0.5.2) (2024.5.22)\n",
|
462 |
+
"Requirement already satisfied: PyWavelets>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from scikit-image->pixellib==0.5.2) (1.6.0)\n",
|
463 |
+
"Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/dist-packages (from scikit-image->pixellib==0.5.2) (24.1)\n",
|
464 |
+
"Collecting sahi>=0.8.19 (from labelme2coco->pixellib==0.5.2)\n",
|
465 |
+
" Downloading sahi-0.11.16-py3-none-any.whl (112 kB)\n",
|
466 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m112.6/112.6 kB\u001b[0m \u001b[31m5.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
467 |
+
"\u001b[?25hRequirement already satisfied: jsonschema>=2.6.0 in /usr/local/lib/python3.10/dist-packages (from labelme2coco->pixellib==0.5.2) (4.19.2)\n",
|
468 |
+
"Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->pixellib==0.5.2) (1.2.1)\n",
|
469 |
+
"Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.10/dist-packages (from matplotlib->pixellib==0.5.2) (0.12.1)\n",
|
470 |
+
"Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib->pixellib==0.5.2) (4.53.0)\n",
|
471 |
+
"Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->pixellib==0.5.2) (1.4.5)\n",
|
472 |
+
"Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->pixellib==0.5.2) (3.1.2)\n",
|
473 |
+
"Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.10/dist-packages (from matplotlib->pixellib==0.5.2) (2.8.2)\n",
|
474 |
+
"Requirement already satisfied: attrs>=22.2.0 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=2.6.0->labelme2coco->pixellib==0.5.2) (23.2.0)\n",
|
475 |
+
"Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=2.6.0->labelme2coco->pixellib==0.5.2) (2023.12.1)\n",
|
476 |
+
"Requirement already satisfied: referencing>=0.28.4 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=2.6.0->labelme2coco->pixellib==0.5.2) (0.35.1)\n",
|
477 |
+
"Requirement already satisfied: rpds-py>=0.7.1 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=2.6.0->labelme2coco->pixellib==0.5.2) (0.18.1)\n",
|
478 |
+
"Requirement already satisfied: tqdm>=4.48.2 in /usr/local/lib/python3.10/dist-packages (from sahi>=0.8.19->labelme2coco->pixellib==0.5.2) (4.66.4)\n",
|
479 |
+
"Collecting pybboxes==0.1.6 (from sahi>=0.8.19->labelme2coco->pixellib==0.5.2)\n",
|
480 |
+
" Downloading pybboxes-0.1.6-py3-none-any.whl (24 kB)\n",
|
481 |
+
"Requirement already satisfied: pyyaml in /usr/local/lib/python3.10/dist-packages (from sahi>=0.8.19->labelme2coco->pixellib==0.5.2) (6.0.1)\n",
|
482 |
+
"Collecting fire (from sahi>=0.8.19->labelme2coco->pixellib==0.5.2)\n",
|
483 |
+
" Downloading fire-0.6.0.tar.gz (88 kB)\n",
|
484 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m88.4/88.4 kB\u001b[0m \u001b[31m8.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
485 |
+
"\u001b[?25h Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
|
486 |
+
"Collecting terminaltables (from sahi>=0.8.19->labelme2coco->pixellib==0.5.2)\n",
|
487 |
+
" Downloading terminaltables-3.1.10-py2.py3-none-any.whl (15 kB)\n",
|
488 |
+
"Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from sahi>=0.8.19->labelme2coco->pixellib==0.5.2) (2.31.0)\n",
|
489 |
+
"Requirement already satisfied: click in /usr/local/lib/python3.10/dist-packages (from sahi>=0.8.19->labelme2coco->pixellib==0.5.2) (8.1.7)\n",
|
490 |
+
"Requirement already satisfied: termcolor in /usr/local/lib/python3.10/dist-packages (from fire->sahi>=0.8.19->labelme2coco->pixellib==0.5.2) (2.4.0)\n",
|
491 |
+
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->sahi>=0.8.19->labelme2coco->pixellib==0.5.2) (3.3.2)\n",
|
492 |
+
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->sahi>=0.8.19->labelme2coco->pixellib==0.5.2) (3.7)\n",
|
493 |
+
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->sahi>=0.8.19->labelme2coco->pixellib==0.5.2) (2.0.7)\n",
|
494 |
+
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->sahi>=0.8.19->labelme2coco->pixellib==0.5.2) (2024.6.2)\n",
|
495 |
+
"Building wheels for collected packages: imantics, fire\n",
|
496 |
+
" Building wheel for imantics (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
|
497 |
+
" Created wheel for imantics: filename=imantics-0.1.12-py3-none-any.whl size=16010 sha256=7d817e9d50811bc57f5430a56a85b68bdd80eb6c1bf29c0162c164ea5437ecc8\n",
|
498 |
+
" Stored in directory: /root/.cache/pip/wheels/56/6a/be/4c60e88b14abec4e93234a1f7f91ce8abe1ae88a2b3eaad3ac\n",
|
499 |
+
" Building wheel for fire (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
|
500 |
+
" Created wheel for fire: filename=fire-0.6.0-py2.py3-none-any.whl size=117029 sha256=7d054fa215963197dcfe0f04d1643078abd6b3849d6506532cce27e2499d896d\n",
|
501 |
+
" Stored in directory: /root/.cache/pip/wheels/d6/6d/5d/5b73fa0f46d01a793713f8859201361e9e581ced8c75e5c6a3\n",
|
502 |
+
"Successfully built imantics fire\n",
|
503 |
+
"Installing collected packages: xmljson, terminaltables, pybboxes, fire, sahi, imantics, labelme2coco, pixellib\n",
|
504 |
+
"Successfully installed fire-0.6.0 imantics-0.1.12 labelme2coco-0.2.6 pixellib-0.5.2 pybboxes-0.1.6 sahi-0.11.16 terminaltables-3.1.10 xmljson-0.2.1\n",
|
505 |
+
"Collecting labelme2coco==0.1.0\n",
|
506 |
+
" Downloading labelme2coco-0.1.0-py3-none-any.whl (19 kB)\n",
|
507 |
+
"Requirement already satisfied: numpy>=1.15.1 in /usr/local/lib/python3.10/dist-packages (from labelme2coco==0.1.0) (1.25.2)\n",
|
508 |
+
"Requirement already satisfied: pillow>=4.3.0 in /usr/local/lib/python3.10/dist-packages (from labelme2coco==0.1.0) (9.4.0)\n",
|
509 |
+
"Requirement already satisfied: jsonschema>=2.6.0 in /usr/local/lib/python3.10/dist-packages (from labelme2coco==0.1.0) (4.19.2)\n",
|
510 |
+
"Requirement already satisfied: attrs>=22.2.0 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=2.6.0->labelme2coco==0.1.0) (23.2.0)\n",
|
511 |
+
"Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=2.6.0->labelme2coco==0.1.0) (2023.12.1)\n",
|
512 |
+
"Requirement already satisfied: referencing>=0.28.4 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=2.6.0->labelme2coco==0.1.0) (0.35.1)\n",
|
513 |
+
"Requirement already satisfied: rpds-py>=0.7.1 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=2.6.0->labelme2coco==0.1.0) (0.18.1)\n",
|
514 |
+
"Installing collected packages: labelme2coco\n",
|
515 |
+
" Attempting uninstall: labelme2coco\n",
|
516 |
+
" Found existing installation: labelme2coco 0.2.6\n",
|
517 |
+
" Uninstalling labelme2coco-0.2.6:\n",
|
518 |
+
" Successfully uninstalled labelme2coco-0.2.6\n",
|
519 |
+
"Successfully installed labelme2coco-0.1.0\n"
|
520 |
+
]
|
521 |
+
}
|
522 |
+
],
|
523 |
+
"source": [
|
524 |
+
"!pip install pixellib==0.5.2\n",
|
525 |
+
"!pip install labelme2coco==0.1.0"
|
526 |
+
]
|
527 |
+
},
|
528 |
+
{
|
529 |
+
"cell_type": "code",
|
530 |
+
"execution_count": null,
|
531 |
+
"metadata": {
|
532 |
+
"id": "LM8K9V9VEpeb"
|
533 |
+
},
|
534 |
+
"outputs": [],
|
535 |
+
"source": [
|
536 |
+
"# Import necessary libraries\n",
|
537 |
+
"import os\n",
|
538 |
+
"from PIL import Image\n",
|
539 |
+
"\n",
|
540 |
+
"# Initialize an empty list to store image information\n",
|
541 |
+
"info = []\n",
|
542 |
+
"# Define the path to the main folder containing the images\n",
|
543 |
+
"main_folder_path = \"/content/gdrive/MyDrive/Orchid-Flowers-Dataset-v1.1/img\"\n",
|
544 |
+
"# Walk through the directory structure starting from the main folder\n",
|
545 |
+
"for root, _, files in os.walk(main_folder_path):\n",
|
546 |
+
" # Iterate over each file in the current directory\n",
|
547 |
+
" for file in files:\n",
|
548 |
+
" # Check if the file is a JPEG image\n",
|
549 |
+
" if file.endswith(\".jpg\"):\n",
|
550 |
+
" # Construct the full path to the image file\n",
|
551 |
+
" img_path = os.path.join(root, file)\n",
|
552 |
+
" # Open the image using PIL\n",
|
553 |
+
" img = Image.open(img_path)\n",
|
554 |
+
" # Append a dictionary containing the image object and its path to the info list\n",
|
555 |
+
" info.append({\"img\": img, \"path\": img_path})\n"
|
556 |
+
]
|
557 |
+
},
|
558 |
+
{
|
559 |
+
"cell_type": "code",
|
560 |
+
"execution_count": null,
|
561 |
+
"metadata": {
|
562 |
+
"id": "cAJhT7DhhOb2"
|
563 |
+
},
|
564 |
+
"outputs": [],
|
565 |
+
"source": [
|
566 |
+
"#preprocess\n",
|
567 |
+
"## prepares the image 'img' according to the requirements of the model\n",
|
568 |
+
"img_t = transform(img)\n",
|
569 |
+
"batch_t = torch.unsqueeze(img_t, 0)"
|
570 |
+
]
|
571 |
+
},
|
572 |
+
{
|
573 |
+
"cell_type": "code",
|
574 |
+
"execution_count": null,
|
575 |
+
"metadata": {
|
576 |
+
"colab": {
|
577 |
+
"base_uri": "https://localhost:8080/"
|
578 |
+
},
|
579 |
+
"id": "_4pQvaLEhVGG",
|
580 |
+
"outputId": "f04abab6-dca9-456a-f81c-6a6a2b2574df"
|
581 |
+
},
|
582 |
+
"outputs": [
|
583 |
+
{
|
584 |
+
"output_type": "stream",
|
585 |
+
"name": "stdout",
|
586 |
+
"text": [
|
587 |
+
"torch.Size([1, 1000])\n"
|
588 |
+
]
|
589 |
+
}
|
590 |
+
],
|
591 |
+
"source": [
|
592 |
+
"#Model Inference\n",
|
593 |
+
"#put our model in eval mode.\n",
|
594 |
+
"alexnet.eval()\n",
|
595 |
+
"\n",
|
596 |
+
"out = alexnet(batch_t)\n",
|
597 |
+
"print(out.shape)"
|
598 |
+
]
|
599 |
+
},
|
600 |
+
{
|
601 |
+
"cell_type": "code",
|
602 |
+
"execution_count": null,
|
603 |
+
"metadata": {
|
604 |
+
"id": "6vwXgG-Khp4g"
|
605 |
+
},
|
606 |
+
"outputs": [],
|
607 |
+
"source": [
|
608 |
+
"#get images class\n",
|
609 |
+
"with open('/content/gdrive/MyDrive/Orchid-Flowers-Dataset-v1.1/Multi-label Classification/Multilabel_training.csv') as f:\n",
|
610 |
+
" classes = [line.strip() for line in f.readlines()]"
|
611 |
+
]
|
612 |
+
},
|
613 |
+
{
|
614 |
+
"cell_type": "code",
|
615 |
+
"execution_count": null,
|
616 |
+
"metadata": {
|
617 |
+
"colab": {
|
618 |
+
"base_uri": "https://localhost:8080/"
|
619 |
+
},
|
620 |
+
"id": "oRLrd5igi72e",
|
621 |
+
"outputId": "2c9eb2b8-0e34-4fe1-d201-db8e889202ee"
|
622 |
+
},
|
623 |
+
"outputs": [
|
624 |
+
{
|
625 |
+
"output_type": "stream",
|
626 |
+
"name": "stdout",
|
627 |
+
"text": [
|
628 |
+
"1328.jpg;Spot;Lobed;Raceme;AFew;White;YellowBrown;24 15.88855266571045\n"
|
629 |
+
]
|
630 |
+
}
|
631 |
+
],
|
632 |
+
"source": [
|
633 |
+
"#find out the max prediction.\n",
|
634 |
+
"_, index = torch.max(out, 1)\n",
|
635 |
+
"\n",
|
636 |
+
"percentage = torch.nn.functional.softmax(out, dim=1)[0] * 100\n",
|
637 |
+
"\n",
|
638 |
+
"print(classes[index[0]], percentage[index[0]].item())\n"
|
639 |
+
]
|
640 |
+
},
|
641 |
+
{
|
642 |
+
"cell_type": "code",
|
643 |
+
"execution_count": null,
|
644 |
+
"metadata": {
|
645 |
+
"colab": {
|
646 |
+
"base_uri": "https://localhost:8080/"
|
647 |
+
},
|
648 |
+
"id": "UVpTbwpLjk1u",
|
649 |
+
"outputId": "eb37e1df-4673-47b0-fff1-f841c3c82525"
|
650 |
+
},
|
651 |
+
"outputs": [
|
652 |
+
{
|
653 |
+
"output_type": "execute_result",
|
654 |
+
"data": {
|
655 |
+
"text/plain": [
|
656 |
+
"[('1328.jpg;Spot;Lobed;Raceme;AFew;White;YellowBrown;24', 15.88855266571045),\n",
|
657 |
+
" ('59.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
658 |
+
" 13.1360502243042),\n",
|
659 |
+
" ('1253.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 12.89087963104248),\n",
|
660 |
+
" ('1292.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 8.40053653717041),\n",
|
661 |
+
" ('381.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 7.234877586364746),\n",
|
662 |
+
" ('366.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 2.4095914363861084),\n",
|
663 |
+
" ('367.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 1.6216557025909424),\n",
|
664 |
+
" ('61.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
665 |
+
" 1.5760637521743774),\n",
|
666 |
+
" ('1336.jpg;Spot;Lobed;Raceme;AFew;White;YellowBrown;24', 1.5720475912094116),\n",
|
667 |
+
" ('21.jpg;Spot;Lobed;Raceme;AFew;PinkRedWhite;White;1', 1.1183711290359497),\n",
|
668 |
+
" ('379.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 1.050938606262207),\n",
|
669 |
+
" ('60.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
670 |
+
" 0.8608635663986206),\n",
|
671 |
+
" ('358.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.819441020488739),\n",
|
672 |
+
" ('19.jpg;Spot;Lobed;Raceme;AFew;PinkRedWhite;White;1', 0.7847009301185608),\n",
|
673 |
+
" ('81.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
674 |
+
" 0.7471103072166443),\n",
|
675 |
+
" ('1260.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.7245150804519653),\n",
|
676 |
+
" ('770.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.7173356413841248),\n",
|
677 |
+
" ('157.jpg;Nospot;Lobed;Raceme;Many;BluePurple;Pink;5', 0.6922218203544617),\n",
|
678 |
+
" ('172.jpg;Nospot;Lobed;Raceme;AFew;BluePurple;Purple;7', 0.6557213068008423),\n",
|
679 |
+
" ('136.jpg;Nospot;Lobed;Raceme;AFew;BluePurple;Pink;4', 0.6397452354431152),\n",
|
680 |
+
" ('382.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.6052159070968628),\n",
|
681 |
+
" ('95.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
682 |
+
" 0.5833677649497986),\n",
|
683 |
+
" ('668.jpg;Nospot;Lobed;Spike;AFew;White;White;13', 0.5295686721801758),\n",
|
684 |
+
" ('76.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
685 |
+
" 0.5227769017219543),\n",
|
686 |
+
" ('140.jpg;Nospot;Lobed;Raceme;Many;BluePurple;Pink;5', 0.5217817425727844),\n",
|
687 |
+
" ('380.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.4721907079219818),\n",
|
688 |
+
" ('656.jpg;Nospot;Lobed;Spike;AFew;White;White;13', 0.45688581466674805),\n",
|
689 |
+
" ('370.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.4555966258049011),\n",
|
690 |
+
" ('374.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.44236528873443604),\n",
|
691 |
+
" ('378.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.44061797857284546),\n",
|
692 |
+
" ('543.jpg;Spot;Pouched;SingleOrPair;SinglePair;PinkRedWhite;Pink;12',\n",
|
693 |
+
" 0.38045161962509155),\n",
|
694 |
+
" ('497.jpg;Spot;Pouched;SingleOrPair;SinglePair;PinkRedWhite;Pink;12',\n",
|
695 |
+
" 0.379602313041687),\n",
|
696 |
+
" ('1254.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.3571322560310364),\n",
|
697 |
+
" ('1092.jpg;Nospot;Simple;Raceme;Many;PinkRed;YellowPurple;22',\n",
|
698 |
+
" 0.3147432208061218),\n",
|
699 |
+
" ('368.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.3100665211677551),\n",
|
700 |
+
" ('6.jpg;Spot;Lobed;Raceme;AFew;PinkRedWhite;White;1', 0.2809280753135681),\n",
|
701 |
+
" ('167.jpg;Spot;Lobed;Raceme;AFew;Green;GreenBrown;6', 0.27919310331344604),\n",
|
702 |
+
" ('1295.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.2738247513771057),\n",
|
703 |
+
" ('66.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
704 |
+
" 0.2725987136363983),\n",
|
705 |
+
" ('418.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.26582586765289307),\n",
|
706 |
+
" ('1278.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.26240798830986023),\n",
|
707 |
+
" ('166.jpg;Spot;Lobed;Raceme;AFew;Green;GreenBrown;6', 0.2560056149959564),\n",
|
708 |
+
" ('72.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
709 |
+
" 0.25269821286201477),\n",
|
710 |
+
" ('3.jpg;Spot;Lobed;Raceme;AFew;PinkRedWhite;White;1', 0.23681098222732544),\n",
|
711 |
+
" ('1291.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.22926069796085358),\n",
|
712 |
+
" ('2.jpg;Spot;Lobed;Raceme;AFew;PinkRedWhite;White;1', 0.2286931574344635),\n",
|
713 |
+
" ('383.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.22630411386489868),\n",
|
714 |
+
" ('1332.jpg;Spot;Lobed;Raceme;AFew;White;YellowBrown;24', 0.2254563570022583),\n",
|
715 |
+
" ('1330.jpg;Spot;Lobed;Raceme;AFew;White;YellowBrown;24', 0.21111786365509033),\n",
|
716 |
+
" ('52.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
717 |
+
" 0.2055903971195221),\n",
|
718 |
+
" ('152.jpg;Nospot;Lobed;Raceme;Many;BluePurple;Pink;5', 0.20558702945709229),\n",
|
719 |
+
" ('879.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.20312798023223877),\n",
|
720 |
+
" ('356.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.20167100429534912),\n",
|
721 |
+
" ('8.jpg;Spot;Lobed;Raceme;AFew;PinkRedWhite;White;1', 0.19924338161945343),\n",
|
722 |
+
" ('24.jpg;Spot;Lobed;Raceme;AFew;PinkRedWhite;White;1', 0.19896815717220306),\n",
|
723 |
+
" ('110.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
724 |
+
" 0.19074273109436035),\n",
|
725 |
+
" ('45.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
726 |
+
" 0.18984097242355347),\n",
|
727 |
+
" ('1333.jpg;Spot;Lobed;Raceme;AFew;White;YellowBrown;24', 0.1873064637184143),\n",
|
728 |
+
" ('7.jpg;Spot;Lobed;Raceme;AFew;PinkRedWhite;White;1', 0.18209609389305115),\n",
|
729 |
+
" ('361.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.17600329220294952),\n",
|
730 |
+
" ('364.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.16741099953651428),\n",
|
731 |
+
" ('365.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.16448485851287842),\n",
|
732 |
+
" ('20.jpg;Spot;Lobed;Raceme;AFew;PinkRedWhite;White;1', 0.16104918718338013),\n",
|
733 |
+
" ('79.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
734 |
+
" 0.1599152684211731),\n",
|
735 |
+
" ('1250.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.15917754173278809),\n",
|
736 |
+
" ('602.jpg;Spot;Pouched;SingleOrPair;SinglePair;PinkRedWhite;Pink;12',\n",
|
737 |
+
" 0.15614819526672363),\n",
|
738 |
+
" ('1251.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.1506175547838211),\n",
|
739 |
+
" ('154.jpg;Nospot;Lobed;Raceme;Many;BluePurple;Pink;5', 0.1481093168258667),\n",
|
740 |
+
" ('153.jpg;Nospot;Lobed;Raceme;Many;BluePurple;Pink;5', 0.1388826221227646),\n",
|
741 |
+
" ('156.jpg;Nospot;Lobed;Raceme;Many;BluePurple;Pink;5', 0.1335545927286148),\n",
|
742 |
+
" ('57.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
743 |
+
" 0.1283245086669922),\n",
|
744 |
+
" ('4.jpg;Spot;Lobed;Raceme;AFew;PinkRedWhite;White;1', 0.12153234332799911),\n",
|
745 |
+
" ('1294.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.12126421928405762),\n",
|
746 |
+
" ('360.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.11958467215299606),\n",
|
747 |
+
" ('149.jpg;Nospot;Lobed;Raceme;Many;BluePurple;Pink;5', 0.11674829572439194),\n",
|
748 |
+
" ('77.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
749 |
+
" 0.11610187590122223),\n",
|
750 |
+
" ('44.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
751 |
+
" 0.11539264768362045),\n",
|
752 |
+
" ('375.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.1144905537366867),\n",
|
753 |
+
" ('16.jpg;Spot;Lobed;Raceme;AFew;PinkRedWhite;White;1', 0.1133173331618309),\n",
|
754 |
+
" ('31.jpg;Spot;Lobed;Raceme;AFew;White;GreenBrown;2', 0.11253408342599869),\n",
|
755 |
+
" ('934.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.11123257130384445),\n",
|
756 |
+
" ('377.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.1095474436879158),\n",
|
757 |
+
" ('345.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.10801921784877777),\n",
|
758 |
+
" ('71.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
759 |
+
" 0.10731980204582214),\n",
|
760 |
+
" ('1329.jpg;Spot;Lobed;Raceme;AFew;White;YellowBrown;24', 0.1048896461725235),\n",
|
761 |
+
" ('347.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.1000528559088707),\n",
|
762 |
+
" ('415.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.10003134608268738),\n",
|
763 |
+
" ('393.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.09839722514152527),\n",
|
764 |
+
" ('67.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
765 |
+
" 0.09760170429944992),\n",
|
766 |
+
" ('372.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.09713171422481537),\n",
|
767 |
+
" ('9.jpg;Spot;Lobed;Raceme;AFew;PinkRedWhite;White;1', 0.09567029029130936),\n",
|
768 |
+
" ('1129.jpg;Nospot;Simple;Raceme;Many;PinkRed;YellowPurple;22',\n",
|
769 |
+
" 0.09349559247493744),\n",
|
770 |
+
" ('29.jpg;Spot;Lobed;Raceme;AFew;White;GreenBrown;2', 0.0917716920375824),\n",
|
771 |
+
" ('43.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
772 |
+
" 0.09113944321870804),\n",
|
773 |
+
" ('151.jpg;Nospot;Lobed;Raceme;Many;BluePurple;Pink;5', 0.09085232764482498),\n",
|
774 |
+
" ('68.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
775 |
+
" 0.08954086899757385),\n",
|
776 |
+
" ('1205.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.08864416182041168),\n",
|
777 |
+
" ('397.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.08842142671346664),\n",
|
778 |
+
" ('335.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.08576169610023499),\n",
|
779 |
+
" ('419.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.08285453915596008),\n",
|
780 |
+
" ('75.jpg;Spot;Simple;SingleOrPair;SinglePair;White;White;3',\n",
|
781 |
+
" 0.08281706273555756),\n",
|
782 |
+
" ('394.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.0826164186000824),\n",
|
783 |
+
" ('388.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.0812898576259613),\n",
|
784 |
+
" ('117.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
785 |
+
" 0.08076874911785126),\n",
|
786 |
+
" ('764.jpg;Nospot;Lobed;Raceme;AFew;Yellow;Yellow;18', 0.08051265776157379),\n",
|
787 |
+
" ('357.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.07831750810146332),\n",
|
788 |
+
" ('1262.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.07743849605321884),\n",
|
789 |
+
" ('376.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.0759877860546112),\n",
|
790 |
+
" ('158.jpg;Nospot;Lobed;Raceme;Many;BluePurple;Pink;5', 0.07545885443687439),\n",
|
791 |
+
" ('344.jpg;Nospot;Lobed;Raceme;AFew;White;White;11', 0.07462375611066818),\n",
|
792 |
+
" ('385.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.07386453449726105),\n",
|
793 |
+
" ('103.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
794 |
+
" 0.07346448302268982),\n",
|
795 |
+
" ('812.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.07209622859954834),\n",
|
796 |
+
" ('1149.jpg;Nospot;Simple;Raceme;Many;PinkRed;YellowPurple;22',\n",
|
797 |
+
" 0.07033940404653549),\n",
|
798 |
+
" ('423.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.07011250406503677),\n",
|
799 |
+
" ('369.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.06953710317611694),\n",
|
800 |
+
" ('28.jpg;Spot;Lobed;Raceme;AFew;White;GreenBrown;2', 0.06891264021396637),\n",
|
801 |
+
" ('226.jpg;Nospot;Lobed;Raceme;AFew;BluePurple;Purple;9', 0.06838587671518326),\n",
|
802 |
+
" ('776.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.06826956570148468),\n",
|
803 |
+
" ('334.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.06826279312372208),\n",
|
804 |
+
" ('69.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
805 |
+
" 0.06743894517421722),\n",
|
806 |
+
" ('818.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.06660064309835434),\n",
|
807 |
+
" ('488.jpg;Spot;Pouched;SingleOrPair;SinglePair;PinkRedWhite;Pink;12',\n",
|
808 |
+
" 0.06591498851776123),\n",
|
809 |
+
" ('177.jpg;Nospot;Lobed;Raceme;AFew;BluePurple;Purple;7', 0.06477275490760803),\n",
|
810 |
+
" ('674.jpg;Nospot;Lobed;Spike;AFew;White;White;13', 0.06421098113059998),\n",
|
811 |
+
" ('603.jpg;Spot;Pouched;SingleOrPair;SinglePair;PinkRedWhite;Pink;12',\n",
|
812 |
+
" 0.06350540369749069),\n",
|
813 |
+
" ('697.jpg;Nospot;Lobed;SingleOrPair;SinglePair;PinkRed;White;15',\n",
|
814 |
+
" 0.06278358399868011),\n",
|
815 |
+
" ('175.jpg;Nospot;Lobed;Raceme;AFew;BluePurple;Purple;7', 0.06274962425231934),\n",
|
816 |
+
" ('1265.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.06253521144390106),\n",
|
817 |
+
" ('328.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.06139958277344704),\n",
|
818 |
+
" ('1160.jpg;Nospot;Simple;Raceme;Many;PinkRed;YellowPurple;22',\n",
|
819 |
+
" 0.061397090554237366),\n",
|
820 |
+
" ('350.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.058440323919057846),\n",
|
821 |
+
" ('230.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;10', 0.057940512895584106),\n",
|
822 |
+
" ('5.jpg;Spot;Lobed;Raceme;AFew;PinkRedWhite;White;1', 0.057657621800899506),\n",
|
823 |
+
" ('171.jpg;Nospot;Lobed;Raceme;AFew;BluePurple;Purple;7', 0.057468231767416),\n",
|
824 |
+
" ('498.jpg;Spot;Pouched;SingleOrPair;SinglePair;PinkRedWhite;Pink;12',\n",
|
825 |
+
" 0.05653461068868637),\n",
|
826 |
+
" ('1002.jpg;Spot;Lobed;Raceme;Many;White;YellowPurple;20',\n",
|
827 |
+
" 0.05630265921354294),\n",
|
828 |
+
" ('482.jpg;Spot;Pouched;SingleOrPair;SinglePair;PinkRedWhite;Pink;12',\n",
|
829 |
+
" 0.056098878383636475),\n",
|
830 |
+
" ('168.jpg;Spot;Lobed;Raceme;AFew;Green;GreenBrown;6', 0.05599924549460411),\n",
|
831 |
+
" ('391.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.053999386727809906),\n",
|
832 |
+
" ('264.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.05180278792977333),\n",
|
833 |
+
" ('1244.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.05118359625339508),\n",
|
834 |
+
" ('78.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
835 |
+
" 0.05117344483733177),\n",
|
836 |
+
" ('1075.jpg;Spot;Simple;Raceme;AFew;White;GreenBrown;21',\n",
|
837 |
+
" 0.050270598381757736),\n",
|
838 |
+
" ('1282.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.050155527889728546),\n",
|
839 |
+
" ('413.jpg;Nospot;Lobed;Raceme;AFew;White;White;11', 0.049014657735824585),\n",
|
840 |
+
" ('17.jpg;Spot;Lobed;Raceme;AFew;PinkRedWhite;White;1', 0.0488186813890934),\n",
|
841 |
+
" ('64.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
842 |
+
" 0.04768126830458641),\n",
|
843 |
+
" ('90.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
844 |
+
" 0.04746171087026596),\n",
|
845 |
+
" ('412.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.04722648113965988),\n",
|
846 |
+
" ('1095.jpg;Nospot;Simple;Raceme;Many;PinkRed;YellowPurple;22',\n",
|
847 |
+
" 0.046545252203941345),\n",
|
848 |
+
" ('1256.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.04631029814481735),\n",
|
849 |
+
" ('262.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.04623924568295479),\n",
|
850 |
+
" ('174.jpg;Nospot;Lobed;Raceme;AFew;BluePurple;Purple;7',\n",
|
851 |
+
" 0.046176716685295105),\n",
|
852 |
+
" ('240.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;White;10', 0.045038942247629166),\n",
|
853 |
+
" ('286.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.044957708567380905)]"
|
854 |
+
]
|
855 |
+
},
|
856 |
+
"metadata": {},
|
857 |
+
"execution_count": 14
|
858 |
+
}
|
859 |
+
],
|
860 |
+
"source": [
|
861 |
+
"#sorts the output tensor out in descending order to identify the classes ranked by their predicted probabilities\n",
|
862 |
+
"_, indices = torch.sort(out, descending=True)\n",
|
863 |
+
"[(classes[idx], percentage[idx].item()) for idx in indices[0][:156]]"
|
864 |
+
]
|
865 |
+
},
|
866 |
+
{
|
867 |
+
"cell_type": "code",
|
868 |
+
"execution_count": null,
|
869 |
+
"metadata": {
|
870 |
+
"colab": {
|
871 |
+
"base_uri": "https://localhost:8080/"
|
872 |
+
},
|
873 |
+
"id": "eCB_8WaAlH81",
|
874 |
+
"outputId": "5b1892c4-c998-4d56-9858-774a0af872d3"
|
875 |
+
},
|
876 |
+
"outputs": [
|
877 |
+
{
|
878 |
+
"output_type": "stream",
|
879 |
+
"name": "stderr",
|
880 |
+
"text": [
|
881 |
+
"/usr/local/lib/python3.10/dist-packages/torchvision/models/_utils.py:223: UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing `weights=ResNet101_Weights.IMAGENET1K_V1`. You can also use `weights=ResNet101_Weights.DEFAULT` to get the most up-to-date weights.\n",
|
882 |
+
" warnings.warn(msg)\n",
|
883 |
+
"Downloading: \"https://download.pytorch.org/models/resnet101-63fe2227.pth\" to /root/.cache/torch/hub/checkpoints/resnet101-63fe2227.pth\n",
|
884 |
+
"100%|██████████| 171M/171M [00:01<00:00, 150MB/s]\n"
|
885 |
+
]
|
886 |
+
},
|
887 |
+
{
|
888 |
+
"output_type": "execute_result",
|
889 |
+
"data": {
|
890 |
+
"text/plain": [
|
891 |
+
"[('668.jpg;Nospot;Lobed;Spike;AFew;White;White;13', 22.527023315429688),\n",
|
892 |
+
" ('366.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 12.090964317321777),\n",
|
893 |
+
" ('358.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 8.455033302307129),\n",
|
894 |
+
" ('379.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 6.997452735900879),\n",
|
895 |
+
" ('1292.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 6.838258266448975),\n",
|
896 |
+
" ('381.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 5.595933437347412),\n",
|
897 |
+
" ('1253.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 3.821831226348877),\n",
|
898 |
+
" ('382.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 3.7380588054656982),\n",
|
899 |
+
" ('1336.jpg;Spot;Lobed;Raceme;AFew;White;YellowBrown;24', 3.2465667724609375),\n",
|
900 |
+
" ('374.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 3.2281291484832764),\n",
|
901 |
+
" ('361.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 2.2762434482574463),\n",
|
902 |
+
" ('367.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 1.5874812602996826),\n",
|
903 |
+
" ('375.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 1.492242455482483),\n",
|
904 |
+
" ('1328.jpg;Spot;Lobed;Raceme;AFew;White;YellowBrown;24', 1.4696153402328491),\n",
|
905 |
+
" ('19.jpg;Spot;Lobed;Raceme;AFew;PinkRedWhite;White;1', 1.4305696487426758),\n",
|
906 |
+
" ('378.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 1.3636442422866821),\n",
|
907 |
+
" ('1291.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 1.036311149597168),\n",
|
908 |
+
" ('368.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.9036271572113037),\n",
|
909 |
+
" ('380.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.765997588634491),\n",
|
910 |
+
" ('1251.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.7222974300384521),\n",
|
911 |
+
" ('369.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.5622342824935913),\n",
|
912 |
+
" ('364.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.4975619614124298),\n",
|
913 |
+
" ('365.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.3840673565864563),\n",
|
914 |
+
" ('372.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.36875268816947937),\n",
|
915 |
+
" ('1296.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.35623791813850403),\n",
|
916 |
+
" ('377.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.3242622911930084),\n",
|
917 |
+
" ('81.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
918 |
+
" 0.30271732807159424),\n",
|
919 |
+
" ('59.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
920 |
+
" 0.2965044677257538),\n",
|
921 |
+
" ('1036.jpg;Spot;Lobed;Raceme;Many;White;YellowPurple;20',\n",
|
922 |
+
" 0.26680225133895874),\n",
|
923 |
+
" ('136.jpg;Nospot;Lobed;Raceme;AFew;BluePurple;Pink;4', 0.26057183742523193),\n",
|
924 |
+
" ('383.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.25701603293418884),\n",
|
925 |
+
" ('104.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
926 |
+
" 0.24599002301692963),\n",
|
927 |
+
" ('1293.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.2180352807044983),\n",
|
928 |
+
" ('21.jpg;Spot;Lobed;Raceme;AFew;PinkRedWhite;White;1', 0.2138841599225998),\n",
|
929 |
+
" ('1294.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.19859229028224945),\n",
|
930 |
+
" ('841.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.19179081916809082),\n",
|
931 |
+
" ('360.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.19158487021923065),\n",
|
932 |
+
" ('376.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.17068561911582947),\n",
|
933 |
+
" ('842.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.16562320291996002),\n",
|
934 |
+
" ('110.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
935 |
+
" 0.13881315290927887),\n",
|
936 |
+
" ('61.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
937 |
+
" 0.13485118746757507),\n",
|
938 |
+
" ('776.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.13175946474075317),\n",
|
939 |
+
" ('603.jpg;Spot;Pouched;SingleOrPair;SinglePair;PinkRedWhite;Pink;12',\n",
|
940 |
+
" 0.12991517782211304),\n",
|
941 |
+
" ('60.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
942 |
+
" 0.10134583711624146),\n",
|
943 |
+
" ('1333.jpg;Spot;Lobed;Raceme;AFew;White;YellowBrown;24', 0.08948017656803131),\n",
|
944 |
+
" ('111.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
945 |
+
" 0.08913480490446091),\n",
|
946 |
+
" ('1295.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.08839907497167587),\n",
|
947 |
+
" ('166.jpg;Spot;Lobed;Raceme;AFew;Green;GreenBrown;6', 0.08462517708539963),\n",
|
948 |
+
" ('929.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.07931681722402573),\n",
|
949 |
+
" ('912.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.0747298002243042),\n",
|
950 |
+
" ('812.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.0725923553109169),\n",
|
951 |
+
" ('562.jpg;Spot;Pouched;SingleOrPair;SinglePair;PinkRedWhite;Pink;12',\n",
|
952 |
+
" 0.07209319621324539),\n",
|
953 |
+
" ('1265.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.07104596495628357),\n",
|
954 |
+
" ('1025.jpg;Spot;Lobed;Raceme;Many;White;YellowPurple;20', 0.0684821680188179),\n",
|
955 |
+
" ('934.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.06393922865390778),\n",
|
956 |
+
" ('543.jpg;Spot;Pouched;SingleOrPair;SinglePair;PinkRedWhite;Pink;12',\n",
|
957 |
+
" 0.06310241669416428),\n",
|
958 |
+
" ('65.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
959 |
+
" 0.061234522610902786),\n",
|
960 |
+
" ('873.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.060004059225320816),\n",
|
961 |
+
" ('656.jpg;Nospot;Lobed;Spike;AFew;White;White;13', 0.05944221466779709),\n",
|
962 |
+
" ('152.jpg;Nospot;Lobed;Raceme;Many;BluePurple;Pink;5', 0.056256651878356934),\n",
|
963 |
+
" ('370.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.05544749274849892),\n",
|
964 |
+
" ('1219.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.055110733956098557),\n",
|
965 |
+
" ('157.jpg;Nospot;Lobed;Raceme;Many;BluePurple;Pink;5', 0.05467784404754639),\n",
|
966 |
+
" ('602.jpg;Spot;Pouched;SingleOrPair;SinglePair;PinkRedWhite;Pink;12',\n",
|
967 |
+
" 0.05428561568260193),\n",
|
968 |
+
" ('770.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.054113131016492844),\n",
|
969 |
+
" ('1329.jpg;Spot;Lobed;Raceme;AFew;White;YellowBrown;24', 0.05381302163004875),\n",
|
970 |
+
" ('1255.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.05171913653612137),\n",
|
971 |
+
" ('1282.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.0514286570250988),\n",
|
972 |
+
" ('796.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.0476374514400959),\n",
|
973 |
+
" ('584.jpg;Spot;Pouched;SingleOrPair;SinglePair;PinkRedWhite;Pink;12',\n",
|
974 |
+
" 0.047247808426618576),\n",
|
975 |
+
" ('1092.jpg;Nospot;Simple;Raceme;Many;PinkRed;YellowPurple;22',\n",
|
976 |
+
" 0.04512034356594086),\n",
|
977 |
+
" ('158.jpg;Nospot;Lobed;Raceme;Many;BluePurple;Pink;5', 0.04467027261853218),\n",
|
978 |
+
" ('373.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.04281145706772804),\n",
|
979 |
+
" ('1162.jpg;Nospot;Simple;Raceme;Many;PinkRed;YellowPurple;22',\n",
|
980 |
+
" 0.04127465561032295),\n",
|
981 |
+
" ('357.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.0410861074924469),\n",
|
982 |
+
" ('1260.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.04081709682941437),\n",
|
983 |
+
" ('840.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.04077337309718132),\n",
|
984 |
+
" ('795.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.039966385811567307),\n",
|
985 |
+
" ('1075.jpg;Spot;Simple;Raceme;AFew;White;GreenBrown;21', 0.03779946640133858),\n",
|
986 |
+
" ('2.jpg;Spot;Lobed;Raceme;AFew;PinkRedWhite;White;1', 0.03746962919831276),\n",
|
987 |
+
" ('3.jpg;Spot;Lobed;Raceme;AFew;PinkRedWhite;White;1', 0.03715381771326065),\n",
|
988 |
+
" ('1129.jpg;Nospot;Simple;Raceme;Many;PinkRed;YellowPurple;22',\n",
|
989 |
+
" 0.03667420521378517),\n",
|
990 |
+
" ('18.jpg;Spot;Lobed;Raceme;AFew;PinkRedWhite;White;1', 0.03613140806555748),\n",
|
991 |
+
" ('24.jpg;Spot;Lobed;Raceme;AFew;PinkRedWhite;White;1', 0.03517169505357742),\n",
|
992 |
+
" ('1160.jpg;Nospot;Simple;Raceme;Many;PinkRed;YellowPurple;22',\n",
|
993 |
+
" 0.033885665237903595),\n",
|
994 |
+
" ('57.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
995 |
+
" 0.033026933670043945),\n",
|
996 |
+
" ('1102.jpg;Nospot;Simple;Raceme;Many;PinkRed;YellowPurple;22',\n",
|
997 |
+
" 0.0327843576669693),\n",
|
998 |
+
" ('548.jpg;Spot;Pouched;SingleOrPair;SinglePair;PinkRedWhite;Pink;12',\n",
|
999 |
+
" 0.030232133343815804),\n",
|
1000 |
+
" ('919.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.029755480587482452),\n",
|
1001 |
+
" ('897.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.02920762076973915),\n",
|
1002 |
+
" ('79.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
1003 |
+
" 0.028464388102293015),\n",
|
1004 |
+
" ('1218.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.025755522772669792),\n",
|
1005 |
+
" ('4.jpg;Spot;Lobed;Raceme;AFew;PinkRedWhite;White;1', 0.025370949879288673),\n",
|
1006 |
+
" ('739.jpg;Nospot;Lobed;Raceme;AFew;Green;Green;17', 0.02451474778354168),\n",
|
1007 |
+
" ('1278.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.023888392373919487),\n",
|
1008 |
+
" ('1250.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.02321772463619709),\n",
|
1009 |
+
" ('76.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
1010 |
+
" 0.02258465811610222),\n",
|
1011 |
+
" ('33.jpg;Spot;Lobed;Raceme;AFew;White;GreenBrown;2', 0.02256450615823269),\n",
|
1012 |
+
" ('155.jpg;Nospot;Lobed;Raceme;Many;BluePurple;Pink;5', 0.02138908952474594),\n",
|
1013 |
+
" ('168.jpg;Spot;Lobed;Raceme;AFew;Green;GreenBrown;6', 0.02103375643491745),\n",
|
1014 |
+
" ('497.jpg;Spot;Pouched;SingleOrPair;SinglePair;PinkRedWhite;Pink;12',\n",
|
1015 |
+
" 0.02076958306133747),\n",
|
1016 |
+
" ('1002.jpg;Spot;Lobed;Raceme;Many;White;YellowPurple;20', 0.0206283051520586),\n",
|
1017 |
+
" ('172.jpg;Nospot;Lobed;Raceme;AFew;BluePurple;Purple;7',\n",
|
1018 |
+
" 0.020343966782093048),\n",
|
1019 |
+
" ('66.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
1020 |
+
" 0.019313814118504524),\n",
|
1021 |
+
" ('815.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.018260987475514412),\n",
|
1022 |
+
" ('1112.jpg;Nospot;Simple;Raceme;Many;PinkRed;YellowPurple;22',\n",
|
1023 |
+
" 0.018153410404920578),\n",
|
1024 |
+
" ('359.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.01792941242456436),\n",
|
1025 |
+
" ('177.jpg;Nospot;Lobed;Raceme;AFew;BluePurple;Purple;7', 0.01784311980009079),\n",
|
1026 |
+
" ('106.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
1027 |
+
" 0.017745058983564377),\n",
|
1028 |
+
" ('415.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.0175403393805027),\n",
|
1029 |
+
" ('1211.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.01693066954612732),\n",
|
1030 |
+
" ('896.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.016679489985108376),\n",
|
1031 |
+
" ('46.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
1032 |
+
" 0.016446145251393318),\n",
|
1033 |
+
" ('20.jpg;Spot;Lobed;Raceme;AFew;PinkRedWhite;White;1', 0.016246825456619263),\n",
|
1034 |
+
" ('1095.jpg;Nospot;Simple;Raceme;Many;PinkRed;YellowPurple;22',\n",
|
1035 |
+
" 0.016134588047862053),\n",
|
1036 |
+
" ('697.jpg;Nospot;Lobed;SingleOrPair;SinglePair;PinkRed;White;15',\n",
|
1037 |
+
" 0.015971848741173744),\n",
|
1038 |
+
" ('1120.jpg;Nospot;Simple;Raceme;Many;PinkRed;YellowPurple;22',\n",
|
1039 |
+
" 0.015784701332449913),\n",
|
1040 |
+
" ('787.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.015611162409186363),\n",
|
1041 |
+
" ('156.jpg;Nospot;Lobed;Raceme;Many;BluePurple;Pink;5', 0.015609643422067165),\n",
|
1042 |
+
" ('1254.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.014959271065890789),\n",
|
1043 |
+
" ('53.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
1044 |
+
" 0.014151744544506073),\n",
|
1045 |
+
" ('140.jpg;Nospot;Lobed;Raceme;Many;BluePurple;Pink;5', 0.013964534737169743),\n",
|
1046 |
+
" ('894.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.013306866399943829),\n",
|
1047 |
+
" ('72.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
1048 |
+
" 0.012626943178474903),\n",
|
1049 |
+
" ('875.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.012507344596087933),\n",
|
1050 |
+
" ('356.jpg;Nospot;Lobed;Raceme;AFew;PinkRed;Pink;11', 0.012436171993613243),\n",
|
1051 |
+
" ('674.jpg;Nospot;Lobed;Spike;AFew;White;White;13', 0.012422670610249043),\n",
|
1052 |
+
" ('863.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.011972565203905106),\n",
|
1053 |
+
" ('764.jpg;Nospot;Lobed;Raceme;AFew;Yellow;Yellow;18', 0.011872835457324982),\n",
|
1054 |
+
" ('780.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.01174514926970005),\n",
|
1055 |
+
" ('77.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
1056 |
+
" 0.01169571653008461),\n",
|
1057 |
+
" ('137.jpg;Nospot;Lobed;Raceme;AFew;BluePurple;Pink;4', 0.011682512238621712),\n",
|
1058 |
+
" ('44.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
1059 |
+
" 0.011502182111144066),\n",
|
1060 |
+
" ('1149.jpg;Nospot;Simple;Raceme;Many;PinkRed;YellowPurple;22',\n",
|
1061 |
+
" 0.011412670835852623),\n",
|
1062 |
+
" ('99.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
1063 |
+
" 0.011360845528542995),\n",
|
1064 |
+
" ('1256.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.011006956920027733),\n",
|
1065 |
+
" ('28.jpg;Spot;Lobed;Raceme;AFew;White;GreenBrown;2', 0.0104835731908679),\n",
|
1066 |
+
" ('1252.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.010352383367717266),\n",
|
1067 |
+
" ('42.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
1068 |
+
" 0.010113776661455631),\n",
|
1069 |
+
" ('1064.jpg;Spot;Simple;Raceme;AFew;White;GreenBrown;21',\n",
|
1070 |
+
" 0.009753772057592869),\n",
|
1071 |
+
" ('175.jpg;Nospot;Lobed;Raceme;AFew;BluePurple;Purple;7',\n",
|
1072 |
+
" 0.009223428554832935),\n",
|
1073 |
+
" ('1264.jpg;Spot;Lobed;Raceme;AFew;White;Green;23', 0.009143059141933918),\n",
|
1074 |
+
" ('151.jpg;Nospot;Lobed;Raceme;Many;BluePurple;Pink;5', 0.00906144455075264),\n",
|
1075 |
+
" ('512.jpg;Spot;Pouched;SingleOrPair;SinglePair;PinkRedWhite;Pink;12',\n",
|
1076 |
+
" 0.00896426197141409),\n",
|
1077 |
+
" ('98.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
1078 |
+
" 0.008810152299702168),\n",
|
1079 |
+
" ('1135.jpg;Nospot;Simple;Raceme;Many;PinkRed;YellowPurple;22',\n",
|
1080 |
+
" 0.008771269582211971),\n",
|
1081 |
+
" ('67.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
1082 |
+
" 0.00870033074170351),\n",
|
1083 |
+
" ('856.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.008633521385490894),\n",
|
1084 |
+
" ('103.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
1085 |
+
" 0.008289733901619911),\n",
|
1086 |
+
" ('73.jpg;Spot;Simple;SingleOrPair;SinglePair;PinkRed;Pink;3',\n",
|
1087 |
+
" 0.008183479309082031),\n",
|
1088 |
+
" ('904.jpg;Spot;Lobed;Raceme;Many;White;YellowBrown;19', 0.008113854564726353),\n",
|
1089 |
+
" ('597.jpg;Spot;Pouched;SingleOrPair;SinglePair;PinkRedWhite;Pink;12',\n",
|
1090 |
+
" 0.00803594570606947),\n",
|
1091 |
+
" ('535.jpg;Spot;Pouched;SingleOrPair;SinglePair;PinkRedWhite;Pink;12',\n",
|
1092 |
+
" 0.008010867051780224),\n",
|
1093 |
+
" ('153.jpg;Nospot;Lobed;Raceme;Many;BluePurple;Pink;5', 0.008003998547792435),\n",
|
1094 |
+
" ('498.jpg;Spot;Pouched;SingleOrPair;SinglePair;PinkRedWhite;Pink;12',\n",
|
1095 |
+
" 0.007863061502575874),\n",
|
1096 |
+
" ('23.jpg;Spot;Lobed;Raceme;AFew;PinkRedWhite;White;1', 0.007817661389708519)]"
|
1097 |
+
]
|
1098 |
+
},
|
1099 |
+
"metadata": {},
|
1100 |
+
"execution_count": 15
|
1101 |
+
}
|
1102 |
+
],
|
1103 |
+
"source": [
|
1104 |
+
"# Using ResNet for Image Classification\n",
|
1105 |
+
"# First, load the model\n",
|
1106 |
+
"resnet = models.resnet101(pretrained=True)\n",
|
1107 |
+
"\n",
|
1108 |
+
"# Second, put the network in eval mode\n",
|
1109 |
+
"resnet.eval()\n",
|
1110 |
+
"\n",
|
1111 |
+
"# Third, carry out model inference\n",
|
1112 |
+
"out = resnet(batch_t)\n",
|
1113 |
+
"\n",
|
1114 |
+
"# Forth, print the top 156 classes predicted by the model\n",
|
1115 |
+
"_, indices = torch.sort(out, descending=True)\n",
|
1116 |
+
"percentage = torch.nn.functional.softmax(out, dim=1)[0] * 100\n",
|
1117 |
+
"[(classes[idx], percentage[idx].item()) for idx in indices[0][:156]]"
|
1118 |
+
]
|
1119 |
+
}
|
1120 |
+
],
|
1121 |
+
"metadata": {
|
1122 |
+
"accelerator": "GPU",
|
1123 |
+
"colab": {
|
1124 |
+
"gpuType": "T4",
|
1125 |
+
"provenance": []
|
1126 |
+
},
|
1127 |
+
"kernelspec": {
|
1128 |
+
"display_name": "Python 3",
|
1129 |
+
"name": "python3"
|
1130 |
+
},
|
1131 |
+
"language_info": {
|
1132 |
+
"name": "python"
|
1133 |
+
}
|
1134 |
+
},
|
1135 |
+
"nbformat": 4,
|
1136 |
+
"nbformat_minor": 0
|
1137 |
+
}
|