Quick Draw is a drawing game which is training a neural network to recognise doodles.
quickdraw
is an API for accessing the Quick Draw data - it downloads the data files as and when needed, caches them locally and interprets them so they can be used.
Created by Martin O'Hanlon (@martinohanlon, stuffaboutco.de).
Install the quickdraw python library using pip.
- Windows
pip install quickdraw
- macOS
pip3 install quickdraw
- Linux / Raspberry Pi
sudo pip3 install quickdraw
Here are some examples of how to use quickdraw
but be sure to also checkout the API documentation for more information.
Open the Quick Draw data using QuickDrawData and pull back a drawing of an anvil.
from quickdraw import QuickDrawData
qd = QuickDrawData()
anvil = qd.get_drawing("anvil")
print(anvil)
quickdraw
will download the anvil.bin
data file and return the data for a random drawing of an anvil (well a doodle of an anvil anyway).
Drawings are returned as QuickDrawing objects which exposes the properties of the drawing.
print(anvil.name)
print(anvil.key_id)
print(anvil.countrycode)
print(anvil.recognized)
print(anvil.timestamp)
print(anvil.no_of_strokes)
print(anvil.image_data)
print(anvil.strokes)
You can save the drawing using the image
property.
anvil.image.save("my_anvil.gif")
You can open a group of Quick Draw drawings using QuickDrawDataGroup passing the name of the drawing ("anvil", "aircraft", "baseball", etc).
from quickdraw import QuickDrawDataGroup
anvils = QuickDrawDataGroup("anvil")
print(anvils.drawing_count)
print(anvils.get_drawing())
By default only 1000 drawings are opened, you can change this by modifying the max_drawings
parameter of QuickDrawDataGroup, setting it to None
will open all the drawings in that group.
from quickdraw import QuickDrawDataGroup
anvils = QuickDrawDataGroup("anvil", max_drawings=None)
print(anvils.drawing_count)
To iterate through all the drawings in a group use the drawings generator.
from quickdraw import QuickDrawDataGroup
qdg = QuickDrawDataGroup("anvil")
for drawing in qdg.drawings:
print(drawing)
You can get a list of all the drawing names using the drawing_names property of QuickDrawData.
from quickdraw import QuickDrawData
qd = QuickDrawData()
print(qd.drawing_names)
Code examples can be found in the quickdraw GitHub repository.
API documentation can be found at quickdraw.readthedocs.io
The drawings have been moderated but there is no guarantee it'll actually be a picture of what you are asking it for (although in my experience they are)!
Beta - stable, under active dev, the API may change.