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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
---
dataset_info:
  features:
  - name: label
    dtype:
      class_label:
        names:
          '0': The Eiffel Tower
          '1': The Great Wall of China
          '2': The Mona Lisa
          '3': aircraft carrier
          '4': airplane
          '5': alarm clock
          '6': ambulance
          '7': angel
          '8': animal migration
          '9': ant
          '10': anvil
          '11': apple
          '12': arm
          '13': asparagus
          '14': axe
          '15': backpack
          '16': banana
          '17': bandage
          '18': barn
          '19': baseball
          '20': baseball bat
          '21': basket
          '22': basketball
          '23': bat
          '24': bathtub
          '25': beach
          '26': bear
          '27': beard
          '28': bed
          '29': bee
          '30': belt
          '31': bench
          '32': bicycle
          '33': binoculars
          '34': bird
          '35': birthday cake
          '36': blackberry
          '37': blueberry
          '38': book
          '39': boomerang
          '40': bottlecap
          '41': bowtie
          '42': bracelet
          '43': brain
          '44': bread
          '45': bridge
          '46': broccoli
          '47': broom
          '48': bucket
          '49': bulldozer
          '50': bus
          '51': bush
          '52': butterfly
          '53': cactus
          '54': cake
          '55': calculator
          '56': calendar
          '57': camel
          '58': camera
          '59': camouflage
          '60': campfire
          '61': candle
          '62': cannon
          '63': canoe
          '64': car
          '65': carrot
          '66': castle
          '67': cat
          '68': ceiling fan
          '69': cell phone
          '70': cello
          '71': chair
          '72': chandelier
          '73': church
          '74': circle
          '75': clarinet
          '76': clock
          '77': cloud
          '78': coffee cup
          '79': compass
          '80': computer
          '81': cookie
          '82': cooler
          '83': couch
          '84': cow
          '85': crab
          '86': crayon
          '87': crocodile
          '88': crown
          '89': cruise ship
          '90': cup
          '91': diamond
          '92': dishwasher
          '93': diving board
          '94': dog
          '95': dolphin
          '96': donut
          '97': door
          '98': dragon
          '99': dresser
          '100': drill
          '101': drums
          '102': duck
          '103': dumbbell
          '104': ear
          '105': elbow
          '106': elephant
          '107': envelope
          '108': eraser
          '109': eye
          '110': eyeglasses
          '111': face
          '112': fan
          '113': feather
          '114': fence
          '115': finger
          '116': fire hydrant
          '117': fireplace
          '118': firetruck
          '119': fish
          '120': flamingo
          '121': flashlight
          '122': flip flops
          '123': floor lamp
          '124': flower
          '125': flying saucer
          '126': foot
          '127': fork
          '128': frog
          '129': frying pan
          '130': garden
          '131': garden hose
          '132': giraffe
          '133': goatee
          '134': golf club
          '135': grapes
          '136': grass
          '137': guitar
          '138': hamburger
          '139': hammer
          '140': hand
          '141': harp
          '142': hat
          '143': headphones
          '144': hedgehog
          '145': helicopter
          '146': helmet
          '147': hexagon
          '148': hockey puck
          '149': hockey stick
          '150': horse
          '151': hospital
          '152': hot air balloon
          '153': hot dog
          '154': hot tub
          '155': hourglass
          '156': house
          '157': house plant
          '158': hurricane
          '159': ice cream
          '160': jacket
          '161': jail
          '162': kangaroo
          '163': key
          '164': keyboard
          '165': knee
          '166': knife
          '167': ladder
          '168': lantern
          '169': laptop
          '170': leaf
          '171': leg
          '172': light bulb
          '173': lighter
          '174': lighthouse
          '175': lightning
          '176': line
          '177': lion
          '178': lipstick
          '179': lobster
          '180': lollipop
          '181': mailbox
          '182': map
          '183': marker
          '184': matches
          '185': megaphone
          '186': mermaid
          '187': microphone
          '188': microwave
          '189': monkey
          '190': moon
          '191': mosquito
          '192': motorbike
          '193': mountain
          '194': mouse
          '195': moustache
          '196': mouth
          '197': mug
          '198': mushroom
          '199': nail
          '200': necklace
          '201': nose
          '202': ocean
          '203': octagon
          '204': octopus
          '205': onion
          '206': oven
          '207': owl
          '208': paint can
          '209': paintbrush
          '210': palm tree
          '211': panda
          '212': pants
          '213': paper clip
          '214': parachute
          '215': parrot
          '216': passport
          '217': peanut
          '218': pear
          '219': peas
          '220': pencil
          '221': penguin
          '222': piano
          '223': pickup truck
          '224': picture frame
          '225': pig
          '226': pillow
          '227': pineapple
          '228': pizza
          '229': pliers
          '230': police car
          '231': pond
          '232': pool
          '233': popsicle
          '234': postcard
          '235': potato
          '236': power outlet
          '237': purse
          '238': rabbit
          '239': raccoon
          '240': radio
          '241': rain
          '242': rainbow
          '243': rake
          '244': remote control
          '245': rhinoceros
          '246': rifle
          '247': river
          '248': roller coaster
          '249': rollerskates
          '250': sailboat
          '251': sandwich
          '252': saw
          '253': saxophone
          '254': school bus
          '255': scissors
          '256': scorpion
          '257': screwdriver
          '258': sea turtle
          '259': see saw
          '260': shark
          '261': sheep
          '262': shoe
          '263': shorts
          '264': shovel
          '265': sink
          '266': skateboard
          '267': skull
          '268': skyscraper
          '269': sleeping bag
          '270': smiley face
          '271': snail
          '272': snake
          '273': snorkel
          '274': snowflake
          '275': snowman
          '276': soccer ball
          '277': sock
          '278': speedboat
          '279': spider
          '280': spoon
          '281': spreadsheet
          '282': square
          '283': squiggle
          '284': squirrel
          '285': stairs
          '286': star
          '287': steak
          '288': stereo
          '289': stethoscope
          '290': stitches
          '291': stop sign
          '292': stove
          '293': strawberry
          '294': streetlight
          '295': string bean
          '296': submarine
          '297': suitcase
          '298': sun
          '299': swan
          '300': sweater
          '301': swing set
          '302': sword
          '303': syringe
          '304': t-shirt
          '305': table
          '306': teapot
          '307': teddy-bear
          '308': telephone
          '309': television
          '310': tennis racquet
          '311': tent
          '312': tiger
          '313': toaster
          '314': toe
          '315': toilet
          '316': tooth
          '317': toothbrush
          '318': toothpaste
          '319': tornado
          '320': tractor
          '321': traffic light
          '322': train
          '323': tree
          '324': triangle
          '325': trombone
          '326': truck
          '327': trumpet
          '328': umbrella
          '329': underwear
          '330': van
          '331': vase
          '332': violin
          '333': washing machine
          '334': watermelon
          '335': waterslide
          '336': whale
          '337': wheel
          '338': windmill
          '339': wine bottle
          '340': wine glass
          '341': wristwatch
          '342': yoga
          '343': zebra
          '344': zigzag
  - name: packed_drawing
    dtype: binary
  splits:
  - name: train
    num_bytes: 5196066788.157136
    num_examples: 40341012
  - name: test
    num_bytes: 1299016825.8428645
    num_examples: 10085254
  download_size: 6290637578
  dataset_size: 6495083614.0
---
# Quick!Draw! Dataset (per-row bin format)

This is the full 50M-row dataset from [QuickDraw! dataset](https://github.com/googlecreativelab/quickdraw-dataset).  The row for each drawing contains a byte-encoded packed representation of the drawing and data, which you can unpack using the following snippet:

```
def unpack_drawing(file_handle):
    key_id, = unpack('Q', file_handle.read(8))
    country_code, = unpack('2s', file_handle.read(2))
    recognized, = unpack('b', file_handle.read(1))
    timestamp, = unpack('I', file_handle.read(4))
    n_strokes, = unpack('H', file_handle.read(2))
    image = []
    n_bytes = 17
    for i in range(n_strokes):
        n_points, = unpack('H', file_handle.read(2))
        fmt = str(n_points) + 'B'
        x = unpack(fmt, file_handle.read(n_points))
        y = unpack(fmt, file_handle.read(n_points))
        image.append((x, y))
        n_bytes += 2 + 2*n_points
    result = {
        'key_id': key_id,
        'country_code': country_code,
        'recognized': recognized,
        'timestamp': timestamp,
        'image': image,
    }
    return result
```

The `image` in the above is still in line vector format.  To convert render this to a raster image (I recommend you do this on-the-fly in a pre-processor):

```
# packed bin -> RGB PIL
def binToPIL(packed_drawing):
    padding = 8
    radius = 7
    scale = (224.0-(2*padding)) / 256
    
    unpacked = unpack_drawing(io.BytesIO(packed_drawing))
    unpacked_image = unpacked['image']
    image = np.full((224,224), 255, np.uint8)
    for stroke in unpacked['image']:
        prevX = round(stroke[0][0]*scale)
        prevY = round(stroke[1][0]*scale)
        for i in range(1, len(stroke[0])):
            x = round(stroke[0][i]*scale)
            y = round(stroke[1][i]*scale)
            cv2.line(image, (padding+prevX, padding+prevY), (padding+x, padding+y), 0, radius, -1)
            prevX = x
            prevY = y
    pilImage = Image.fromarray(image).convert("RGB")     
    return pilImage
```