hujameson commited on
Commit
c1e5d84
1 Parent(s): 68bd949

create app with docker mode on Space

Browse files
Dockerfile ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # For more information, please refer to https://aka.ms/vscode-docker-python
2
+ FROM python:3.10-slim
3
+
4
+ EXPOSE 8000
5
+
6
+ # Keeps Python from generating .pyc files in the container
7
+ ENV PYTHONDONTWRITEBYTECODE=1
8
+
9
+ # Turns off buffering for easier container logging
10
+ ENV PYTHONUNBUFFERED=1
11
+
12
+ # Install pip requirements
13
+ COPY requirements.txt .
14
+ RUN python -m pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
15
+ RUN python -m pip install -r requirements.txt
16
+
17
+ WORKDIR /app
18
+ COPY . /app
19
+
20
+ # Creates a non-root user with an explicit UID and adds permission to access the /app folder
21
+ # For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers
22
+ RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
23
+ USER appuser
24
+
25
+ # During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug
26
+ CMD ["gunicorn", "--bind", "0.0.0.0:8000", "-k", "uvicorn.workers.UvicornWorker", "main:app"]
birds-classifier-efficientnetb2/config.json ADDED
@@ -0,0 +1,1137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "google/efficientnet-b2",
3
+ "architectures": [
4
+ "EfficientNetForImageClassification"
5
+ ],
6
+ "batch_norm_eps": 0.001,
7
+ "batch_norm_momentum": 0.99,
8
+ "depth_coefficient": 1.2,
9
+ "depth_divisor": 8,
10
+ "depthwise_padding": [
11
+ 5,
12
+ 8,
13
+ 16
14
+ ],
15
+ "drop_connect_rate": 0.2,
16
+ "dropout_rate": 0.3,
17
+ "expand_ratios": [
18
+ 1,
19
+ 6,
20
+ 6,
21
+ 6,
22
+ 6,
23
+ 6,
24
+ 6
25
+ ],
26
+ "hidden_act": "swish",
27
+ "hidden_dim": 1408,
28
+ "id2label": {
29
+ "0": "ABBOTTS BABBLER",
30
+ "1": "ABBOTTS BOOBY",
31
+ "2": "ABYSSINIAN GROUND HORNBILL",
32
+ "3": "AFRICAN CROWNED CRANE",
33
+ "4": "AFRICAN EMERALD CUCKOO",
34
+ "5": "AFRICAN FIREFINCH",
35
+ "6": "AFRICAN OYSTER CATCHER",
36
+ "7": "AFRICAN PIED HORNBILL",
37
+ "8": "AFRICAN PYGMY GOOSE",
38
+ "9": "ALBATROSS",
39
+ "10": "ALBERTS TOWHEE",
40
+ "11": "ALEXANDRINE PARAKEET",
41
+ "12": "ALPINE CHOUGH",
42
+ "13": "ALTAMIRA YELLOWTHROAT",
43
+ "14": "AMERICAN AVOCET",
44
+ "15": "AMERICAN BITTERN",
45
+ "16": "AMERICAN COOT",
46
+ "17": "AMERICAN DIPPER",
47
+ "18": "AMERICAN FLAMINGO",
48
+ "19": "AMERICAN GOLDFINCH",
49
+ "20": "AMERICAN KESTREL",
50
+ "21": "AMERICAN PIPIT",
51
+ "22": "AMERICAN REDSTART",
52
+ "23": "AMERICAN ROBIN",
53
+ "24": "AMERICAN WIGEON",
54
+ "25": "AMETHYST WOODSTAR",
55
+ "26": "ANDEAN GOOSE",
56
+ "27": "ANDEAN LAPWING",
57
+ "28": "ANDEAN SISKIN",
58
+ "29": "ANHINGA",
59
+ "30": "ANIANIAU",
60
+ "31": "ANNAS HUMMINGBIRD",
61
+ "32": "ANTBIRD",
62
+ "33": "ANTILLEAN EUPHONIA",
63
+ "34": "APAPANE",
64
+ "35": "APOSTLEBIRD",
65
+ "36": "ARARIPE MANAKIN",
66
+ "37": "ASHY STORM PETREL",
67
+ "38": "ASHY THRUSHBIRD",
68
+ "39": "ASIAN CRESTED IBIS",
69
+ "40": "ASIAN DOLLARD BIRD",
70
+ "41": "ASIAN GREEN BEE EATER",
71
+ "42": "ASIAN OPENBILL STORK",
72
+ "43": "AUCKLAND SHAQ",
73
+ "44": "AUSTRAL CANASTERO",
74
+ "45": "AUSTRALASIAN FIGBIRD",
75
+ "46": "AVADAVAT",
76
+ "47": "AZARAS SPINETAIL",
77
+ "48": "AZURE BREASTED PITTA",
78
+ "49": "AZURE JAY",
79
+ "50": "AZURE TANAGER",
80
+ "51": "AZURE TIT",
81
+ "52": "BAIKAL TEAL",
82
+ "53": "BALD EAGLE",
83
+ "54": "BALD IBIS",
84
+ "55": "BALI STARLING",
85
+ "56": "BALTIMORE ORIOLE",
86
+ "57": "BANANAQUIT",
87
+ "58": "BAND TAILED GUAN",
88
+ "59": "BANDED BROADBILL",
89
+ "60": "BANDED PITA",
90
+ "61": "BANDED STILT",
91
+ "62": "BAR-TAILED GODWIT",
92
+ "63": "BARN OWL",
93
+ "64": "BARN SWALLOW",
94
+ "65": "BARRED PUFFBIRD",
95
+ "66": "BARROWS GOLDENEYE",
96
+ "67": "BAY-BREASTED WARBLER",
97
+ "68": "BEARDED BARBET",
98
+ "69": "BEARDED BELLBIRD",
99
+ "70": "BEARDED REEDLING",
100
+ "71": "BELTED KINGFISHER",
101
+ "72": "BIRD OF PARADISE",
102
+ "73": "BLACK AND YELLOW BROADBILL",
103
+ "74": "BLACK BAZA",
104
+ "75": "BLACK BREASTED PUFFBIRD",
105
+ "76": "BLACK COCKATO",
106
+ "77": "BLACK FACED SPOONBILL",
107
+ "78": "BLACK FRANCOLIN",
108
+ "79": "BLACK HEADED CAIQUE",
109
+ "80": "BLACK NECKED STILT",
110
+ "81": "BLACK SKIMMER",
111
+ "82": "BLACK SWAN",
112
+ "83": "BLACK TAIL CRAKE",
113
+ "84": "BLACK THROATED BUSHTIT",
114
+ "85": "BLACK THROATED HUET",
115
+ "86": "BLACK THROATED WARBLER",
116
+ "87": "BLACK VENTED SHEARWATER",
117
+ "88": "BLACK VULTURE",
118
+ "89": "BLACK-CAPPED CHICKADEE",
119
+ "90": "BLACK-NECKED GREBE",
120
+ "91": "BLACK-THROATED SPARROW",
121
+ "92": "BLACKBURNIAM WARBLER",
122
+ "93": "BLONDE CRESTED WOODPECKER",
123
+ "94": "BLOOD PHEASANT",
124
+ "95": "BLUE COAU",
125
+ "96": "BLUE DACNIS",
126
+ "97": "BLUE GRAY GNATCATCHER",
127
+ "98": "BLUE GROSBEAK",
128
+ "99": "BLUE GROUSE",
129
+ "100": "BLUE HERON",
130
+ "101": "BLUE MALKOHA",
131
+ "102": "BLUE THROATED PIPING GUAN",
132
+ "103": "BLUE THROATED TOUCANET",
133
+ "104": "BOBOLINK",
134
+ "105": "BORNEAN BRISTLEHEAD",
135
+ "106": "BORNEAN LEAFBIRD",
136
+ "107": "BORNEAN PHEASANT",
137
+ "108": "BRANDT CORMARANT",
138
+ "109": "BREWERS BLACKBIRD",
139
+ "110": "BROWN CREPPER",
140
+ "111": "BROWN HEADED COWBIRD",
141
+ "112": "BROWN NOODY",
142
+ "113": "BROWN THRASHER",
143
+ "114": "BUFFLEHEAD",
144
+ "115": "BULWERS PHEASANT",
145
+ "116": "BURCHELLS COURSER",
146
+ "117": "BUSH TURKEY",
147
+ "118": "CAATINGA CACHOLOTE",
148
+ "119": "CABOTS TRAGOPAN",
149
+ "120": "CACTUS WREN",
150
+ "121": "CALIFORNIA CONDOR",
151
+ "122": "CALIFORNIA GULL",
152
+ "123": "CALIFORNIA QUAIL",
153
+ "124": "CAMPO FLICKER",
154
+ "125": "CANARY",
155
+ "126": "CANVASBACK",
156
+ "127": "CAPE GLOSSY STARLING",
157
+ "128": "CAPE LONGCLAW",
158
+ "129": "CAPE MAY WARBLER",
159
+ "130": "CAPE ROCK THRUSH",
160
+ "131": "CAPPED HERON",
161
+ "132": "CAPUCHINBIRD",
162
+ "133": "CARMINE BEE-EATER",
163
+ "134": "CASPIAN TERN",
164
+ "135": "CASSOWARY",
165
+ "136": "CEDAR WAXWING",
166
+ "137": "CERULEAN WARBLER",
167
+ "138": "CHARA DE COLLAR",
168
+ "139": "CHATTERING LORY",
169
+ "140": "CHESTNET BELLIED EUPHONIA",
170
+ "141": "CHESTNUT WINGED CUCKOO",
171
+ "142": "CHINESE BAMBOO PARTRIDGE",
172
+ "143": "CHINESE POND HERON",
173
+ "144": "CHIPPING SPARROW",
174
+ "145": "CHUCAO TAPACULO",
175
+ "146": "CHUKAR PARTRIDGE",
176
+ "147": "CINNAMON ATTILA",
177
+ "148": "CINNAMON FLYCATCHER",
178
+ "149": "CINNAMON TEAL",
179
+ "150": "CLARKS GREBE",
180
+ "151": "CLARKS NUTCRACKER",
181
+ "152": "COCK OF THE ROCK",
182
+ "153": "COCKATOO",
183
+ "154": "COLLARED ARACARI",
184
+ "155": "COLLARED CRESCENTCHEST",
185
+ "156": "COMMON FIRECREST",
186
+ "157": "COMMON GRACKLE",
187
+ "158": "COMMON HOUSE MARTIN",
188
+ "159": "COMMON IORA",
189
+ "160": "COMMON LOON",
190
+ "161": "COMMON POORWILL",
191
+ "162": "COMMON STARLING",
192
+ "163": "COPPERSMITH BARBET",
193
+ "164": "COPPERY TAILED COUCAL",
194
+ "165": "CRAB PLOVER",
195
+ "166": "CRANE HAWK",
196
+ "167": "CREAM COLORED WOODPECKER",
197
+ "168": "CRESTED AUKLET",
198
+ "169": "CRESTED CARACARA",
199
+ "170": "CRESTED COUA",
200
+ "171": "CRESTED FIREBACK",
201
+ "172": "CRESTED KINGFISHER",
202
+ "173": "CRESTED NUTHATCH",
203
+ "174": "CRESTED OROPENDOLA",
204
+ "175": "CRESTED SERPENT EAGLE",
205
+ "176": "CRESTED SHRIKETIT",
206
+ "177": "CRESTED WOOD PARTRIDGE",
207
+ "178": "CRIMSON CHAT",
208
+ "179": "CRIMSON SUNBIRD",
209
+ "180": "CROW",
210
+ "181": "CUBAN TODY",
211
+ "182": "CUBAN TROGON",
212
+ "183": "CURL CRESTED ARACURI",
213
+ "184": "D-ARNAUDS BARBET",
214
+ "185": "DALMATIAN PELICAN",
215
+ "186": "DARJEELING WOODPECKER",
216
+ "187": "DARK EYED JUNCO",
217
+ "188": "DAURIAN REDSTART",
218
+ "189": "DEMOISELLE CRANE",
219
+ "190": "DOUBLE BARRED FINCH",
220
+ "191": "DOUBLE BRESTED CORMARANT",
221
+ "192": "DOUBLE EYED FIG PARROT",
222
+ "193": "DOWNY WOODPECKER",
223
+ "194": "DUNLIN",
224
+ "195": "DUSKY LORY",
225
+ "196": "DUSKY ROBIN",
226
+ "197": "EARED PITA",
227
+ "198": "EASTERN BLUEBIRD",
228
+ "199": "EASTERN BLUEBONNET",
229
+ "200": "EASTERN GOLDEN WEAVER",
230
+ "201": "EASTERN MEADOWLARK",
231
+ "202": "EASTERN ROSELLA",
232
+ "203": "EASTERN TOWEE",
233
+ "204": "EASTERN WIP POOR WILL",
234
+ "205": "EASTERN YELLOW ROBIN",
235
+ "206": "ECUADORIAN HILLSTAR",
236
+ "207": "EGYPTIAN GOOSE",
237
+ "208": "ELEGANT TROGON",
238
+ "209": "ELLIOTS PHEASANT",
239
+ "210": "EMERALD TANAGER",
240
+ "211": "EMPEROR PENGUIN",
241
+ "212": "EMU",
242
+ "213": "ENGGANO MYNA",
243
+ "214": "EURASIAN BULLFINCH",
244
+ "215": "EURASIAN GOLDEN ORIOLE",
245
+ "216": "EURASIAN MAGPIE",
246
+ "217": "EUROPEAN GOLDFINCH",
247
+ "218": "EUROPEAN TURTLE DOVE",
248
+ "219": "EVENING GROSBEAK",
249
+ "220": "FAIRY BLUEBIRD",
250
+ "221": "FAIRY PENGUIN",
251
+ "222": "FAIRY TERN",
252
+ "223": "FAN TAILED WIDOW",
253
+ "224": "FASCIATED WREN",
254
+ "225": "FIERY MINIVET",
255
+ "226": "FIORDLAND PENGUIN",
256
+ "227": "FIRE TAILLED MYZORNIS",
257
+ "228": "FLAME BOWERBIRD",
258
+ "229": "FLAME TANAGER",
259
+ "230": "FOREST WAGTAIL",
260
+ "231": "FRIGATE",
261
+ "232": "FRILL BACK PIGEON",
262
+ "233": "GAMBELS QUAIL",
263
+ "234": "GANG GANG COCKATOO",
264
+ "235": "GILA WOODPECKER",
265
+ "236": "GILDED FLICKER",
266
+ "237": "GLOSSY IBIS",
267
+ "238": "GO AWAY BIRD",
268
+ "239": "GOLD WING WARBLER",
269
+ "240": "GOLDEN BOWER BIRD",
270
+ "241": "GOLDEN CHEEKED WARBLER",
271
+ "242": "GOLDEN CHLOROPHONIA",
272
+ "243": "GOLDEN EAGLE",
273
+ "244": "GOLDEN PARAKEET",
274
+ "245": "GOLDEN PHEASANT",
275
+ "246": "GOLDEN PIPIT",
276
+ "247": "GOULDIAN FINCH",
277
+ "248": "GRANDALA",
278
+ "249": "GRAY CATBIRD",
279
+ "250": "GRAY KINGBIRD",
280
+ "251": "GRAY PARTRIDGE",
281
+ "252": "GREAT ARGUS",
282
+ "253": "GREAT GRAY OWL",
283
+ "254": "GREAT JACAMAR",
284
+ "255": "GREAT KISKADEE",
285
+ "256": "GREAT POTOO",
286
+ "257": "GREAT TINAMOU",
287
+ "258": "GREAT XENOPS",
288
+ "259": "GREATER PEWEE",
289
+ "260": "GREATER PRAIRIE CHICKEN",
290
+ "261": "GREATOR SAGE GROUSE",
291
+ "262": "GREEN BROADBILL",
292
+ "263": "GREEN JAY",
293
+ "264": "GREEN MAGPIE",
294
+ "265": "GREEN WINGED DOVE",
295
+ "266": "GREY CUCKOOSHRIKE",
296
+ "267": "GREY HEADED CHACHALACA",
297
+ "268": "GREY HEADED FISH EAGLE",
298
+ "269": "GREY PLOVER",
299
+ "270": "GROVED BILLED ANI",
300
+ "271": "GUINEA TURACO",
301
+ "272": "GUINEAFOWL",
302
+ "273": "GURNEYS PITTA",
303
+ "274": "GYRFALCON",
304
+ "275": "HAMERKOP",
305
+ "276": "HARLEQUIN DUCK",
306
+ "277": "HARLEQUIN QUAIL",
307
+ "278": "HARPY EAGLE",
308
+ "279": "HAWAIIAN GOOSE",
309
+ "280": "HAWFINCH",
310
+ "281": "HELMET VANGA",
311
+ "282": "HEPATIC TANAGER",
312
+ "283": "HIMALAYAN BLUETAIL",
313
+ "284": "HIMALAYAN MONAL",
314
+ "285": "HOATZIN",
315
+ "286": "HOODED MERGANSER",
316
+ "287": "HOOPOES",
317
+ "288": "HORNED GUAN",
318
+ "289": "HORNED LARK",
319
+ "290": "HORNED SUNGEM",
320
+ "291": "HOUSE FINCH",
321
+ "292": "HOUSE SPARROW",
322
+ "293": "HYACINTH MACAW",
323
+ "294": "IBERIAN MAGPIE",
324
+ "295": "IBISBILL",
325
+ "296": "IMPERIAL SHAQ",
326
+ "297": "INCA TERN",
327
+ "298": "INDIAN BUSTARD",
328
+ "299": "INDIAN PITTA",
329
+ "300": "INDIAN ROLLER",
330
+ "301": "INDIAN VULTURE",
331
+ "302": "INDIGO BUNTING",
332
+ "303": "INDIGO FLYCATCHER",
333
+ "304": "INLAND DOTTEREL",
334
+ "305": "IVORY BILLED ARACARI",
335
+ "306": "IVORY GULL",
336
+ "307": "IWI",
337
+ "308": "JABIRU",
338
+ "309": "JACK SNIPE",
339
+ "310": "JACOBIN PIGEON",
340
+ "311": "JANDAYA PARAKEET",
341
+ "312": "JAPANESE ROBIN",
342
+ "313": "JAVA SPARROW",
343
+ "314": "JOCOTOCO ANTPITTA",
344
+ "315": "KAGU",
345
+ "316": "KAKAPO",
346
+ "317": "KILLDEAR",
347
+ "318": "KING EIDER",
348
+ "319": "KING VULTURE",
349
+ "320": "KIWI",
350
+ "321": "KNOB BILLED DUCK",
351
+ "322": "KOOKABURRA",
352
+ "323": "LARK BUNTING",
353
+ "324": "LAUGHING GULL",
354
+ "325": "LAZULI BUNTING",
355
+ "326": "LESSER ADJUTANT",
356
+ "327": "LILAC ROLLER",
357
+ "328": "LIMPKIN",
358
+ "329": "LITTLE AUK",
359
+ "330": "LOGGERHEAD SHRIKE",
360
+ "331": "LONG-EARED OWL",
361
+ "332": "LOONEY BIRDS",
362
+ "333": "LUCIFER HUMMINGBIRD",
363
+ "334": "MAGPIE GOOSE",
364
+ "335": "MALABAR HORNBILL",
365
+ "336": "MALACHITE KINGFISHER",
366
+ "337": "MALAGASY WHITE EYE",
367
+ "338": "MALEO",
368
+ "339": "MALLARD DUCK",
369
+ "340": "MANDRIN DUCK",
370
+ "341": "MANGROVE CUCKOO",
371
+ "342": "MARABOU STORK",
372
+ "343": "MASKED BOBWHITE",
373
+ "344": "MASKED BOOBY",
374
+ "345": "MASKED LAPWING",
375
+ "346": "MCKAYS BUNTING",
376
+ "347": "MERLIN",
377
+ "348": "MIKADO PHEASANT",
378
+ "349": "MILITARY MACAW",
379
+ "350": "MOURNING DOVE",
380
+ "351": "MYNA",
381
+ "352": "NICOBAR PIGEON",
382
+ "353": "NOISY FRIARBIRD",
383
+ "354": "NORTHERN BEARDLESS TYRANNULET",
384
+ "355": "NORTHERN CARDINAL",
385
+ "356": "NORTHERN FLICKER",
386
+ "357": "NORTHERN FULMAR",
387
+ "358": "NORTHERN GANNET",
388
+ "359": "NORTHERN GOSHAWK",
389
+ "360": "NORTHERN JACANA",
390
+ "361": "NORTHERN MOCKINGBIRD",
391
+ "362": "NORTHERN PARULA",
392
+ "363": "NORTHERN RED BISHOP",
393
+ "364": "NORTHERN SHOVELER",
394
+ "365": "OCELLATED TURKEY",
395
+ "366": "OILBIRD",
396
+ "367": "OKINAWA RAIL",
397
+ "368": "ORANGE BREASTED TROGON",
398
+ "369": "ORANGE BRESTED BUNTING",
399
+ "370": "ORIENTAL BAY OWL",
400
+ "371": "ORNATE HAWK EAGLE",
401
+ "372": "OSPREY",
402
+ "373": "OSTRICH",
403
+ "374": "OVENBIRD",
404
+ "375": "OYSTER CATCHER",
405
+ "376": "PAINTED BUNTING",
406
+ "377": "PALILA",
407
+ "378": "PALM NUT VULTURE",
408
+ "379": "PARADISE TANAGER",
409
+ "380": "PARAKETT AUKLET",
410
+ "381": "PARUS MAJOR",
411
+ "382": "PATAGONIAN SIERRA FINCH",
412
+ "383": "PEACOCK",
413
+ "384": "PEREGRINE FALCON",
414
+ "385": "PHAINOPEPLA",
415
+ "386": "PHILIPPINE EAGLE",
416
+ "387": "PINK ROBIN",
417
+ "388": "PLUSH CRESTED JAY",
418
+ "389": "POMARINE JAEGER",
419
+ "390": "PUFFIN",
420
+ "391": "PUNA TEAL",
421
+ "392": "PURPLE FINCH",
422
+ "393": "PURPLE GALLINULE",
423
+ "394": "PURPLE MARTIN",
424
+ "395": "PURPLE SWAMPHEN",
425
+ "396": "PYGMY KINGFISHER",
426
+ "397": "PYRRHULOXIA",
427
+ "398": "QUETZAL",
428
+ "399": "RAINBOW LORIKEET",
429
+ "400": "RAZORBILL",
430
+ "401": "RED BEARDED BEE EATER",
431
+ "402": "RED BELLIED PITTA",
432
+ "403": "RED BILLED TROPICBIRD",
433
+ "404": "RED BROWED FINCH",
434
+ "405": "RED CROSSBILL",
435
+ "406": "RED FACED CORMORANT",
436
+ "407": "RED FACED WARBLER",
437
+ "408": "RED FODY",
438
+ "409": "RED HEADED DUCK",
439
+ "410": "RED HEADED WOODPECKER",
440
+ "411": "RED KNOT",
441
+ "412": "RED LEGGED HONEYCREEPER",
442
+ "413": "RED NAPED TROGON",
443
+ "414": "RED SHOULDERED HAWK",
444
+ "415": "RED TAILED HAWK",
445
+ "416": "RED TAILED THRUSH",
446
+ "417": "RED WINGED BLACKBIRD",
447
+ "418": "RED WISKERED BULBUL",
448
+ "419": "REGENT BOWERBIRD",
449
+ "420": "RING-NECKED PHEASANT",
450
+ "421": "ROADRUNNER",
451
+ "422": "ROCK DOVE",
452
+ "423": "ROSE BREASTED COCKATOO",
453
+ "424": "ROSE BREASTED GROSBEAK",
454
+ "425": "ROSEATE SPOONBILL",
455
+ "426": "ROSY FACED LOVEBIRD",
456
+ "427": "ROUGH LEG BUZZARD",
457
+ "428": "ROYAL FLYCATCHER",
458
+ "429": "RUBY CROWNED KINGLET",
459
+ "430": "RUBY THROATED HUMMINGBIRD",
460
+ "431": "RUDDY SHELDUCK",
461
+ "432": "RUDY KINGFISHER",
462
+ "433": "RUFOUS KINGFISHER",
463
+ "434": "RUFOUS TREPE",
464
+ "435": "RUFUOS MOTMOT",
465
+ "436": "SAMATRAN THRUSH",
466
+ "437": "SAND MARTIN",
467
+ "438": "SANDHILL CRANE",
468
+ "439": "SATYR TRAGOPAN",
469
+ "440": "SAYS PHOEBE",
470
+ "441": "SCARLET CROWNED FRUIT DOVE",
471
+ "442": "SCARLET FACED LIOCICHLA",
472
+ "443": "SCARLET IBIS",
473
+ "444": "SCARLET MACAW",
474
+ "445": "SCARLET TANAGER",
475
+ "446": "SHOEBILL",
476
+ "447": "SHORT BILLED DOWITCHER",
477
+ "448": "SMITHS LONGSPUR",
478
+ "449": "SNOW GOOSE",
479
+ "450": "SNOW PARTRIDGE",
480
+ "451": "SNOWY EGRET",
481
+ "452": "SNOWY OWL",
482
+ "453": "SNOWY PLOVER",
483
+ "454": "SNOWY SHEATHBILL",
484
+ "455": "SORA",
485
+ "456": "SPANGLED COTINGA",
486
+ "457": "SPLENDID WREN",
487
+ "458": "SPOON BILED SANDPIPER",
488
+ "459": "SPOTTED CATBIRD",
489
+ "460": "SPOTTED WHISTLING DUCK",
490
+ "461": "SQUACCO HERON",
491
+ "462": "SRI LANKA BLUE MAGPIE",
492
+ "463": "STEAMER DUCK",
493
+ "464": "STORK BILLED KINGFISHER",
494
+ "465": "STRIATED CARACARA",
495
+ "466": "STRIPED OWL",
496
+ "467": "STRIPPED MANAKIN",
497
+ "468": "STRIPPED SWALLOW",
498
+ "469": "SUNBITTERN",
499
+ "470": "SUPERB STARLING",
500
+ "471": "SURF SCOTER",
501
+ "472": "SWINHOES PHEASANT",
502
+ "473": "TAILORBIRD",
503
+ "474": "TAIWAN MAGPIE",
504
+ "475": "TAKAHE",
505
+ "476": "TASMANIAN HEN",
506
+ "477": "TAWNY FROGMOUTH",
507
+ "478": "TEAL DUCK",
508
+ "479": "TIT MOUSE",
509
+ "480": "TOUCHAN",
510
+ "481": "TOWNSENDS WARBLER",
511
+ "482": "TREE SWALLOW",
512
+ "483": "TRICOLORED BLACKBIRD",
513
+ "484": "TROPICAL KINGBIRD",
514
+ "485": "TRUMPTER SWAN",
515
+ "486": "TURKEY VULTURE",
516
+ "487": "TURQUOISE MOTMOT",
517
+ "488": "UMBRELLA BIRD",
518
+ "489": "VARIED THRUSH",
519
+ "490": "VEERY",
520
+ "491": "VENEZUELIAN TROUPIAL",
521
+ "492": "VERDIN",
522
+ "493": "VERMILION FLYCATHER",
523
+ "494": "VICTORIA CROWNED PIGEON",
524
+ "495": "VIOLET BACKED STARLING",
525
+ "496": "VIOLET CUCKOO",
526
+ "497": "VIOLET GREEN SWALLOW",
527
+ "498": "VIOLET TURACO",
528
+ "499": "VISAYAN HORNBILL",
529
+ "500": "VULTURINE GUINEAFOWL",
530
+ "501": "WALL CREAPER",
531
+ "502": "WATTLED CURASSOW",
532
+ "503": "WATTLED LAPWING",
533
+ "504": "WHIMBREL",
534
+ "505": "WHITE BREASTED WATERHEN",
535
+ "506": "WHITE BROWED CRAKE",
536
+ "507": "WHITE CHEEKED TURACO",
537
+ "508": "WHITE CRESTED HORNBILL",
538
+ "509": "WHITE EARED HUMMINGBIRD",
539
+ "510": "WHITE NECKED RAVEN",
540
+ "511": "WHITE TAILED TROPIC",
541
+ "512": "WHITE THROATED BEE EATER",
542
+ "513": "WILD TURKEY",
543
+ "514": "WILLOW PTARMIGAN",
544
+ "515": "WILSONS BIRD OF PARADISE",
545
+ "516": "WOOD DUCK",
546
+ "517": "WOOD THRUSH",
547
+ "518": "WOODLAND KINGFISHER",
548
+ "519": "WRENTIT",
549
+ "520": "YELLOW BELLIED FLOWERPECKER",
550
+ "521": "YELLOW BREASTED CHAT",
551
+ "522": "YELLOW CACIQUE",
552
+ "523": "YELLOW HEADED BLACKBIRD",
553
+ "524": "ZEBRA DOVE"
554
+ },
555
+ "image_size": 260,
556
+ "in_channels": [
557
+ 32,
558
+ 16,
559
+ 24,
560
+ 40,
561
+ 80,
562
+ 112,
563
+ 192
564
+ ],
565
+ "initializer_range": 0.02,
566
+ "kernel_sizes": [
567
+ 3,
568
+ 3,
569
+ 5,
570
+ 3,
571
+ 5,
572
+ 5,
573
+ 3
574
+ ],
575
+ "label2id": {
576
+ "ABBOTTS BABBLER": 0,
577
+ "ABBOTTS BOOBY": 1,
578
+ "ABYSSINIAN GROUND HORNBILL": 2,
579
+ "AFRICAN CROWNED CRANE": 3,
580
+ "AFRICAN EMERALD CUCKOO": 4,
581
+ "AFRICAN FIREFINCH": 5,
582
+ "AFRICAN OYSTER CATCHER": 6,
583
+ "AFRICAN PIED HORNBILL": 7,
584
+ "AFRICAN PYGMY GOOSE": 8,
585
+ "ALBATROSS": 9,
586
+ "ALBERTS TOWHEE": 10,
587
+ "ALEXANDRINE PARAKEET": 11,
588
+ "ALPINE CHOUGH": 12,
589
+ "ALTAMIRA YELLOWTHROAT": 13,
590
+ "AMERICAN AVOCET": 14,
591
+ "AMERICAN BITTERN": 15,
592
+ "AMERICAN COOT": 16,
593
+ "AMERICAN DIPPER": 17,
594
+ "AMERICAN FLAMINGO": 18,
595
+ "AMERICAN GOLDFINCH": 19,
596
+ "AMERICAN KESTREL": 20,
597
+ "AMERICAN PIPIT": 21,
598
+ "AMERICAN REDSTART": 22,
599
+ "AMERICAN ROBIN": 23,
600
+ "AMERICAN WIGEON": 24,
601
+ "AMETHYST WOODSTAR": 25,
602
+ "ANDEAN GOOSE": 26,
603
+ "ANDEAN LAPWING": 27,
604
+ "ANDEAN SISKIN": 28,
605
+ "ANHINGA": 29,
606
+ "ANIANIAU": 30,
607
+ "ANNAS HUMMINGBIRD": 31,
608
+ "ANTBIRD": 32,
609
+ "ANTILLEAN EUPHONIA": 33,
610
+ "APAPANE": 34,
611
+ "APOSTLEBIRD": 35,
612
+ "ARARIPE MANAKIN": 36,
613
+ "ASHY STORM PETREL": 37,
614
+ "ASHY THRUSHBIRD": 38,
615
+ "ASIAN CRESTED IBIS": 39,
616
+ "ASIAN DOLLARD BIRD": 40,
617
+ "ASIAN GREEN BEE EATER": 41,
618
+ "ASIAN OPENBILL STORK": 42,
619
+ "AUCKLAND SHAQ": 43,
620
+ "AUSTRAL CANASTERO": 44,
621
+ "AUSTRALASIAN FIGBIRD": 45,
622
+ "AVADAVAT": 46,
623
+ "AZARAS SPINETAIL": 47,
624
+ "AZURE BREASTED PITTA": 48,
625
+ "AZURE JAY": 49,
626
+ "AZURE TANAGER": 50,
627
+ "AZURE TIT": 51,
628
+ "BAIKAL TEAL": 52,
629
+ "BALD EAGLE": 53,
630
+ "BALD IBIS": 54,
631
+ "BALI STARLING": 55,
632
+ "BALTIMORE ORIOLE": 56,
633
+ "BANANAQUIT": 57,
634
+ "BAND TAILED GUAN": 58,
635
+ "BANDED BROADBILL": 59,
636
+ "BANDED PITA": 60,
637
+ "BANDED STILT": 61,
638
+ "BAR-TAILED GODWIT": 62,
639
+ "BARN OWL": 63,
640
+ "BARN SWALLOW": 64,
641
+ "BARRED PUFFBIRD": 65,
642
+ "BARROWS GOLDENEYE": 66,
643
+ "BAY-BREASTED WARBLER": 67,
644
+ "BEARDED BARBET": 68,
645
+ "BEARDED BELLBIRD": 69,
646
+ "BEARDED REEDLING": 70,
647
+ "BELTED KINGFISHER": 71,
648
+ "BIRD OF PARADISE": 72,
649
+ "BLACK AND YELLOW BROADBILL": 73,
650
+ "BLACK BAZA": 74,
651
+ "BLACK BREASTED PUFFBIRD": 75,
652
+ "BLACK COCKATO": 76,
653
+ "BLACK FACED SPOONBILL": 77,
654
+ "BLACK FRANCOLIN": 78,
655
+ "BLACK HEADED CAIQUE": 79,
656
+ "BLACK NECKED STILT": 80,
657
+ "BLACK SKIMMER": 81,
658
+ "BLACK SWAN": 82,
659
+ "BLACK TAIL CRAKE": 83,
660
+ "BLACK THROATED BUSHTIT": 84,
661
+ "BLACK THROATED HUET": 85,
662
+ "BLACK THROATED WARBLER": 86,
663
+ "BLACK VENTED SHEARWATER": 87,
664
+ "BLACK VULTURE": 88,
665
+ "BLACK-CAPPED CHICKADEE": 89,
666
+ "BLACK-NECKED GREBE": 90,
667
+ "BLACK-THROATED SPARROW": 91,
668
+ "BLACKBURNIAM WARBLER": 92,
669
+ "BLONDE CRESTED WOODPECKER": 93,
670
+ "BLOOD PHEASANT": 94,
671
+ "BLUE COAU": 95,
672
+ "BLUE DACNIS": 96,
673
+ "BLUE GRAY GNATCATCHER": 97,
674
+ "BLUE GROSBEAK": 98,
675
+ "BLUE GROUSE": 99,
676
+ "BLUE HERON": 100,
677
+ "BLUE MALKOHA": 101,
678
+ "BLUE THROATED PIPING GUAN": 102,
679
+ "BLUE THROATED TOUCANET": 103,
680
+ "BOBOLINK": 104,
681
+ "BORNEAN BRISTLEHEAD": 105,
682
+ "BORNEAN LEAFBIRD": 106,
683
+ "BORNEAN PHEASANT": 107,
684
+ "BRANDT CORMARANT": 108,
685
+ "BREWERS BLACKBIRD": 109,
686
+ "BROWN CREPPER": 110,
687
+ "BROWN HEADED COWBIRD": 111,
688
+ "BROWN NOODY": 112,
689
+ "BROWN THRASHER": 113,
690
+ "BUFFLEHEAD": 114,
691
+ "BULWERS PHEASANT": 115,
692
+ "BURCHELLS COURSER": 116,
693
+ "BUSH TURKEY": 117,
694
+ "CAATINGA CACHOLOTE": 118,
695
+ "CABOTS TRAGOPAN": 119,
696
+ "CACTUS WREN": 120,
697
+ "CALIFORNIA CONDOR": 121,
698
+ "CALIFORNIA GULL": 122,
699
+ "CALIFORNIA QUAIL": 123,
700
+ "CAMPO FLICKER": 124,
701
+ "CANARY": 125,
702
+ "CANVASBACK": 126,
703
+ "CAPE GLOSSY STARLING": 127,
704
+ "CAPE LONGCLAW": 128,
705
+ "CAPE MAY WARBLER": 129,
706
+ "CAPE ROCK THRUSH": 130,
707
+ "CAPPED HERON": 131,
708
+ "CAPUCHINBIRD": 132,
709
+ "CARMINE BEE-EATER": 133,
710
+ "CASPIAN TERN": 134,
711
+ "CASSOWARY": 135,
712
+ "CEDAR WAXWING": 136,
713
+ "CERULEAN WARBLER": 137,
714
+ "CHARA DE COLLAR": 138,
715
+ "CHATTERING LORY": 139,
716
+ "CHESTNET BELLIED EUPHONIA": 140,
717
+ "CHESTNUT WINGED CUCKOO": 141,
718
+ "CHINESE BAMBOO PARTRIDGE": 142,
719
+ "CHINESE POND HERON": 143,
720
+ "CHIPPING SPARROW": 144,
721
+ "CHUCAO TAPACULO": 145,
722
+ "CHUKAR PARTRIDGE": 146,
723
+ "CINNAMON ATTILA": 147,
724
+ "CINNAMON FLYCATCHER": 148,
725
+ "CINNAMON TEAL": 149,
726
+ "CLARKS GREBE": 150,
727
+ "CLARKS NUTCRACKER": 151,
728
+ "COCK OF THE ROCK": 152,
729
+ "COCKATOO": 153,
730
+ "COLLARED ARACARI": 154,
731
+ "COLLARED CRESCENTCHEST": 155,
732
+ "COMMON FIRECREST": 156,
733
+ "COMMON GRACKLE": 157,
734
+ "COMMON HOUSE MARTIN": 158,
735
+ "COMMON IORA": 159,
736
+ "COMMON LOON": 160,
737
+ "COMMON POORWILL": 161,
738
+ "COMMON STARLING": 162,
739
+ "COPPERSMITH BARBET": 163,
740
+ "COPPERY TAILED COUCAL": 164,
741
+ "CRAB PLOVER": 165,
742
+ "CRANE HAWK": 166,
743
+ "CREAM COLORED WOODPECKER": 167,
744
+ "CRESTED AUKLET": 168,
745
+ "CRESTED CARACARA": 169,
746
+ "CRESTED COUA": 170,
747
+ "CRESTED FIREBACK": 171,
748
+ "CRESTED KINGFISHER": 172,
749
+ "CRESTED NUTHATCH": 173,
750
+ "CRESTED OROPENDOLA": 174,
751
+ "CRESTED SERPENT EAGLE": 175,
752
+ "CRESTED SHRIKETIT": 176,
753
+ "CRESTED WOOD PARTRIDGE": 177,
754
+ "CRIMSON CHAT": 178,
755
+ "CRIMSON SUNBIRD": 179,
756
+ "CROW": 180,
757
+ "CUBAN TODY": 181,
758
+ "CUBAN TROGON": 182,
759
+ "CURL CRESTED ARACURI": 183,
760
+ "D-ARNAUDS BARBET": 184,
761
+ "DALMATIAN PELICAN": 185,
762
+ "DARJEELING WOODPECKER": 186,
763
+ "DARK EYED JUNCO": 187,
764
+ "DAURIAN REDSTART": 188,
765
+ "DEMOISELLE CRANE": 189,
766
+ "DOUBLE BARRED FINCH": 190,
767
+ "DOUBLE BRESTED CORMARANT": 191,
768
+ "DOUBLE EYED FIG PARROT": 192,
769
+ "DOWNY WOODPECKER": 193,
770
+ "DUNLIN": 194,
771
+ "DUSKY LORY": 195,
772
+ "DUSKY ROBIN": 196,
773
+ "EARED PITA": 197,
774
+ "EASTERN BLUEBIRD": 198,
775
+ "EASTERN BLUEBONNET": 199,
776
+ "EASTERN GOLDEN WEAVER": 200,
777
+ "EASTERN MEADOWLARK": 201,
778
+ "EASTERN ROSELLA": 202,
779
+ "EASTERN TOWEE": 203,
780
+ "EASTERN WIP POOR WILL": 204,
781
+ "EASTERN YELLOW ROBIN": 205,
782
+ "ECUADORIAN HILLSTAR": 206,
783
+ "EGYPTIAN GOOSE": 207,
784
+ "ELEGANT TROGON": 208,
785
+ "ELLIOTS PHEASANT": 209,
786
+ "EMERALD TANAGER": 210,
787
+ "EMPEROR PENGUIN": 211,
788
+ "EMU": 212,
789
+ "ENGGANO MYNA": 213,
790
+ "EURASIAN BULLFINCH": 214,
791
+ "EURASIAN GOLDEN ORIOLE": 215,
792
+ "EURASIAN MAGPIE": 216,
793
+ "EUROPEAN GOLDFINCH": 217,
794
+ "EUROPEAN TURTLE DOVE": 218,
795
+ "EVENING GROSBEAK": 219,
796
+ "FAIRY BLUEBIRD": 220,
797
+ "FAIRY PENGUIN": 221,
798
+ "FAIRY TERN": 222,
799
+ "FAN TAILED WIDOW": 223,
800
+ "FASCIATED WREN": 224,
801
+ "FIERY MINIVET": 225,
802
+ "FIORDLAND PENGUIN": 226,
803
+ "FIRE TAILLED MYZORNIS": 227,
804
+ "FLAME BOWERBIRD": 228,
805
+ "FLAME TANAGER": 229,
806
+ "FOREST WAGTAIL": 230,
807
+ "FRIGATE": 231,
808
+ "FRILL BACK PIGEON": 232,
809
+ "GAMBELS QUAIL": 233,
810
+ "GANG GANG COCKATOO": 234,
811
+ "GILA WOODPECKER": 235,
812
+ "GILDED FLICKER": 236,
813
+ "GLOSSY IBIS": 237,
814
+ "GO AWAY BIRD": 238,
815
+ "GOLD WING WARBLER": 239,
816
+ "GOLDEN BOWER BIRD": 240,
817
+ "GOLDEN CHEEKED WARBLER": 241,
818
+ "GOLDEN CHLOROPHONIA": 242,
819
+ "GOLDEN EAGLE": 243,
820
+ "GOLDEN PARAKEET": 244,
821
+ "GOLDEN PHEASANT": 245,
822
+ "GOLDEN PIPIT": 246,
823
+ "GOULDIAN FINCH": 247,
824
+ "GRANDALA": 248,
825
+ "GRAY CATBIRD": 249,
826
+ "GRAY KINGBIRD": 250,
827
+ "GRAY PARTRIDGE": 251,
828
+ "GREAT ARGUS": 252,
829
+ "GREAT GRAY OWL": 253,
830
+ "GREAT JACAMAR": 254,
831
+ "GREAT KISKADEE": 255,
832
+ "GREAT POTOO": 256,
833
+ "GREAT TINAMOU": 257,
834
+ "GREAT XENOPS": 258,
835
+ "GREATER PEWEE": 259,
836
+ "GREATER PRAIRIE CHICKEN": 260,
837
+ "GREATOR SAGE GROUSE": 261,
838
+ "GREEN BROADBILL": 262,
839
+ "GREEN JAY": 263,
840
+ "GREEN MAGPIE": 264,
841
+ "GREEN WINGED DOVE": 265,
842
+ "GREY CUCKOOSHRIKE": 266,
843
+ "GREY HEADED CHACHALACA": 267,
844
+ "GREY HEADED FISH EAGLE": 268,
845
+ "GREY PLOVER": 269,
846
+ "GROVED BILLED ANI": 270,
847
+ "GUINEA TURACO": 271,
848
+ "GUINEAFOWL": 272,
849
+ "GURNEYS PITTA": 273,
850
+ "GYRFALCON": 274,
851
+ "HAMERKOP": 275,
852
+ "HARLEQUIN DUCK": 276,
853
+ "HARLEQUIN QUAIL": 277,
854
+ "HARPY EAGLE": 278,
855
+ "HAWAIIAN GOOSE": 279,
856
+ "HAWFINCH": 280,
857
+ "HELMET VANGA": 281,
858
+ "HEPATIC TANAGER": 282,
859
+ "HIMALAYAN BLUETAIL": 283,
860
+ "HIMALAYAN MONAL": 284,
861
+ "HOATZIN": 285,
862
+ "HOODED MERGANSER": 286,
863
+ "HOOPOES": 287,
864
+ "HORNED GUAN": 288,
865
+ "HORNED LARK": 289,
866
+ "HORNED SUNGEM": 290,
867
+ "HOUSE FINCH": 291,
868
+ "HOUSE SPARROW": 292,
869
+ "HYACINTH MACAW": 293,
870
+ "IBERIAN MAGPIE": 294,
871
+ "IBISBILL": 295,
872
+ "IMPERIAL SHAQ": 296,
873
+ "INCA TERN": 297,
874
+ "INDIAN BUSTARD": 298,
875
+ "INDIAN PITTA": 299,
876
+ "INDIAN ROLLER": 300,
877
+ "INDIAN VULTURE": 301,
878
+ "INDIGO BUNTING": 302,
879
+ "INDIGO FLYCATCHER": 303,
880
+ "INLAND DOTTEREL": 304,
881
+ "IVORY BILLED ARACARI": 305,
882
+ "IVORY GULL": 306,
883
+ "IWI": 307,
884
+ "JABIRU": 308,
885
+ "JACK SNIPE": 309,
886
+ "JACOBIN PIGEON": 310,
887
+ "JANDAYA PARAKEET": 311,
888
+ "JAPANESE ROBIN": 312,
889
+ "JAVA SPARROW": 313,
890
+ "JOCOTOCO ANTPITTA": 314,
891
+ "KAGU": 315,
892
+ "KAKAPO": 316,
893
+ "KILLDEAR": 317,
894
+ "KING EIDER": 318,
895
+ "KING VULTURE": 319,
896
+ "KIWI": 320,
897
+ "KNOB BILLED DUCK": 321,
898
+ "KOOKABURRA": 322,
899
+ "LARK BUNTING": 323,
900
+ "LAUGHING GULL": 324,
901
+ "LAZULI BUNTING": 325,
902
+ "LESSER ADJUTANT": 326,
903
+ "LILAC ROLLER": 327,
904
+ "LIMPKIN": 328,
905
+ "LITTLE AUK": 329,
906
+ "LOGGERHEAD SHRIKE": 330,
907
+ "LONG-EARED OWL": 331,
908
+ "LOONEY BIRDS": 332,
909
+ "LUCIFER HUMMINGBIRD": 333,
910
+ "MAGPIE GOOSE": 334,
911
+ "MALABAR HORNBILL": 335,
912
+ "MALACHITE KINGFISHER": 336,
913
+ "MALAGASY WHITE EYE": 337,
914
+ "MALEO": 338,
915
+ "MALLARD DUCK": 339,
916
+ "MANDRIN DUCK": 340,
917
+ "MANGROVE CUCKOO": 341,
918
+ "MARABOU STORK": 342,
919
+ "MASKED BOBWHITE": 343,
920
+ "MASKED BOOBY": 344,
921
+ "MASKED LAPWING": 345,
922
+ "MCKAYS BUNTING": 346,
923
+ "MERLIN": 347,
924
+ "MIKADO PHEASANT": 348,
925
+ "MILITARY MACAW": 349,
926
+ "MOURNING DOVE": 350,
927
+ "MYNA": 351,
928
+ "NICOBAR PIGEON": 352,
929
+ "NOISY FRIARBIRD": 353,
930
+ "NORTHERN BEARDLESS TYRANNULET": 354,
931
+ "NORTHERN CARDINAL": 355,
932
+ "NORTHERN FLICKER": 356,
933
+ "NORTHERN FULMAR": 357,
934
+ "NORTHERN GANNET": 358,
935
+ "NORTHERN GOSHAWK": 359,
936
+ "NORTHERN JACANA": 360,
937
+ "NORTHERN MOCKINGBIRD": 361,
938
+ "NORTHERN PARULA": 362,
939
+ "NORTHERN RED BISHOP": 363,
940
+ "NORTHERN SHOVELER": 364,
941
+ "OCELLATED TURKEY": 365,
942
+ "OILBIRD": 366,
943
+ "OKINAWA RAIL": 367,
944
+ "ORANGE BREASTED TROGON": 368,
945
+ "ORANGE BRESTED BUNTING": 369,
946
+ "ORIENTAL BAY OWL": 370,
947
+ "ORNATE HAWK EAGLE": 371,
948
+ "OSPREY": 372,
949
+ "OSTRICH": 373,
950
+ "OVENBIRD": 374,
951
+ "OYSTER CATCHER": 375,
952
+ "PAINTED BUNTING": 376,
953
+ "PALILA": 377,
954
+ "PALM NUT VULTURE": 378,
955
+ "PARADISE TANAGER": 379,
956
+ "PARAKETT AUKLET": 380,
957
+ "PARUS MAJOR": 381,
958
+ "PATAGONIAN SIERRA FINCH": 382,
959
+ "PEACOCK": 383,
960
+ "PEREGRINE FALCON": 384,
961
+ "PHAINOPEPLA": 385,
962
+ "PHILIPPINE EAGLE": 386,
963
+ "PINK ROBIN": 387,
964
+ "PLUSH CRESTED JAY": 388,
965
+ "POMARINE JAEGER": 389,
966
+ "PUFFIN": 390,
967
+ "PUNA TEAL": 391,
968
+ "PURPLE FINCH": 392,
969
+ "PURPLE GALLINULE": 393,
970
+ "PURPLE MARTIN": 394,
971
+ "PURPLE SWAMPHEN": 395,
972
+ "PYGMY KINGFISHER": 396,
973
+ "PYRRHULOXIA": 397,
974
+ "QUETZAL": 398,
975
+ "RAINBOW LORIKEET": 399,
976
+ "RAZORBILL": 400,
977
+ "RED BEARDED BEE EATER": 401,
978
+ "RED BELLIED PITTA": 402,
979
+ "RED BILLED TROPICBIRD": 403,
980
+ "RED BROWED FINCH": 404,
981
+ "RED CROSSBILL": 405,
982
+ "RED FACED CORMORANT": 406,
983
+ "RED FACED WARBLER": 407,
984
+ "RED FODY": 408,
985
+ "RED HEADED DUCK": 409,
986
+ "RED HEADED WOODPECKER": 410,
987
+ "RED KNOT": 411,
988
+ "RED LEGGED HONEYCREEPER": 412,
989
+ "RED NAPED TROGON": 413,
990
+ "RED SHOULDERED HAWK": 414,
991
+ "RED TAILED HAWK": 415,
992
+ "RED TAILED THRUSH": 416,
993
+ "RED WINGED BLACKBIRD": 417,
994
+ "RED WISKERED BULBUL": 418,
995
+ "REGENT BOWERBIRD": 419,
996
+ "RING-NECKED PHEASANT": 420,
997
+ "ROADRUNNER": 421,
998
+ "ROCK DOVE": 422,
999
+ "ROSE BREASTED COCKATOO": 423,
1000
+ "ROSE BREASTED GROSBEAK": 424,
1001
+ "ROSEATE SPOONBILL": 425,
1002
+ "ROSY FACED LOVEBIRD": 426,
1003
+ "ROUGH LEG BUZZARD": 427,
1004
+ "ROYAL FLYCATCHER": 428,
1005
+ "RUBY CROWNED KINGLET": 429,
1006
+ "RUBY THROATED HUMMINGBIRD": 430,
1007
+ "RUDDY SHELDUCK": 431,
1008
+ "RUDY KINGFISHER": 432,
1009
+ "RUFOUS KINGFISHER": 433,
1010
+ "RUFOUS TREPE": 434,
1011
+ "RUFUOS MOTMOT": 435,
1012
+ "SAMATRAN THRUSH": 436,
1013
+ "SAND MARTIN": 437,
1014
+ "SANDHILL CRANE": 438,
1015
+ "SATYR TRAGOPAN": 439,
1016
+ "SAYS PHOEBE": 440,
1017
+ "SCARLET CROWNED FRUIT DOVE": 441,
1018
+ "SCARLET FACED LIOCICHLA": 442,
1019
+ "SCARLET IBIS": 443,
1020
+ "SCARLET MACAW": 444,
1021
+ "SCARLET TANAGER": 445,
1022
+ "SHOEBILL": 446,
1023
+ "SHORT BILLED DOWITCHER": 447,
1024
+ "SMITHS LONGSPUR": 448,
1025
+ "SNOW GOOSE": 449,
1026
+ "SNOW PARTRIDGE": 450,
1027
+ "SNOWY EGRET": 451,
1028
+ "SNOWY OWL": 452,
1029
+ "SNOWY PLOVER": 453,
1030
+ "SNOWY SHEATHBILL": 454,
1031
+ "SORA": 455,
1032
+ "SPANGLED COTINGA": 456,
1033
+ "SPLENDID WREN": 457,
1034
+ "SPOON BILED SANDPIPER": 458,
1035
+ "SPOTTED CATBIRD": 459,
1036
+ "SPOTTED WHISTLING DUCK": 460,
1037
+ "SQUACCO HERON": 461,
1038
+ "SRI LANKA BLUE MAGPIE": 462,
1039
+ "STEAMER DUCK": 463,
1040
+ "STORK BILLED KINGFISHER": 464,
1041
+ "STRIATED CARACARA": 465,
1042
+ "STRIPED OWL": 466,
1043
+ "STRIPPED MANAKIN": 467,
1044
+ "STRIPPED SWALLOW": 468,
1045
+ "SUNBITTERN": 469,
1046
+ "SUPERB STARLING": 470,
1047
+ "SURF SCOTER": 471,
1048
+ "SWINHOES PHEASANT": 472,
1049
+ "TAILORBIRD": 473,
1050
+ "TAIWAN MAGPIE": 474,
1051
+ "TAKAHE": 475,
1052
+ "TASMANIAN HEN": 476,
1053
+ "TAWNY FROGMOUTH": 477,
1054
+ "TEAL DUCK": 478,
1055
+ "TIT MOUSE": 479,
1056
+ "TOUCHAN": 480,
1057
+ "TOWNSENDS WARBLER": 481,
1058
+ "TREE SWALLOW": 482,
1059
+ "TRICOLORED BLACKBIRD": 483,
1060
+ "TROPICAL KINGBIRD": 484,
1061
+ "TRUMPTER SWAN": 485,
1062
+ "TURKEY VULTURE": 486,
1063
+ "TURQUOISE MOTMOT": 487,
1064
+ "UMBRELLA BIRD": 488,
1065
+ "VARIED THRUSH": 489,
1066
+ "VEERY": 490,
1067
+ "VENEZUELIAN TROUPIAL": 491,
1068
+ "VERDIN": 492,
1069
+ "VERMILION FLYCATHER": 493,
1070
+ "VICTORIA CROWNED PIGEON": 494,
1071
+ "VIOLET BACKED STARLING": 495,
1072
+ "VIOLET CUCKOO": 496,
1073
+ "VIOLET GREEN SWALLOW": 497,
1074
+ "VIOLET TURACO": 498,
1075
+ "VISAYAN HORNBILL": 499,
1076
+ "VULTURINE GUINEAFOWL": 500,
1077
+ "WALL CREAPER": 501,
1078
+ "WATTLED CURASSOW": 502,
1079
+ "WATTLED LAPWING": 503,
1080
+ "WHIMBREL": 504,
1081
+ "WHITE BREASTED WATERHEN": 505,
1082
+ "WHITE BROWED CRAKE": 506,
1083
+ "WHITE CHEEKED TURACO": 507,
1084
+ "WHITE CRESTED HORNBILL": 508,
1085
+ "WHITE EARED HUMMINGBIRD": 509,
1086
+ "WHITE NECKED RAVEN": 510,
1087
+ "WHITE TAILED TROPIC": 511,
1088
+ "WHITE THROATED BEE EATER": 512,
1089
+ "WILD TURKEY": 513,
1090
+ "WILLOW PTARMIGAN": 514,
1091
+ "WILSONS BIRD OF PARADISE": 515,
1092
+ "WOOD DUCK": 516,
1093
+ "WOOD THRUSH": 517,
1094
+ "WOODLAND KINGFISHER": 518,
1095
+ "WRENTIT": 519,
1096
+ "YELLOW BELLIED FLOWERPECKER": 520,
1097
+ "YELLOW BREASTED CHAT": 521,
1098
+ "YELLOW CACIQUE": 522,
1099
+ "YELLOW HEADED BLACKBIRD": 523,
1100
+ "ZEBRA DOVE": 524
1101
+ },
1102
+ "model_type": "efficientnet",
1103
+ "num_block_repeats": [
1104
+ 1,
1105
+ 2,
1106
+ 2,
1107
+ 3,
1108
+ 3,
1109
+ 4,
1110
+ 1
1111
+ ],
1112
+ "num_channels": 3,
1113
+ "num_hidden_layers": 64,
1114
+ "out_channels": [
1115
+ 16,
1116
+ 24,
1117
+ 40,
1118
+ 80,
1119
+ 112,
1120
+ 192,
1121
+ 320
1122
+ ],
1123
+ "pooling_type": "mean",
1124
+ "squeeze_expansion_ratio": 0.25,
1125
+ "strides": [
1126
+ 1,
1127
+ 2,
1128
+ 2,
1129
+ 2,
1130
+ 1,
1131
+ 2,
1132
+ 1
1133
+ ],
1134
+ "torch_dtype": "float32",
1135
+ "transformers_version": "4.33.0",
1136
+ "width_coefficient": 1.1
1137
+ }
birds-classifier-efficientnetb2/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:22638ea5e4d128de83610863180aec15cab1e141090bd6170520cfee76c2cf17
3
+ size 34099540
birds-classifier-efficientnetb2/preprocessor_config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "crop_size": {
3
+ "height": 289,
4
+ "width": 289
5
+ },
6
+ "do_center_crop": false,
7
+ "do_normalize": true,
8
+ "do_rescale": true,
9
+ "do_resize": true,
10
+ "image_mean": [
11
+ 0.485,
12
+ 0.456,
13
+ 0.406
14
+ ],
15
+ "image_processor_type": "EfficientNetImageProcessor",
16
+ "image_std": [
17
+ 0.47853944,
18
+ 0.4732864,
19
+ 0.47434163
20
+ ],
21
+ "include_top": true,
22
+ "resample": 0,
23
+ "rescale_factor": 0.00392156862745098,
24
+ "rescale_offset": false,
25
+ "size": {
26
+ "height": 260,
27
+ "width": 260
28
+ }
29
+ }
main.py ADDED
@@ -0,0 +1,342 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pip install fastapi ###for fastapi
2
+ #pip install uvicorn ###for server. to run the api serice from terminal: uvicorn main:app --reload
3
+ #pip install gunicorn ###gunicorn --bind 0.0.0.0:8000 -k uvicorn.workers.UvicornWorker main:app
4
+ #pip install python-multipart ###for UploadFile
5
+ #pip install pillow ###for PIL
6
+ #pip install transformers ###for transformers
7
+ #pip install torch ###for torch
8
+ #pip install sentencepiece ###for AutoTokenizer
9
+ #pip install -U cos-python-sdk-v5 ###腾讯云对象存储SDK(COS-SDK)
10
+
11
+ from typing import Optional
12
+ from fastapi import FastAPI, Header
13
+ from PIL import Image
14
+ #from transformers import pipeline, EfficientNetImageProcessor, EfficientNetForImageClassification, AutoTokenizer, AutoModelForSeq2SeqLM
15
+ import torch
16
+ from transformers import EfficientNetImageProcessor, EfficientNetForImageClassification, pipeline
17
+ from models import ItemInHistory, ItemUploaded, ServiceLoginInfo
18
+ from openai import OpenAI
19
+
20
+ from qcloud_cos import CosConfig, CosS3Client
21
+ import sys, os, logging
22
+ import urllib.parse as urlparse
23
+ import json, requests
24
+
25
+ # class Conversation:
26
+ # def __init__(self, openai_client: OpenAI, prompt, num_of_round):
27
+ # self.openai_client = openai_client
28
+ # self.prompt = prompt
29
+ # self.num_of_round = num_of_round
30
+ # self.messages = []
31
+ # self.messages.append({"role": "system", "content": self.prompt})
32
+
33
+ # def ask(self, question):
34
+ # message = ''
35
+ # num_of_tokens = 0
36
+ # try:
37
+ # self.messages.append( {"role": "user", "content": question})
38
+ # chat_completion = self.openai_client.chat.completions.create(
39
+ # model="gpt-3.5-turbo",
40
+ # messages=self.messages,
41
+ # temperature=0.5,
42
+ # max_tokens=2048,
43
+ # top_p=1,
44
+ # )
45
+ # message = chat_completion.choices[0].message.content
46
+ # # num_of_tokens = chat_completion.usage.total_tokens
47
+ # self.messages.append({"role": "assistant", "content": message})
48
+
49
+ # except Exception as e:
50
+ # print(e)
51
+ # return e
52
+
53
+ # if len(self.messages) > self.num_of_round*2 + 1:
54
+ # del self.messages[1:3]
55
+ # return message, num_of_tokens
56
+
57
+
58
+ app = FastAPI()
59
+ logging.basicConfig(level=logging.INFO, stream=sys.stdout)
60
+
61
+ cos_secret_id = os.environ['COS_SECRET_ID']
62
+ cos_secret_key = os.environ['COS_SECRET_KEY']
63
+ cos_region = 'ap-shanghai'
64
+ cos_bucket = '7072-prod-3g52ms9o7a81f23c-1324125412'
65
+ token = None
66
+ scheme = 'https'
67
+ config = CosConfig(Region=cos_region, SecretId=cos_secret_id, SecretKey=cos_secret_key, Token=token, Scheme=scheme)
68
+ client = CosS3Client(config)
69
+ logging.info(f"COS init succeeded.")
70
+
71
+
72
+ try:
73
+ ai_model_bc_preprocessor = EfficientNetImageProcessor.from_pretrained("./birds-classifier-efficientnetb2")
74
+ ai_model_bc_model = EfficientNetForImageClassification.from_pretrained("./birds-classifier-efficientnetb2")
75
+ logging.info(f"local model dennisjooo/Birds-Classifier-EfficientNetB2 loaded.")
76
+
77
+ except Exception as e:
78
+ logging.error(e)
79
+
80
+ try:
81
+ openai_client = OpenAI(
82
+ api_key=os.environ.get("OPENAI_API_KEY"),
83
+ )
84
+ # prompt = """你是一个鸟类学家,用中文回答关于鸟类的问题。你的回答需要满足以下要求:
85
+ # 1. 你的回答必须是中文
86
+ # 2. 回答限制在100个字以内"""
87
+ # conv = Conversation(open_client, prompt, 3)
88
+ logging.info(f"openai chat model loaded.")
89
+ except Exception as e:
90
+ logging.error(e)
91
+
92
+ try:
93
+ ai_model_bc_pipe= pipeline("image-classification", model="dennisjooo/Birds-Classifier-EfficientNetB2")
94
+ logging.info(f"remote model dennisjooo/Birds-Classifier-EfficientNetB2 loaded.")
95
+
96
+ except Exception as e:
97
+ print(e)
98
+
99
+ #try:
100
+ # ai_model_ez_preprocessor = AutoTokenizer.from_pretrained("./opus-mt-en-zh")
101
+ # ai_model_ez_model = AutoModelForSeq2SeqLM.from_pretrained("./opus-mt-en-zh")
102
+ # print(f"local model Helsinki-NLP/opus-mt-en-zh loaded.")
103
+ #except Exception as e:
104
+ # print(e)
105
+
106
+ #try:
107
+ # ai_model_ez_pipe= pipeline(task="translation_en_to_zh", model="Helsinki-NLP/opus-mt-en-zh", device=0)
108
+ # print(f"remote model Helsinki-NLP/opus-mt-en-zh loaded.")
109
+
110
+ #except Exception as e:
111
+ # print(e)
112
+
113
+ def bird_classifier(image_file: str) -> str:
114
+ # Opening the image using PIL
115
+ img = Image.open(image_file)
116
+ logging.info(f"image file {image_file} is opened.")
117
+
118
+ result:str = ""
119
+ try:
120
+ inputs = ai_model_bc_preprocessor(img, return_tensors="pt")
121
+
122
+ # Running the inference
123
+ with torch.no_grad():
124
+ logits = ai_model_bc_model(**inputs).logits
125
+
126
+ # Getting the predicted label
127
+ predicted_label = logits.argmax(-1).item()
128
+ result = ai_model_bc_model.config.id2label[predicted_label]
129
+ logging.info(f"{ai_model_bc_model.config.id2label[predicted_label]}:{ai_model_bc_pipe(img)[0]['label']}")
130
+ except Exception as e:
131
+ logging.error(e)
132
+
133
+
134
+ logging.info(result)
135
+ return result
136
+
137
+ # def text_en_zh(text_en: str) -> str:
138
+ # text_zh = ""
139
+ # if ai_model_ez_status is MODEL_STATUS.LOCAL:
140
+ # input = ai_model_ez_preprocessor(text_en)
141
+ # translated = ai_model_ez_model.generate(**ai_model_ez_preprocessor(text_en, return_tensors="pt", padding=True))
142
+ # for t in translated:
143
+ # text_zh += ai_model_ez_preprocessor.decode(t, skip_special_tokens=True)
144
+ # elif ai_model_ez_status is MODEL_STATUS.REMOTE:
145
+ # text_zh = ai_model_ez_pipe(text_en)
146
+
147
+ # return text_zh
148
+
149
+ # Route to upload a file
150
+ # @app.post("/uploadfile/")
151
+ # async def create_upload_file(file: UploadFile):
152
+ # contents: bytes = await file.read()
153
+ # contents_len = len(contents)
154
+ # file_name = file.filename
155
+ # server_file_name = f"server-{file_name}"
156
+ # with open(server_file_name,"wb") as server_file:
157
+ # server_file.write(contents)
158
+
159
+ # logging.info(f"{file_name} is received and saved as {server_file_name}.")
160
+
161
+ # bird_classification = bird_classifier(server_file_name)
162
+
163
+ # # if bird_classification != "":
164
+ # # bird_classification = "the species of bird is " + bird_classification
165
+ # # bird_classification = text_en_zh(bird_classification)
166
+
167
+ # logging.info(f"AI feedback: {bird_classification}.")
168
+
169
+ # return {"filename": server_file_name, "AI feedback": bird_classification}
170
+
171
+ # Route to login to zhizhi-service
172
+ @app.post("/login/")
173
+ def service_login(item: ServiceLoginInfo):
174
+ logging.info("service_login")
175
+ logging.info(item)
176
+
177
+ code2Session = f"http://api.weixin.qq.com/sns/jscode2session?appid={item.appid}&secret={item.secret}&js_code={item.js_code}&grant_type={item.grant_type}"
178
+ logging.info(code2Session)
179
+
180
+ response = requests.get(code2Session)
181
+ json_response = response.json()
182
+ logging.info(json_response)
183
+
184
+ return {"user_openid": json_response.get("openid")}
185
+
186
+ # Route to create an item
187
+ @app.post("/items/")
188
+ async def create_item(item: ItemUploaded, x_wx_openid: Optional[str]=Header(None)):
189
+ logging.info("create_item")
190
+ logging.info(item)
191
+ logging.info(x_wx_openid)
192
+
193
+ if x_wx_openid is None:
194
+ x_wx_openid = ""
195
+
196
+ url = urlparse.urlparse(item.item_fileurl)
197
+ key = url[2][1::]
198
+ bucket = url[1].split('.')[1]
199
+ contentfile = key.split('/')[1]
200
+ historyid = contentfile.split('.')[0]
201
+ # historyfile = f'{historyid}.json'
202
+
203
+ response = client.get_object(
204
+ Bucket = bucket,
205
+ Key = key
206
+ )
207
+ response['Body'].get_stream_to_file(contentfile)
208
+ if item.item_mediatype == "image":
209
+ bird_classification = bird_classifier(contentfile)
210
+ try:
211
+ # question = f"鸟类的英文名是{bird_classification},它的中文名是什么?有什么样的习性?"
212
+ # answer, num_of_tokens = conv.ask(question)
213
+ # logging.info(f"chatgpt feedback: {answer}.\n")
214
+
215
+ prompt = """你是一个鸟类学家,用中文回答关于鸟类的问题。你的回答需要满足以下要求:
216
+ 1. 你的回答必须是中文
217
+ 2. 回答限制在100个字以内"""
218
+
219
+ messages = []
220
+ messages.append({"role": "system", "content": prompt})
221
+ question = f"鸟类的英文名是{bird_classification},它的中文名是什么?有什么样的习性?"
222
+ messages.append( {"role": "user", "content": question})
223
+ chat_completion = openai_client.chat.completions.create(
224
+ model="gpt-3.5-turbo",
225
+ messages=messages,
226
+ temperature=0.5,
227
+ max_tokens=2048,
228
+ top_p=1,
229
+ )
230
+ response = chat_completion.choices[0].message.content
231
+ logging.info(f"chatgpt feedback: {response}.\n")
232
+
233
+ except Exception as e:
234
+ logging.error(e)
235
+ else:
236
+ bird_classification = "不是image类型,暂不能识别"
237
+
238
+ logging.info(f"AI feedback: {bird_classification}.\n")
239
+
240
+ historyfile = itemToJsonFile(ItemInHistory(history_id = historyid,union_id = x_wx_openid,
241
+ item_fileurl = item.item_fileurl,item_mediatype = item.item_mediatype,
242
+ upload_datetime = item.upload_datetime,ai_feedback = bird_classification))
243
+
244
+ response = client.upload_file(
245
+ Bucket = cos_bucket,
246
+ LocalFilePath=historyfile,
247
+ Key=f'{x_wx_openid}/history/{historyfile}',
248
+ PartSize=1,
249
+ MAXThread=10,
250
+ EnableMD5=False
251
+ )
252
+ logging.info(response['ETag'])
253
+
254
+
255
+ return {"filename": historyfile, "AI feedback": bird_classification}
256
+
257
+ # Route to list all items uploaded by a specific user by unionid
258
+ # @app.get("/items/{user_unionid}")
259
+ # def list_items(user_unionid: str) -> dict[str, list[ItemInHistory]]:
260
+ # logging.info("list_items")
261
+ # logging.info(user_unionid)
262
+
263
+ # items: list[ItemInHistory] = []
264
+
265
+ # response = client.list_objects(
266
+ # Bucket=cos_bucket,
267
+ # Prefix=f'{user_unionid}/history/'
268
+ # )
269
+
270
+ # logging.info(response['Contents'])
271
+
272
+ # for obj in response['Contents']:
273
+ # key:str = obj['Key']
274
+ # response = client.get_object(
275
+ # Bucket = cos_bucket,
276
+ # Key = key
277
+ # )
278
+ # localfile = key.split('/')[2]
279
+ # response['Body'].get_stream_to_file(localfile)
280
+
281
+ # item = itemFromJsonFile(localfile)
282
+ # items.append(item)
283
+
284
+ return {"items": items}
285
+
286
+ # Route to list all items uploaded by a specific user by unionid from header
287
+ @app.get("/items/")
288
+ def list_items_byheader(x_wx_openid: Optional[str]=Header(None)) -> dict[str, list[ItemInHistory]]:
289
+ logging.info("list_items_byheader")
290
+ logging.info(x_wx_openid)
291
+
292
+ items: list[ItemInHistory] = []
293
+
294
+ response = client.list_objects(
295
+ Bucket=cos_bucket,
296
+ Prefix=f'{x_wx_openid}/history/'
297
+ )
298
+
299
+ logging.info(response['Contents'])
300
+
301
+ for obj in response['Contents']:
302
+ key:str = obj['Key']
303
+ response = client.get_object(
304
+ Bucket = cos_bucket,
305
+ Key = key
306
+ )
307
+ localfile = key.split('/')[2]
308
+ response['Body'].get_stream_to_file(localfile)
309
+
310
+ item = itemFromJsonFile(localfile)
311
+ items.append(item)
312
+
313
+ return {"items": items}
314
+
315
+
316
+ def itemFromJsonFile(jsonfile: str) -> ItemInHistory:
317
+ f = open(jsonfile, 'r')
318
+ content = f.read()
319
+ a = json.loads(content)
320
+ f.close()
321
+ return ItemInHistory(history_id = a['history_id'],union_id = a['union_id'],
322
+ item_fileurl = a['item_fileurl'],item_mediatype = a["item_mediatype"],
323
+ upload_datetime = a["upload_datetime"],ai_feedback = a['ai_feedback'])
324
+
325
+
326
+ def itemToJsonFile(item: ItemInHistory):
327
+ history_json = {
328
+ "history_id": item.history_id,
329
+ "union_id": item.union_id,
330
+ "item_fileurl": item.item_fileurl,
331
+ "item_mediatype": item.item_mediatype,
332
+ "upload_datetime": item.upload_datetime,
333
+ "ai_feedback": item.ai_feedback
334
+ }
335
+ b = json.dumps(history_json)
336
+ historyfile = f'{item.history_id}.json'
337
+ f = open(historyfile, 'w')
338
+ f.write(b)
339
+ f.close()
340
+
341
+ return historyfile
342
+
models.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ctypes import Union
2
+ from typing import Optional
3
+ from pydantic import BaseModel, Field
4
+ import json
5
+
6
+ class ItemUploaded(BaseModel):
7
+ union_id: str = Field(title="the user unionid of the item uploaded",examples=["oR_-n69II04mrTuFOFyqiAt_Wgbk"])
8
+ item_fileurl: str = Field(title="the file url of the item uploaded",examples=["cloud://prod-3g52ms9o7a81f23c.7072-prod-3g52ms9o7a81f23c-1324125412/oR_-n69II04mrTuFOFyqiAt_Wgbk/202402022042282841.jpg"])
9
+ item_mediatype: str = Field(title="the media type of the item uploaded",examples=["image"])
10
+ upload_datetime: str = Field(title="the upload datetime of the item uploaded",examples=["2024-2-1 17:20:18"])
11
+
12
+ class ItemInHistory(BaseModel):
13
+ history_id: str = Field(title="the unique id of the item in history",examples=["20240131003701985"])
14
+ union_id: str = Field(title="the user unionid of the item in history",examples=["oR_-n69II04mrTuFOFyqiAt_Wgbk"])
15
+ item_fileurl: str = Field(title="the file url of the item in history",examples=["cloud://prod-3g52ms9o7a81f23c.7072-prod-3g52ms9o7a81f23c-1324125412/oR_-n69II04mrTuFOFyqiAt_Wgbk/20240131003701985.jpg"])
16
+ item_mediatype: str = Field(title="the media type of the item in history",examples=["image"])
17
+ upload_datetime: str = Field(title="the upload datetime of the item in history",examples=["2024-2-1 17:20:18"])
18
+ ai_feedback: str = Field(title="the ai feedback to the item in history",examples=["AZARAS SPINETAIL"])
19
+
20
+ class ServiceLoginInfo(BaseModel):
21
+ appid: str = Field(title="appid of wx miniprogram",examples=[""])
22
+ secret: str = Field(title="secret of wx miniprogram",examples=[""])
23
+ js_code: str = Field(title="res.code return from wx.login()",examples=[""])
24
+ grant_type: str = Field(title="grant_type = authorization_code",examples=["authorization_code"])
requirements.txt ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ annotated-types==0.6.0
2
+ anyio==4.2.0
3
+ certifi==2023.11.17
4
+ charset-normalizer==3.3.2
5
+ click==8.1.7
6
+ cos-python-sdk-v5==1.9.27
7
+ crcmod==1.7
8
+ distro==1.9.0
9
+ fastapi==0.109.0
10
+ filelock==3.13.1
11
+ fsspec==2023.12.2
12
+ gunicorn==21.2.0
13
+ h11==0.14.0
14
+ httpcore==1.0.2
15
+ httpx==0.26.0
16
+ huggingface-hub==0.20.3
17
+ idna==3.6
18
+ iniconfig==2.0.0
19
+ Jinja2==3.1.3
20
+ MarkupSafe==2.1.4
21
+ mpmath==1.3.0
22
+ networkx==3.2.1
23
+ numpy==1.26.3
24
+ openai==1.10.0
25
+ packaging==23.2
26
+ pillow==10.2.0
27
+ pluggy==1.4.0
28
+ pycryptodome==3.20.0
29
+ pydantic==2.5.3
30
+ pydantic_core==2.14.6
31
+ pytest==8.0.0
32
+ python-multipart==0.0.6
33
+ PyYAML==6.0.1
34
+ regex==2023.12.25
35
+ requests==2.31.0
36
+ safetensors==0.4.2
37
+ six==1.16.0
38
+ sniffio==1.3.0
39
+ starlette==0.35.1
40
+ sympy==1.12
41
+ tokenizers==0.15.1
42
+ torch==2.1.2
43
+ tqdm==4.66.1
44
+ transformers==4.37.1
45
+ typing_extensions==4.9.0
46
+ urllib3==2.1.0
47
+ uvicorn==0.27.0
48
+ xmltodict==0.13.0