File size: 2,477 Bytes
bc377d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ed9f134
bc377d2
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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
---
license: mit
task_categories:
  - text-to-image
  - image-to-text
language:
  - en
tags:
  - gcode
  - cnc
  - plotter
  - polargraph
  - line-art
  - sketch
  - stable-diffusion
size_categories:
  - 100K<n<1M
---

# dcode: ImageNet-Sketch to G-code Dataset

A dataset of **ImageNet-Sketch images paired with generated G-code** for training text-to-gcode diffusion models.

## Overview

This dataset enables training models that convert text descriptions directly into G-code for CNC machines, plotters, and polargraph drawing robots.

| Feature | Value |
|---------|-------|
| Source Images | [ImageNet-Sketch](https://github.com/HaohanWang/ImageNet-Sketch) |
| Classes | 1,000 ImageNet categories |
| Images | ~50,000 black/white sketches |
| G-code Files | ~200,000 (4 algorithms × images) |
| Algorithms | spiral, crosshatch, squares, trace |

## Structure

```
images/
    n01440764/              # ImageNet synset ID
        ILSVRC2012_val_00000293.JPEG
        ...
    n01443537/
        ...
gcode/
    n01440764/
        spiral/
            ILSVRC2012_val_00000293_spiral_0.gcode
            ILSVRC2012_val_00000293_spiral_1.gcode
        crosshatch/
            ...
        squares/
            ...
        trace/
            ...
```

## Algorithms

| Algorithm | Description |
|-----------|-------------|
| **spiral** | Concentric spiral from center, density varies with brightness |
| **crosshatch** | Multi-angle hatching lines at configurable angles |
| **squares** | Concentric squares sized by local brightness |
| **trace** | Binary edge detection with scan-line tracing |

## Usage

```python
from datasets import load_dataset

# Load the dataset
ds = load_dataset("twarner/dcode-imagenet-sketch")

# Access image and corresponding gcode
sample = ds["train"][0]
print(sample["image_path"])
print(sample["gcode_path"])
print(sample["caption"])  # "a sketch of a goldfish"
```

## Training

This dataset was used to train [dcode-sd-gcode-v3](https://huggingface.co/twarner/dcode-sd-gcode-v3), an end-to-end text-to-gcode diffusion model.

## Project

Full project documentation, hardware build guide, and interactive demo:

**🔗 [teddywarner.org/Projects/Polargraph/#dcode](https://teddywarner.org/Projects/Polargraph/#dcode)**

## Citation

```bibtex
@misc{dcode2024,
  author = {Teddy Warner},
  title = {dcode: Text-to-Gcode Diffusion Model},
  year = {2026},
  url = {https://teddywarner.org/Projects/Polargraph/#dcode}
}
```

## License

MIT License