File size: 2,209 Bytes
2b812b0
92d4a6d
 
 
 
 
 
 
 
2b812b0
92d4a6d
 
 
 
 
d08ec15
 
 
 
 
92d4a6d
 
 
 
 
 
3ec51f0
 
 
 
92d4a6d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: cc0-1.0
task_categories:
- text-to-image
tags:
- art
pretty_name: Factorio Blueprint Visualizations Dataset
size_categories:
- n<1K
---

## Dataset Description

This dataset is a collection of visualizations of [Factorio Blueprints](https://wiki.factorio.com/Blueprint) using this Factorio Visualization Tool: https://github.com/piebro/factorio-blueprint-visualizer. The Blueprints are collected from https://www.factorio.school/.

## Examples

![](png_1024x1024/image_38.png)
![](png_1024x1024/image_39.png)

## Dataset Structure

* "svg_original": The svg downloaded like this from the website
* "svg_rect": The svg reshaped to a rect and a slightly bigger border
* "png_1024x1024": The svg_rect images exported as pngs

## Additional Information

The dataset was used to train this lora: https://huggingface.co/piebro/factorio-blueprint-visualizations-sdxl-lora

## Code Attachments

Code to create the rectangular svgs:
```python
import os
import xml.etree.ElementTree as ET

def modify_svg(save_dir, svg_file_path):
    tree = ET.parse(svg_file_path)
    root = tree.getroot()

    # Extract current width and height
    width = float(root.attrib['width'].replace('mm', ''))
    height = float(root.attrib['height'].replace('mm', ''))

    # Calculate new dimensions
    new_size = max(width, height) + 200

    # Update width and height
    root.attrib['width'] = f"{new_size}mm"
    root.attrib['height'] = f"{new_size}mm"

    # Adjust viewBox for centering content
    view_box = root.attrib.get('viewBox', '').split(',')
    if len(view_box) == 4:
        x, y, vw, vh = map(float, view_box)
        dx = vw*0.12
        dy = vh*0.12
        root.attrib['viewBox'] = f"{x-dx/2}, {y-dy/2}, {vw+dx}, {vh+dy}"

    # Write back to file or a new file
    tree.write(os.path.join(save_dir, f"modified_{os.path.basename(svg_file_path)}"))

save_dir = ""
original_svg_folder_path = ""
for file_name in os.listdir(original_svg_folder_path):
    if file_name.endswith('.svg'):
        modify_svg(save_dir, os.path.join(original_svg_folder_path, file_name))
```

Code to create the pngs:
```bash
mkdir pngs
for file in *.svg; do convert "$file" -resize 1024x1024 "pngs/${file%.svg}.png"; done
```