|
2 | 2 | "cells": [ |
3 | 3 | { |
4 | 4 | "cell_type": "code", |
5 | | - "execution_count": 10, |
| 5 | + "execution_count": 1, |
6 | 6 | "metadata": { |
7 | 7 | "collapsed": true |
8 | 8 | }, |
|
18 | 18 | }, |
19 | 19 | { |
20 | 20 | "cell_type": "code", |
21 | | - "execution_count": 3, |
| 21 | + "execution_count": 2, |
22 | 22 | "metadata": { |
23 | 23 | "pycharm": { |
24 | 24 | "name": "#%%\n" |
25 | 25 | } |
26 | 26 | }, |
27 | 27 | "outputs": [], |
28 | 28 | "source": [ |
29 | | - "github_opts = dict(org=\"pjreddie\", repo=\"darknet\", sha=\"master\")\n", |
30 | | - "darknet_gh_url = \"github://{org}:{repo}@master\".format(**github_opts)\n", |
31 | | - "filecache_opts = dict(cache_storage=f\"{os.environ['HOME']}/.cache/darknet.py\")" |
| 29 | + "darknet_gh_url = \"github://pjreddie:darknet@master\"" |
32 | 30 | ] |
33 | 31 | }, |
34 | 32 | { |
35 | 33 | "cell_type": "code", |
36 | | - "execution_count": 4, |
| 34 | + "execution_count": 3, |
37 | 35 | "outputs": [], |
38 | 36 | "source": [ |
39 | 37 | "# Load the ImageNet 1k labels/metadata\n", |
40 | | - "with fsspec.open(f\"{darknet_gh_url}/data/imagenet.shortnames.list\") as f:\n", |
41 | | - " labels = [line.decode().rstrip() for line in f.readlines()[:1000]]" |
| 38 | + "with fsspec.open(f\"{darknet_gh_url}/data/imagenet.shortnames.list\", mode=\"rt\") as f:\n", |
| 39 | + " labels = [line.rstrip() for line in f.readlines()[:1000]]" |
42 | 40 | ], |
43 | 41 | "metadata": { |
44 | 42 | "collapsed": false, |
|
49 | 47 | }, |
50 | 48 | { |
51 | 49 | "cell_type": "code", |
52 | | - "execution_count": 6, |
| 50 | + "execution_count": 5, |
53 | 51 | "metadata": { |
54 | 52 | "pycharm": { |
55 | 53 | "name": "#%%\n" |
56 | 54 | } |
57 | 55 | }, |
58 | 56 | "outputs": [], |
59 | 57 | "source": [ |
60 | | - "config_of = fsspec.open(f\"filecache::github://cfg/darknet53_448.cfg\",\n", |
61 | | - " filecache=filecache_opts, github=github_opts)\n", |
62 | | - "weights_of = fsspec.open(\"filecache::https://pjreddie.com/media/files/darknet53_448.weights\",\n", |
63 | | - " filecache=filecache_opts)\n", |
64 | | - "with config_of as config:\n", |
65 | | - " with weights_of as weights:\n", |
66 | | - " # Load the Classifier\n", |
67 | | - " n = ImageClassifier(labels=labels,\n", |
68 | | - " config_file=config.name,\n", |
69 | | - " weights_file=weights.name)" |
| 58 | + "n = ImageClassifier(labels=labels,\n", |
| 59 | + " config_url=f\"{darknet_gh_url}/cfg/darknet53_448.cfg\",\n", |
| 60 | + " weights_url=\"https://pjreddie.com/media/files/darknet53_448.weights\")" |
70 | 61 | ] |
71 | 62 | }, |
72 | 63 | { |
73 | 64 | "cell_type": "code", |
74 | | - "execution_count": 7, |
| 65 | + "execution_count": 6, |
75 | 66 | "metadata": { |
76 | 67 | "pycharm": { |
77 | 68 | "name": "#%%\n" |
|
82 | 73 | "data": { |
83 | 74 | "text/plain": "[('malamute', 0.98354006),\n ('Eskimo dog', 0.0042837244),\n ('Siberian husky', 0.0031863458),\n ('Tibetan mastiff', 0.0030448402),\n ('Great Pyrenees', 0.0022190544)]" |
84 | 75 | }, |
85 | | - "execution_count": 7, |
| 76 | + "execution_count": 6, |
86 | 77 | "metadata": {}, |
87 | 78 | "output_type": "execute_result" |
88 | 79 | } |
|
94 | 85 | }, |
95 | 86 | { |
96 | 87 | "cell_type": "code", |
97 | | - "execution_count": 12, |
| 88 | + "execution_count": 7, |
98 | 89 | "outputs": [ |
99 | 90 | { |
100 | 91 | "data": { |
101 | 92 | "text/plain": "[('malamute', 0.98354006),\n ('Eskimo dog', 0.0042837244),\n ('Siberian husky', 0.0031863458),\n ('Tibetan mastiff', 0.0030448402),\n ('Great Pyrenees', 0.0022190544)]" |
102 | 93 | }, |
103 | | - "execution_count": 12, |
| 94 | + "execution_count": 7, |
104 | 95 | "metadata": {}, |
105 | 96 | "output_type": "execute_result" |
106 | 97 | } |
|
119 | 110 | }, |
120 | 111 | { |
121 | 112 | "cell_type": "code", |
122 | | - "execution_count": 13, |
| 113 | + "execution_count": 8, |
123 | 114 | "metadata": { |
124 | 115 | "pycharm": { |
125 | 116 | "name": "#%%\n" |
|
130 | 121 | "data": { |
131 | 122 | "text/plain": "[('malamute', 0.98354006),\n ('Eskimo dog', 0.0042837244),\n ('Siberian husky', 0.0031863458),\n ('Tibetan mastiff', 0.0030448402),\n ('Great Pyrenees', 0.0022190544)]" |
132 | 123 | }, |
133 | | - "execution_count": 13, |
| 124 | + "execution_count": 8, |
134 | 125 | "metadata": {}, |
135 | 126 | "output_type": "execute_result" |
136 | 127 | } |
|
150 | 141 | }, |
151 | 142 | { |
152 | 143 | "cell_type": "code", |
153 | | - "execution_count": 14, |
| 144 | + "execution_count": 9, |
154 | 145 | "metadata": { |
155 | 146 | "pycharm": { |
156 | 147 | "name": "#%%\n" |
|
161 | 152 | "data": { |
162 | 153 | "text/plain": "[('bald eagle', 0.55666465),\n ('vulture', 0.21876547),\n ('kite', 0.18937683),\n ('ruddy turnstone', 0.004589723),\n ('ruffed grouse', 0.0032499917)]" |
163 | 154 | }, |
164 | | - "execution_count": 14, |
| 155 | + "execution_count": 9, |
165 | 156 | "metadata": {}, |
166 | 157 | "output_type": "execute_result" |
167 | 158 | } |
|
172 | 163 | }, |
173 | 164 | { |
174 | 165 | "cell_type": "code", |
175 | | - "execution_count": 15, |
| 166 | + "execution_count": 10, |
176 | 167 | "metadata": { |
177 | 168 | "pycharm": { |
178 | 169 | "name": "#%%\n" |
|
183 | 174 | "data": { |
184 | 175 | "text/plain": "[('electric guitar', 0.98759043),\n ('acoustic guitar', 0.009553942),\n ('banjo', 0.0011607071),\n ('pick', 0.0007309786),\n ('stage', 0.00058993115)]" |
185 | 176 | }, |
186 | | - "execution_count": 15, |
| 177 | + "execution_count": 10, |
187 | 178 | "metadata": {}, |
188 | 179 | "output_type": "execute_result" |
189 | 180 | } |
|
0 commit comments