Skip to content

Commit a3fb797

Browse files
committed
Finish readme
1 parent a3577db commit a3fb797

File tree

1 file changed

+90
-5
lines changed

1 file changed

+90
-5
lines changed

datasets/quickdraw/README.md

Lines changed: 90 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ The `sketch_rnn_full` configuration stores the data in the format suitable for i
166166
<summary>
167167
Click here to see the full class labels mapping:
168168
</summary>
169+
169170
|id|class|
170171
|---|---|
171172
|0|aircraft carrier|
@@ -513,28 +514,99 @@ The `sketch_rnn_full` configuration stores the data in the format suitable for i
513514
|342|yoga|
514515
|343|zebra|
515516
|344|zigzag|
517+
516518
</details>
517519

518520
#### `sketch_rnn` and `sketch_rnn_full`
519521

520522
- `word`: Category the player was prompted to draw.
521523
- `drawing`: An array of strokes. Strokes are represented as 3-tuples consisting of x-offset, y-offset, and a binary variable which is 1 if the pen is lifted between this position and the next, and 0 otherwise.
522524

525+
<details>
526+
<summary>
527+
Click here to see the code for visualizing drawings in Jupyter Notebook or Google Colab:
528+
</summary>
529+
530+
```python
531+
import numpy as np
532+
import svgwrite # pip install svgwrite
533+
from IPython.display import SVG, display
534+
535+
def draw_strokes(drawing, factor=0.045):
536+
"""Displays vector drawing as SVG.
537+
538+
Args:
539+
drawing: a list of strokes represented as 3-tuples
540+
factor: scaling factor. The smaller the scaling factor, the bigger the SVG picture and vice versa.
541+
542+
"""
543+
def get_bounds(data, factor):
544+
"""Return bounds of data."""
545+
min_x = 0
546+
max_x = 0
547+
min_y = 0
548+
max_y = 0
549+
550+
abs_x = 0
551+
abs_y = 0
552+
for i in range(len(data)):
553+
x = float(data[i, 0]) / factor
554+
y = float(data[i, 1]) / factor
555+
abs_x += x
556+
abs_y += y
557+
min_x = min(min_x, abs_x)
558+
min_y = min(min_y, abs_y)
559+
max_x = max(max_x, abs_x)
560+
max_y = max(max_y, abs_y)
561+
562+
return (min_x, max_x, min_y, max_y)
563+
564+
data = np.array(drawing)
565+
min_x, max_x, min_y, max_y = get_bounds(data, factor)
566+
dims = (50 + max_x - min_x, 50 + max_y - min_y)
567+
dwg = svgwrite.Drawing(size=dims)
568+
dwg.add(dwg.rect(insert=(0, 0), size=dims,fill='white'))
569+
lift_pen = 1
570+
abs_x = 25 - min_x
571+
abs_y = 25 - min_y
572+
p = "M%s,%s " % (abs_x, abs_y)
573+
command = "m"
574+
for i in range(len(data)):
575+
if (lift_pen == 1):
576+
command = "m"
577+
elif (command != "l"):
578+
command = "l"
579+
else:
580+
command = ""
581+
x = float(data[i,0])/factor
582+
y = float(data[i,1])/factor
583+
lift_pen = data[i, 2]
584+
p += command+str(x)+","+str(y)+" "
585+
the_color = "black"
586+
stroke_width = 1
587+
dwg.add(dwg.path(p).stroke(the_color,stroke_width).fill("none"))
588+
display(SVG(dwg.tostring()))
589+
```
590+
591+
</details>
592+
593+
523594
> **Note**: Sketch-RNN takes for input strokes represented as 5-tuples with drawings padded to a common maximum length and prefixed by the special start token `[0, 0, 1, 0, 0]`. The 5-tuple representation consists of x-offset, y-offset, and p_1, p_2, p_3, a binary one-hot vector of 3 possible pen states: pen down, pen up, end of sketch. More precisely, the first two elements are the offset distance in the x and y directions of the pen from the previous point. The last 3 elements represents a binary one-hot vector of 3 possible states. The first pen state, p1, indicates that the pen is currently touching the paper, and that a line will be drawn connecting the next point with the current point. The second pen state, p2, indicates that the pen will be lifted from the paper after the current point, and that no line will be drawn next. The final pen state, p3, indicates that the drawing has ended, and subsequent points, including the current point, will not be rendered.
524595
><details>
525596
> <summary>
526597
> Click here to see the code for converting drawings to Sketch-RNN input format:
527598
> </summary>
599+
>
528600
> ```python
529601
> def to_sketch_rnn_format(drawing, max_len):
530602
> """Converts a drawing to Sketch-RNN input format.
531603
>
532604
> Args:
533-
> drawing: a list of strokes represented as 3-tuples
534-
> max_len: maximum common length of all drawings
605+
> drawing: a list of strokes represented as 3-tuples
606+
> max_len: maximum common length of all drawings
535607
>
536608
> Returns:
537-
> NumPy array
609+
> NumPy array
538610
> """
539611
> drawing = np.array(drawing)
540612
> result = np.zeros((max_len, 5), dtype=float)
@@ -548,10 +620,15 @@ The `sketch_rnn_full` configuration stores the data in the format suitable for i
548620
> result = np.vstack([[0, 0, 1, 0, 0], result])
549621
> return result
550622
> ```
623+
>
551624
></details>
552625
553626
### Data Splits
554627
628+
In the configurations `raw`, `preprocessed_simplified_drawings` and `preprocessed_bitamps` (default configuration), all the data is contained in the training set, which has 50426266 examples.
629+
630+
`sketch_rnn` and `sketch_rnn_full` have the data split into training, validation and test split. In the `sketch_rnn` configuration, 75K samples (70K Training, 2.5K Validation, 2.5K Test) have been randomly selected from each category. Therefore, the training set contains 24150000 examples, the validation set 862500 examples and the test set 862500 examples. The `sketch_rnn_full` configuration has the full (training) data for each category, which leads to the training set having 43988874 examples, the validation set 862500 and the test set 862500 examples.
631+
555632
## Dataset Creation
556633
557634
### Curation Rationale
@@ -566,17 +643,25 @@ From the GitHub repository:
566643
567644
#### Initial Data Collection and Normalization
568645
646+
This dataset contains vector drawings obtained from [Quick, Draw!](https://quickdraw.withgoogle.com/), an online game where the players are asked to draw objects belonging to a particular object class in less than 20 seconds.
647+
569648
#### Who are the source language producers?
570649
650+
The participants in the [Quick, Draw!](https://quickdraw.withgoogle.com/) game.
651+
571652
### Annotations
572653
573654
#### Annotation process
574655
656+
The annotations are machine-generated and match the category the player was prompted to draw.
657+
575658
#### Who are the annotators?
576659
660+
The annotations are machine-generated.
661+
577662
### Personal and Sensitive Information
578663
579-
[More Information Needed]
664+
Some sketches are known to be problematic (see https://github.com/googlecreativelab/quickdraw-dataset/issues/74 and https://github.com/googlecreativelab/quickdraw-dataset/issues/18).
580665
581666
## Considerations for Using the Data
582667
@@ -594,7 +679,7 @@ From the GitHub repository:
594679
595680
### Dataset Curators
596681
597-
Jonas Jongejan.
682+
Jonas Jongejan, Henry Rowley, Takashi Kawashima, Jongmin Kim and Nick Fox-Gieg.
598683
599684
### Licensing Information
600685

0 commit comments

Comments
 (0)