autoforge 1.5.4__tar.gz → 1.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. {autoforge-1.5.4 → autoforge-1.6.0}/PKG-INFO +67 -51
  2. {autoforge-1.5.4 → autoforge-1.6.0}/README.md +64 -50
  3. {autoforge-1.5.4 → autoforge-1.6.0}/pyproject.toml +4 -2
  4. {autoforge-1.5.4 → autoforge-1.6.0}/src/AutoForge.egg-info/PKG-INFO +67 -51
  5. {autoforge-1.5.4 → autoforge-1.6.0}/src/AutoForge.egg-info/SOURCES.txt +8 -5
  6. {autoforge-1.5.4 → autoforge-1.6.0}/src/AutoForge.egg-info/requires.txt +2 -0
  7. {autoforge-1.5.4 → autoforge-1.6.0}/src/autoforge/Helper/Heightmaps/ChristofidesHeightMap.py +111 -49
  8. {autoforge-1.5.4 → autoforge-1.6.0}/src/autoforge/Helper/OptimizerHelper.py +28 -37
  9. {autoforge-1.5.4 → autoforge-1.6.0}/src/autoforge/Helper/OutputHelper.py +168 -145
  10. autoforge-1.6.0/src/autoforge/Helper/PruningHelper.py +628 -0
  11. autoforge-1.6.0/src/autoforge/Init_comparer/auto_forge_init_check.py +254 -0
  12. autoforge-1.6.0/src/autoforge/Init_comparer/plot_results.py +118 -0
  13. autoforge-1.6.0/src/autoforge/Loss/LossFunctions.py +95 -0
  14. {autoforge-1.5.4 → autoforge-1.6.0}/src/autoforge/Modules/Optimizer.py +139 -69
  15. autoforge-1.6.0/src/autoforge/__init__.py +0 -0
  16. {autoforge-1.5.4 → autoforge-1.6.0}/src/autoforge/auto_forge.py +50 -120
  17. autoforge-1.5.4/src/autoforge/Helper/PruningHelper.py +0 -502
  18. autoforge-1.5.4/src/autoforge/Loss/LossFunctions.py +0 -103
  19. {autoforge-1.5.4 → autoforge-1.6.0}/setup.cfg +0 -0
  20. {autoforge-1.5.4 → autoforge-1.6.0}/src/AutoForge.egg-info/dependency_links.txt +0 -0
  21. {autoforge-1.5.4 → autoforge-1.6.0}/src/AutoForge.egg-info/entry_points.txt +0 -0
  22. {autoforge-1.5.4 → autoforge-1.6.0}/src/AutoForge.egg-info/top_level.txt +0 -0
  23. {autoforge-1.5.4/src/autoforge/Gui/Views → autoforge-1.6.0/src/autoforge/Gui}/__init__.py +0 -0
  24. {autoforge-1.5.4/src/autoforge/Gui → autoforge-1.6.0/src/autoforge/Gui/browser_gui/Views}/__init__.py +0 -0
  25. {autoforge-1.5.4/src/autoforge/Gui → autoforge-1.6.0/src/autoforge/Gui/browser_gui}/Views/backend_database.py +0 -0
  26. {autoforge-1.5.4/src/autoforge/Gui → autoforge-1.6.0/src/autoforge/Gui/browser_gui}/Views/filament_editor.py +0 -0
  27. {autoforge-1.5.4/src/autoforge/Gui → autoforge-1.6.0/src/autoforge/Gui/browser_gui}/app.py +0 -0
  28. {autoforge-1.5.4/src/autoforge/Gui → autoforge-1.6.0/src/autoforge/Gui/browser_gui}/main.py +0 -0
  29. {autoforge-1.5.4 → autoforge-1.6.0}/src/autoforge/Helper/CAdamW.py +0 -0
  30. {autoforge-1.5.4 → autoforge-1.6.0}/src/autoforge/Helper/FilamentHelper.py +0 -0
  31. {autoforge-1.5.4 → autoforge-1.6.0}/src/autoforge/Helper/Heightmaps/DepthEstimateHeightMap.py +0 -0
  32. {autoforge-1.5.4 → autoforge-1.6.0}/src/autoforge/Helper/Heightmaps/OldHeightmap.py +0 -0
  33. {autoforge-1.5.4 → autoforge-1.6.0}/src/autoforge/Helper/Heightmaps/__init__.py +0 -0
  34. {autoforge-1.5.4 → autoforge-1.6.0}/src/autoforge/Helper/ImageHelper.py +0 -0
  35. {autoforge-1.5.4 → autoforge-1.6.0}/src/autoforge/Helper/__init__.py +0 -0
  36. {autoforge-1.5.4 → autoforge-1.6.0}/src/autoforge/Helper/filamentcolors_library.py +0 -0
  37. {autoforge-1.5.4/src/autoforge/Loss → autoforge-1.6.0/src/autoforge/Init_comparer}/__init__.py +0 -0
  38. {autoforge-1.5.4 → autoforge-1.6.0}/src/autoforge/Loss/PerceptionLoss.py +0 -0
  39. {autoforge-1.5.4/src/autoforge/Misc → autoforge-1.6.0/src/autoforge/Loss}/__init__.py +0 -0
  40. {autoforge-1.5.4/src/autoforge/Modules → autoforge-1.6.0/src/autoforge/Misc}/__init__.py +0 -0
  41. {autoforge-1.5.4 → autoforge-1.6.0}/src/autoforge/Misc/color_fit_all.py +0 -0
  42. {autoforge-1.5.4/src/autoforge → autoforge-1.6.0/src/autoforge/Modules}/__init__.py +0 -0
  43. {autoforge-1.5.4 → autoforge-1.6.0}/src/autoforge/__main__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: AutoForge
3
- Version: 1.5.4
3
+ Version: 1.6.0
4
4
  Summary: AutoForge is a Python tool for generating 3D printed layered models from an input image.
5
5
  Author-email: Hendric Voss <hvoss@techfak.uni-bielefeld.de>
6
6
  License: CC BY-NC-SA 4.0
@@ -19,6 +19,8 @@ Requires-Dist: scikit-image
19
19
  Requires-Dist: scikit-learn
20
20
  Requires-Dist: tensorboard
21
21
  Requires-Dist: pillow>=11.1.0
22
+ Requires-Dist: shapely>=2.0.7
23
+ Requires-Dist: trimesh>=4.6.4
22
24
 
23
25
  # AutoForge
24
26
 
@@ -35,18 +37,14 @@ The pruning is set to a maximum of 8 color and 20 swaps, so each image uses at m
35
37
  <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/lofi.jpg" width="200" />
36
38
  <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/nature.jpg" width="200" />
37
39
  <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/cat.jpg" width="200" />
40
+ <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/chameleon.jpg" width="200" />
38
41
  </div>
39
42
  <div style="text-align: center;">
40
- <h3>Autoforge Output (75 color layers (3.0mm) + 10 gray background layers (0.4mm)) </h3>
43
+ <h3>Autoforge Output</h3>
41
44
  <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/lofi_discretized.png" width="200" />
42
45
  <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/nature_discretized.png" width="200" />
43
46
  <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/cat_discretized.png" width="200" />
44
- </div>
45
- <div style="text-align: center;">
46
- <h3>Imported Hueforge View</h3>
47
- <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/lofi_hueforge.png" width="200" />
48
- <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/nature_hueforge.png" width="200" />
49
- <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/cat_hueforge.png" width="200" />
47
+ <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/chameleon_discretized.png" width="200" />
50
48
  </div>
51
49
  </div>
52
50
 
@@ -58,6 +56,7 @@ I would love to see what you made!
58
56
 
59
57
  - **Image-to-Model Conversion**: Converts an input image into a layered model suitable for 3D printing.
60
58
  - **Learned Optimization**: Optimizes per-pixel height and per-layer material assignments using PyTorch.
59
+ - **Learned Heightmap**: Optimizes the height of the layered model to create more detailed prints.
61
60
  - **Gumbel Softmax Sampling**: Leverages the Gumbel softmax method to decide material assignments for each layer.
62
61
  - **STL File Generation**: Exports an ASCII STL file based on the optimized height map.
63
62
  - **Swap Instructions**: Generates clear swap instructions for changing materials during printing.
@@ -69,11 +68,11 @@ I would love to see what you made!
69
68
 
70
69
  To install AutoForge, simply install the current version from PyPI:
71
70
  ```bash
72
- pip install autoforge
71
+ pip install -U autoforge
73
72
  ```
74
73
 
75
74
  If you have problems running the code on your gpu, please refer to the [Pytorch Homepage](https://pytorch.org/) for help. \
76
- Both CUDA and ROCm are supported, but you need to install the correct version of pytorch for your system.
75
+ CUDA, ROCm, and MPS (Apple Metal) are supported, but you need to install the correct version of pytorch for your system.
77
76
 
78
77
  ## Usage
79
78
 
@@ -90,35 +89,47 @@ autoforge --input_image path/to/input_image.jpg --csv_file path/to/materials.csv
90
89
 
91
90
  ### Command Line Arguments
92
91
 
93
- - `--config`: *(Optional)* Path to a configuration file with the settings.
94
- - `--input_image`: **(Required)** Path to the input image.
95
- - `--csv_file`: **(Required)** Path to the CSV file containing material data. The CSV should include columns for the brand, name, color (hex code), and TD values.
96
- - `--output_folder`: Folder where output files will be saved. (default: `./outputs`).
97
- - `--iterations`: Number of optimization iterations (default: 5000).
98
- - `--learning_rate`: Learning rate for the optimizer (default: 1e-2).
99
- - `--layer_height`: Layer thickness in millimeters (default: 0.04).
100
- - `--max_layers`: Maximum number of layers (default: 100). \
101
- **Note:** This is about 3mm + the background height
102
- - `--min_layers`: Minimum number of layers (default: 0). Used to limit height of pruning
103
- - `--background_height`: Height of the background in millimeters (default: 0.4). \
92
+ ### Command Line Arguments
93
+
94
+ - `--config` *(Optional)* Path to a configuration file with the settings.
95
+
96
+
97
+ - `--input_image` **(Required)** Path to the input image.
98
+ - `--csv_file` **(Required)** Path to the CSV file containing material data. The CSV should include columns for the brand, name, color (hex code), and TD values.
99
+
100
+ - `--output_folder` Folder where output files will be saved (default: `output`).
101
+ - `--iterations` Number of optimization iterations (default: 5000).
102
+ - `--learning_rate` Learning rate for optimization (default: 1e-2).
103
+ - `--layer_height` Layer thickness in millimeters (default: 0.04).
104
+ - `--max_layers` Maximum number of layers (default: 50).
105
+ **Note:** This is about 2mm + the background height
106
+ - `--background_height` Height of the background in millimeters (default: 0.4).
104
107
  **Note:** The background height must be divisible by the layer height.
105
- - `--background_color`: Background color in hexadecimal format (default: `#000000` aka Black). \
106
- **Note:** The solver currently assumes that you have a solid color in the background, which means a color with a TD value of 4 or less (if you have a background height of 0.4)
107
- - `--output_size`: Maximum dimension for target image (default: 1024).
108
- - `--solver_size`: Maximum dimension for solver (fast) image (default: 256). \
109
- **Note:** We solve on a smaller size as this is many times faster, but also a bit less accurate. Increase if you need more accuracy.
110
- - `--init_tau`: Initial tau value for Gumbel-Softmax (default: 1.0).
111
- - `--final_tau`: Final tau value for the Gumbel-Softmax formulation (default: 0.01).
112
- - `--stl_output_size`: Size of the output stl file in mm (default: 200) (20cm).
113
- - `--visualize`: Flag to enable live visualization of the composite image during optimization.
114
- - `--tensorboard`: Enable TensorBoard logging
115
- - `--run_name`: Name of the run used for TensorBoard logging (optional).
116
- - `--perform_pruning`: Perform pruning after optimization (default: True). \
108
+ - `--background_color` Background color in hexadecimal format (default: `#000000` aka Black).
109
+ **Note:** The solver currently assumes that you have a solid color in the background, which means a color with a TD value of 4 or less (if you have a background height of 0.4).
110
+ - `--init_tau` Initial tau value for Gumbel-Softmax (default: 1.0).
111
+ - `--final_tau` Final tau value for the Gumbel-Softmax formulation (default: 0.01).
112
+ - `--visualize` Flag to enable live visualization of the composite image during optimization.
113
+ - `--stl_output_size` Size of the longest dimension of the output STL file in millimeters (default: 150).
114
+ - `--nozzle_diameter` Diameter of the printer nozzle in millimeters (default: 0.4).
115
+ **Note:** Details smaller than half this value will be ignored.
116
+ - `--early_stopping` Number of steps without improvement before stopping (default: 1500).
117
+ -
118
+
119
+ - `--perform_pruning` Perform pruning after optimization (default: True).
117
120
  **Note:** This is highly recommended even if you don't have a color/color swap limit, as it actually increases the quality of the output.
118
- - `--pruning_max_colors`: Max number of colors allowed after pruning (default: 100).
119
- - `--pruning_max_swaps`: Max number of swaps allowed after pruning (default: 100).
120
- - `--pruning_max_layers`: Max number of layers allowed after pruning (default: 75).
121
- - `--random_seed`: Random seed for reproducibility (default: 0 (disabled) ).
121
+ - `--pruning_max_colors` Max number of colors allowed after pruning (default: 100).
122
+ - `--pruning_max_swaps` Max number of swaps allowed after pruning (default: 100).
123
+ - `--pruning_max_layer` Max number of layers allowed after pruning (default: 75).
124
+ - `--min_layers` Minimum number of layers (default: 0). Used to limit height of pruning.
125
+ - `--random_seed` Random seed for reproducibility (default: 0 (disabled)).
126
+ - `--mps` Flag to use the Metal Performance Shaders (MPS) backend if available.
127
+
128
+
129
+ - `--tensorboard` Flag to enable TensorBoard logging.
130
+ - `--run_name` *(Optional)* Name of the run used for TensorBoard logging.
131
+
132
+
122
133
 
123
134
  ### Experimental Deph Anything V2 parameters
124
135
  I got a request to add an initializing function that takes the original depth of the image into account when initializing. \
@@ -129,7 +140,6 @@ I currently don't recommend it as the output is not as good as without it, but I
129
140
  - `--use_depth_anything`: Use a depth anything v2 model to initialize the height map (default: False).
130
141
  **Note:** This will give you a nice background/foreground separation, but will could degrade quality in some cases.
131
142
  **Note:** In addition you need the VRAM to run the depth model.
132
-
133
143
  - `--depth_strength`: Weight for blending even spacing with the cluster’s average depth when using depth initialization. (default: 0.25)
134
144
  - `--depth_threshold`: Threshold for splitting two distinct colors based on depth. (default: 0.05)
135
145
  - `--min_cluster_value`: Minimum normalized value for the lowest cluster (to avoid pure black). (default: 0.1)
@@ -142,22 +152,15 @@ I currently don't recommend it as the output is not as good as without it, but I
142
152
 
143
153
  After running, the following files will be created in your specified output folder:
144
154
 
145
- - **Discrete Composite Image**: `discrete_comp.png`
155
+ - **Discrete Composite Image**: `final_model.png`
146
156
  - **STL File**: `final_model.stl`
157
+ - **Hueforge Project File**: `project_file.hfp`
147
158
  - **Swap Instructions**: `swap_instructions.txt`
148
159
 
149
- Just a heads-up, this program is mainly concerned with realistic output and will give you VERY long swap instructions.
150
- Expect to switch your filament every 1-2 layers!
151
-
152
- For more artistic control or to reduce the number of swaps, consider buying [Hueforge](https://shop.thehueforge.com/).
153
-
154
160
  ## Known Bugs
155
161
 
156
- - There is a color discrepancy between our output and hueforge. If anyone has an idea what the problem is, please don't hesitate to submit a pull request :) \
157
- Although I would love to be it fully color compatible with hueforge, I don't think this will happen without a lot of work or the hueforge source code.
158
162
  - The optimizer can sometimes get stuck in a local minimum. If this happens, try running the optimization again with different settings.
159
163
  - Hueforge can't open STL files under linux. This is a known bug in hueforge.
160
- - The first version used a learnable height map which was nice but resulted in a lot of problems. Right now we compute the height map from the luminance values and slightly adjust the result. If somebody has an idea to make this better, please don't hesitate to submit a pull request :)
161
164
 
162
165
  ## License
163
166
 
@@ -181,9 +184,22 @@ AutoForge makes use of several open source libraries:
181
184
  - [TQDM](https://github.com/tqdm/tqdm)
182
185
  - [ConfigArgParse](https://github.com/bw2/ConfigArgParse)
183
186
 
184
- Example Images:
185
- <a href="https://www.vecteezy.com/free-photos/anime-girl">Anime Girl Stock photos by Vecteezy</a>
186
- <a href="https://www.vecteezy.com/free-photos/nature">Nature Stock photos by Vecteezy</a>
187
- <a href="https://www.vecteezy.com/free-photos/ai-generated">Ai Generated Stock photos by Vecteezy</a>
187
+ Example Images: \
188
+ <a href="https://www.vecteezy.com/free-photos/nature">Nature Stock photos by Vecteezy</a> \
189
+ <a href="https://www.vecteezy.com/free-photos/ai-generated">Ai Generated Stock photos by Vecteezy</a> \
190
+ <a href="https://www.vecteezy.com/free-photos/animal">Animal Stock photos by Vecteezy</a> \
191
+ <a href="https://www.vecteezy.com/free-photos/people">People Stock photos by Vecteezy</a> \
192
+ <a href="https://www.vecteezy.com/free-photos/psychedelic">Psychedelic Stock photos by Vecteezy</a> \
193
+ <a href="https://www.vecteezy.com/free-photos/ocean">Ocean Stock photos by Vecteezy</a> \
194
+ <a href="https://www.vecteezy.com/free-photos/psychic">Psychic Stock photos by Vecteezy</a> \
195
+ <a href="https://www.vecteezy.com/free-photos/psychedelic">Psychedelic Stock photos by Vecteezy</a> \
196
+ <a href="https://www.vecteezy.com/free-photos/pattern">Pattern Stock photos by Vecteezy</a> \
197
+ <a href="https://www.vecteezy.com/free-photos/forest">Forest Stock photos by Vecteezy</a> \
198
+ <a href="https://www.vecteezy.com/free-photos/stick-figure-kids">Stick Figure Kids Stock photos by Vecteezy</a> \
199
+ <a href="https://www.vecteezy.com/free-photos/forest">Forest Stock photos by Vecteezy</a> \
200
+ <a href="https://www.vecteezy.com/free-photos/nature">Nature Stock photos by Vecteezy</a> \
201
+ <a href="https://www.vecteezy.com/free-photos/ai-generated">Ai Generated Stock photos by Vecteezy</a>\
202
+ <a href="https://www.vecteezy.com/free-photos/animal">Animal Stock photos by Vecteezy</a>
203
+
188
204
 
189
205
  Happy printing!
@@ -13,18 +13,14 @@ The pruning is set to a maximum of 8 color and 20 swaps, so each image uses at m
13
13
  <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/lofi.jpg" width="200" />
14
14
  <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/nature.jpg" width="200" />
15
15
  <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/cat.jpg" width="200" />
16
+ <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/chameleon.jpg" width="200" />
16
17
  </div>
17
18
  <div style="text-align: center;">
18
- <h3>Autoforge Output (75 color layers (3.0mm) + 10 gray background layers (0.4mm)) </h3>
19
+ <h3>Autoforge Output</h3>
19
20
  <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/lofi_discretized.png" width="200" />
20
21
  <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/nature_discretized.png" width="200" />
21
22
  <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/cat_discretized.png" width="200" />
22
- </div>
23
- <div style="text-align: center;">
24
- <h3>Imported Hueforge View</h3>
25
- <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/lofi_hueforge.png" width="200" />
26
- <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/nature_hueforge.png" width="200" />
27
- <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/cat_hueforge.png" width="200" />
23
+ <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/chameleon_discretized.png" width="200" />
28
24
  </div>
29
25
  </div>
30
26
 
@@ -36,6 +32,7 @@ I would love to see what you made!
36
32
 
37
33
  - **Image-to-Model Conversion**: Converts an input image into a layered model suitable for 3D printing.
38
34
  - **Learned Optimization**: Optimizes per-pixel height and per-layer material assignments using PyTorch.
35
+ - **Learned Heightmap**: Optimizes the height of the layered model to create more detailed prints.
39
36
  - **Gumbel Softmax Sampling**: Leverages the Gumbel softmax method to decide material assignments for each layer.
40
37
  - **STL File Generation**: Exports an ASCII STL file based on the optimized height map.
41
38
  - **Swap Instructions**: Generates clear swap instructions for changing materials during printing.
@@ -47,11 +44,11 @@ I would love to see what you made!
47
44
 
48
45
  To install AutoForge, simply install the current version from PyPI:
49
46
  ```bash
50
- pip install autoforge
47
+ pip install -U autoforge
51
48
  ```
52
49
 
53
50
  If you have problems running the code on your gpu, please refer to the [Pytorch Homepage](https://pytorch.org/) for help. \
54
- Both CUDA and ROCm are supported, but you need to install the correct version of pytorch for your system.
51
+ CUDA, ROCm, and MPS (Apple Metal) are supported, but you need to install the correct version of pytorch for your system.
55
52
 
56
53
  ## Usage
57
54
 
@@ -68,35 +65,47 @@ autoforge --input_image path/to/input_image.jpg --csv_file path/to/materials.csv
68
65
 
69
66
  ### Command Line Arguments
70
67
 
71
- - `--config`: *(Optional)* Path to a configuration file with the settings.
72
- - `--input_image`: **(Required)** Path to the input image.
73
- - `--csv_file`: **(Required)** Path to the CSV file containing material data. The CSV should include columns for the brand, name, color (hex code), and TD values.
74
- - `--output_folder`: Folder where output files will be saved. (default: `./outputs`).
75
- - `--iterations`: Number of optimization iterations (default: 5000).
76
- - `--learning_rate`: Learning rate for the optimizer (default: 1e-2).
77
- - `--layer_height`: Layer thickness in millimeters (default: 0.04).
78
- - `--max_layers`: Maximum number of layers (default: 100). \
79
- **Note:** This is about 3mm + the background height
80
- - `--min_layers`: Minimum number of layers (default: 0). Used to limit height of pruning
81
- - `--background_height`: Height of the background in millimeters (default: 0.4). \
68
+ ### Command Line Arguments
69
+
70
+ - `--config` *(Optional)* Path to a configuration file with the settings.
71
+
72
+
73
+ - `--input_image` **(Required)** Path to the input image.
74
+ - `--csv_file` **(Required)** Path to the CSV file containing material data. The CSV should include columns for the brand, name, color (hex code), and TD values.
75
+
76
+ - `--output_folder` Folder where output files will be saved (default: `output`).
77
+ - `--iterations` Number of optimization iterations (default: 5000).
78
+ - `--learning_rate` Learning rate for optimization (default: 1e-2).
79
+ - `--layer_height` Layer thickness in millimeters (default: 0.04).
80
+ - `--max_layers` Maximum number of layers (default: 50).
81
+ **Note:** This is about 2mm + the background height
82
+ - `--background_height` Height of the background in millimeters (default: 0.4).
82
83
  **Note:** The background height must be divisible by the layer height.
83
- - `--background_color`: Background color in hexadecimal format (default: `#000000` aka Black). \
84
- **Note:** The solver currently assumes that you have a solid color in the background, which means a color with a TD value of 4 or less (if you have a background height of 0.4)
85
- - `--output_size`: Maximum dimension for target image (default: 1024).
86
- - `--solver_size`: Maximum dimension for solver (fast) image (default: 256). \
87
- **Note:** We solve on a smaller size as this is many times faster, but also a bit less accurate. Increase if you need more accuracy.
88
- - `--init_tau`: Initial tau value for Gumbel-Softmax (default: 1.0).
89
- - `--final_tau`: Final tau value for the Gumbel-Softmax formulation (default: 0.01).
90
- - `--stl_output_size`: Size of the output stl file in mm (default: 200) (20cm).
91
- - `--visualize`: Flag to enable live visualization of the composite image during optimization.
92
- - `--tensorboard`: Enable TensorBoard logging
93
- - `--run_name`: Name of the run used for TensorBoard logging (optional).
94
- - `--perform_pruning`: Perform pruning after optimization (default: True). \
84
+ - `--background_color` Background color in hexadecimal format (default: `#000000` aka Black).
85
+ **Note:** The solver currently assumes that you have a solid color in the background, which means a color with a TD value of 4 or less (if you have a background height of 0.4).
86
+ - `--init_tau` Initial tau value for Gumbel-Softmax (default: 1.0).
87
+ - `--final_tau` Final tau value for the Gumbel-Softmax formulation (default: 0.01).
88
+ - `--visualize` Flag to enable live visualization of the composite image during optimization.
89
+ - `--stl_output_size` Size of the longest dimension of the output STL file in millimeters (default: 150).
90
+ - `--nozzle_diameter` Diameter of the printer nozzle in millimeters (default: 0.4).
91
+ **Note:** Details smaller than half this value will be ignored.
92
+ - `--early_stopping` Number of steps without improvement before stopping (default: 1500).
93
+ -
94
+
95
+ - `--perform_pruning` Perform pruning after optimization (default: True).
95
96
  **Note:** This is highly recommended even if you don't have a color/color swap limit, as it actually increases the quality of the output.
96
- - `--pruning_max_colors`: Max number of colors allowed after pruning (default: 100).
97
- - `--pruning_max_swaps`: Max number of swaps allowed after pruning (default: 100).
98
- - `--pruning_max_layers`: Max number of layers allowed after pruning (default: 75).
99
- - `--random_seed`: Random seed for reproducibility (default: 0 (disabled) ).
97
+ - `--pruning_max_colors` Max number of colors allowed after pruning (default: 100).
98
+ - `--pruning_max_swaps` Max number of swaps allowed after pruning (default: 100).
99
+ - `--pruning_max_layer` Max number of layers allowed after pruning (default: 75).
100
+ - `--min_layers` Minimum number of layers (default: 0). Used to limit height of pruning.
101
+ - `--random_seed` Random seed for reproducibility (default: 0 (disabled)).
102
+ - `--mps` Flag to use the Metal Performance Shaders (MPS) backend if available.
103
+
104
+
105
+ - `--tensorboard` Flag to enable TensorBoard logging.
106
+ - `--run_name` *(Optional)* Name of the run used for TensorBoard logging.
107
+
108
+
100
109
 
101
110
  ### Experimental Deph Anything V2 parameters
102
111
  I got a request to add an initializing function that takes the original depth of the image into account when initializing. \
@@ -107,7 +116,6 @@ I currently don't recommend it as the output is not as good as without it, but I
107
116
  - `--use_depth_anything`: Use a depth anything v2 model to initialize the height map (default: False).
108
117
  **Note:** This will give you a nice background/foreground separation, but will could degrade quality in some cases.
109
118
  **Note:** In addition you need the VRAM to run the depth model.
110
-
111
119
  - `--depth_strength`: Weight for blending even spacing with the cluster’s average depth when using depth initialization. (default: 0.25)
112
120
  - `--depth_threshold`: Threshold for splitting two distinct colors based on depth. (default: 0.05)
113
121
  - `--min_cluster_value`: Minimum normalized value for the lowest cluster (to avoid pure black). (default: 0.1)
@@ -120,22 +128,15 @@ I currently don't recommend it as the output is not as good as without it, but I
120
128
 
121
129
  After running, the following files will be created in your specified output folder:
122
130
 
123
- - **Discrete Composite Image**: `discrete_comp.png`
131
+ - **Discrete Composite Image**: `final_model.png`
124
132
  - **STL File**: `final_model.stl`
133
+ - **Hueforge Project File**: `project_file.hfp`
125
134
  - **Swap Instructions**: `swap_instructions.txt`
126
135
 
127
- Just a heads-up, this program is mainly concerned with realistic output and will give you VERY long swap instructions.
128
- Expect to switch your filament every 1-2 layers!
129
-
130
- For more artistic control or to reduce the number of swaps, consider buying [Hueforge](https://shop.thehueforge.com/).
131
-
132
136
  ## Known Bugs
133
137
 
134
- - There is a color discrepancy between our output and hueforge. If anyone has an idea what the problem is, please don't hesitate to submit a pull request :) \
135
- Although I would love to be it fully color compatible with hueforge, I don't think this will happen without a lot of work or the hueforge source code.
136
138
  - The optimizer can sometimes get stuck in a local minimum. If this happens, try running the optimization again with different settings.
137
139
  - Hueforge can't open STL files under linux. This is a known bug in hueforge.
138
- - The first version used a learnable height map which was nice but resulted in a lot of problems. Right now we compute the height map from the luminance values and slightly adjust the result. If somebody has an idea to make this better, please don't hesitate to submit a pull request :)
139
140
 
140
141
  ## License
141
142
 
@@ -159,9 +160,22 @@ AutoForge makes use of several open source libraries:
159
160
  - [TQDM](https://github.com/tqdm/tqdm)
160
161
  - [ConfigArgParse](https://github.com/bw2/ConfigArgParse)
161
162
 
162
- Example Images:
163
- <a href="https://www.vecteezy.com/free-photos/anime-girl">Anime Girl Stock photos by Vecteezy</a>
164
- <a href="https://www.vecteezy.com/free-photos/nature">Nature Stock photos by Vecteezy</a>
165
- <a href="https://www.vecteezy.com/free-photos/ai-generated">Ai Generated Stock photos by Vecteezy</a>
163
+ Example Images: \
164
+ <a href="https://www.vecteezy.com/free-photos/nature">Nature Stock photos by Vecteezy</a> \
165
+ <a href="https://www.vecteezy.com/free-photos/ai-generated">Ai Generated Stock photos by Vecteezy</a> \
166
+ <a href="https://www.vecteezy.com/free-photos/animal">Animal Stock photos by Vecteezy</a> \
167
+ <a href="https://www.vecteezy.com/free-photos/people">People Stock photos by Vecteezy</a> \
168
+ <a href="https://www.vecteezy.com/free-photos/psychedelic">Psychedelic Stock photos by Vecteezy</a> \
169
+ <a href="https://www.vecteezy.com/free-photos/ocean">Ocean Stock photos by Vecteezy</a> \
170
+ <a href="https://www.vecteezy.com/free-photos/psychic">Psychic Stock photos by Vecteezy</a> \
171
+ <a href="https://www.vecteezy.com/free-photos/psychedelic">Psychedelic Stock photos by Vecteezy</a> \
172
+ <a href="https://www.vecteezy.com/free-photos/pattern">Pattern Stock photos by Vecteezy</a> \
173
+ <a href="https://www.vecteezy.com/free-photos/forest">Forest Stock photos by Vecteezy</a> \
174
+ <a href="https://www.vecteezy.com/free-photos/stick-figure-kids">Stick Figure Kids Stock photos by Vecteezy</a> \
175
+ <a href="https://www.vecteezy.com/free-photos/forest">Forest Stock photos by Vecteezy</a> \
176
+ <a href="https://www.vecteezy.com/free-photos/nature">Nature Stock photos by Vecteezy</a> \
177
+ <a href="https://www.vecteezy.com/free-photos/ai-generated">Ai Generated Stock photos by Vecteezy</a>\
178
+ <a href="https://www.vecteezy.com/free-photos/animal">Animal Stock photos by Vecteezy</a>
179
+
166
180
 
167
181
  Happy printing!
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "AutoForge"
7
- version="1.5.4"
7
+ version="1.6.0"
8
8
  description = "AutoForge is a Python tool for generating 3D printed layered models from an input image."
9
9
  authors = [{ name = "Hendric Voss", email = "hvoss@techfak.uni-bielefeld.de" }]
10
10
  readme = "README.md"
@@ -23,7 +23,9 @@ dependencies = [
23
23
  "scikit-image",
24
24
  "scikit-learn",
25
25
  "tensorboard",
26
- "pillow>=11.1.0"
26
+ "pillow>=11.1.0",
27
+ "shapely>=2.0.7",
28
+ "trimesh>=4.6.4"
27
29
  ]
28
30
 
29
31
  [tool.setuptools]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: AutoForge
3
- Version: 1.5.4
3
+ Version: 1.6.0
4
4
  Summary: AutoForge is a Python tool for generating 3D printed layered models from an input image.
5
5
  Author-email: Hendric Voss <hvoss@techfak.uni-bielefeld.de>
6
6
  License: CC BY-NC-SA 4.0
@@ -19,6 +19,8 @@ Requires-Dist: scikit-image
19
19
  Requires-Dist: scikit-learn
20
20
  Requires-Dist: tensorboard
21
21
  Requires-Dist: pillow>=11.1.0
22
+ Requires-Dist: shapely>=2.0.7
23
+ Requires-Dist: trimesh>=4.6.4
22
24
 
23
25
  # AutoForge
24
26
 
@@ -35,18 +37,14 @@ The pruning is set to a maximum of 8 color and 20 swaps, so each image uses at m
35
37
  <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/lofi.jpg" width="200" />
36
38
  <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/nature.jpg" width="200" />
37
39
  <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/cat.jpg" width="200" />
40
+ <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/chameleon.jpg" width="200" />
38
41
  </div>
39
42
  <div style="text-align: center;">
40
- <h3>Autoforge Output (75 color layers (3.0mm) + 10 gray background layers (0.4mm)) </h3>
43
+ <h3>Autoforge Output</h3>
41
44
  <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/lofi_discretized.png" width="200" />
42
45
  <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/nature_discretized.png" width="200" />
43
46
  <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/cat_discretized.png" width="200" />
44
- </div>
45
- <div style="text-align: center;">
46
- <h3>Imported Hueforge View</h3>
47
- <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/lofi_hueforge.png" width="200" />
48
- <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/nature_hueforge.png" width="200" />
49
- <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/cat_hueforge.png" width="200" />
47
+ <img src="https://github.com/hvoss-techfak/AutoForge/blob/main/images/chameleon_discretized.png" width="200" />
50
48
  </div>
51
49
  </div>
52
50
 
@@ -58,6 +56,7 @@ I would love to see what you made!
58
56
 
59
57
  - **Image-to-Model Conversion**: Converts an input image into a layered model suitable for 3D printing.
60
58
  - **Learned Optimization**: Optimizes per-pixel height and per-layer material assignments using PyTorch.
59
+ - **Learned Heightmap**: Optimizes the height of the layered model to create more detailed prints.
61
60
  - **Gumbel Softmax Sampling**: Leverages the Gumbel softmax method to decide material assignments for each layer.
62
61
  - **STL File Generation**: Exports an ASCII STL file based on the optimized height map.
63
62
  - **Swap Instructions**: Generates clear swap instructions for changing materials during printing.
@@ -69,11 +68,11 @@ I would love to see what you made!
69
68
 
70
69
  To install AutoForge, simply install the current version from PyPI:
71
70
  ```bash
72
- pip install autoforge
71
+ pip install -U autoforge
73
72
  ```
74
73
 
75
74
  If you have problems running the code on your gpu, please refer to the [Pytorch Homepage](https://pytorch.org/) for help. \
76
- Both CUDA and ROCm are supported, but you need to install the correct version of pytorch for your system.
75
+ CUDA, ROCm, and MPS (Apple Metal) are supported, but you need to install the correct version of pytorch for your system.
77
76
 
78
77
  ## Usage
79
78
 
@@ -90,35 +89,47 @@ autoforge --input_image path/to/input_image.jpg --csv_file path/to/materials.csv
90
89
 
91
90
  ### Command Line Arguments
92
91
 
93
- - `--config`: *(Optional)* Path to a configuration file with the settings.
94
- - `--input_image`: **(Required)** Path to the input image.
95
- - `--csv_file`: **(Required)** Path to the CSV file containing material data. The CSV should include columns for the brand, name, color (hex code), and TD values.
96
- - `--output_folder`: Folder where output files will be saved. (default: `./outputs`).
97
- - `--iterations`: Number of optimization iterations (default: 5000).
98
- - `--learning_rate`: Learning rate for the optimizer (default: 1e-2).
99
- - `--layer_height`: Layer thickness in millimeters (default: 0.04).
100
- - `--max_layers`: Maximum number of layers (default: 100). \
101
- **Note:** This is about 3mm + the background height
102
- - `--min_layers`: Minimum number of layers (default: 0). Used to limit height of pruning
103
- - `--background_height`: Height of the background in millimeters (default: 0.4). \
92
+ ### Command Line Arguments
93
+
94
+ - `--config` *(Optional)* Path to a configuration file with the settings.
95
+
96
+
97
+ - `--input_image` **(Required)** Path to the input image.
98
+ - `--csv_file` **(Required)** Path to the CSV file containing material data. The CSV should include columns for the brand, name, color (hex code), and TD values.
99
+
100
+ - `--output_folder` Folder where output files will be saved (default: `output`).
101
+ - `--iterations` Number of optimization iterations (default: 5000).
102
+ - `--learning_rate` Learning rate for optimization (default: 1e-2).
103
+ - `--layer_height` Layer thickness in millimeters (default: 0.04).
104
+ - `--max_layers` Maximum number of layers (default: 50).
105
+ **Note:** This is about 2mm + the background height
106
+ - `--background_height` Height of the background in millimeters (default: 0.4).
104
107
  **Note:** The background height must be divisible by the layer height.
105
- - `--background_color`: Background color in hexadecimal format (default: `#000000` aka Black). \
106
- **Note:** The solver currently assumes that you have a solid color in the background, which means a color with a TD value of 4 or less (if you have a background height of 0.4)
107
- - `--output_size`: Maximum dimension for target image (default: 1024).
108
- - `--solver_size`: Maximum dimension for solver (fast) image (default: 256). \
109
- **Note:** We solve on a smaller size as this is many times faster, but also a bit less accurate. Increase if you need more accuracy.
110
- - `--init_tau`: Initial tau value for Gumbel-Softmax (default: 1.0).
111
- - `--final_tau`: Final tau value for the Gumbel-Softmax formulation (default: 0.01).
112
- - `--stl_output_size`: Size of the output stl file in mm (default: 200) (20cm).
113
- - `--visualize`: Flag to enable live visualization of the composite image during optimization.
114
- - `--tensorboard`: Enable TensorBoard logging
115
- - `--run_name`: Name of the run used for TensorBoard logging (optional).
116
- - `--perform_pruning`: Perform pruning after optimization (default: True). \
108
+ - `--background_color` Background color in hexadecimal format (default: `#000000` aka Black).
109
+ **Note:** The solver currently assumes that you have a solid color in the background, which means a color with a TD value of 4 or less (if you have a background height of 0.4).
110
+ - `--init_tau` Initial tau value for Gumbel-Softmax (default: 1.0).
111
+ - `--final_tau` Final tau value for the Gumbel-Softmax formulation (default: 0.01).
112
+ - `--visualize` Flag to enable live visualization of the composite image during optimization.
113
+ - `--stl_output_size` Size of the longest dimension of the output STL file in millimeters (default: 150).
114
+ - `--nozzle_diameter` Diameter of the printer nozzle in millimeters (default: 0.4).
115
+ **Note:** Details smaller than half this value will be ignored.
116
+ - `--early_stopping` Number of steps without improvement before stopping (default: 1500).
117
+ -
118
+
119
+ - `--perform_pruning` Perform pruning after optimization (default: True).
117
120
  **Note:** This is highly recommended even if you don't have a color/color swap limit, as it actually increases the quality of the output.
118
- - `--pruning_max_colors`: Max number of colors allowed after pruning (default: 100).
119
- - `--pruning_max_swaps`: Max number of swaps allowed after pruning (default: 100).
120
- - `--pruning_max_layers`: Max number of layers allowed after pruning (default: 75).
121
- - `--random_seed`: Random seed for reproducibility (default: 0 (disabled) ).
121
+ - `--pruning_max_colors` Max number of colors allowed after pruning (default: 100).
122
+ - `--pruning_max_swaps` Max number of swaps allowed after pruning (default: 100).
123
+ - `--pruning_max_layer` Max number of layers allowed after pruning (default: 75).
124
+ - `--min_layers` Minimum number of layers (default: 0). Used to limit height of pruning.
125
+ - `--random_seed` Random seed for reproducibility (default: 0 (disabled)).
126
+ - `--mps` Flag to use the Metal Performance Shaders (MPS) backend if available.
127
+
128
+
129
+ - `--tensorboard` Flag to enable TensorBoard logging.
130
+ - `--run_name` *(Optional)* Name of the run used for TensorBoard logging.
131
+
132
+
122
133
 
123
134
  ### Experimental Deph Anything V2 parameters
124
135
  I got a request to add an initializing function that takes the original depth of the image into account when initializing. \
@@ -129,7 +140,6 @@ I currently don't recommend it as the output is not as good as without it, but I
129
140
  - `--use_depth_anything`: Use a depth anything v2 model to initialize the height map (default: False).
130
141
  **Note:** This will give you a nice background/foreground separation, but will could degrade quality in some cases.
131
142
  **Note:** In addition you need the VRAM to run the depth model.
132
-
133
143
  - `--depth_strength`: Weight for blending even spacing with the cluster’s average depth when using depth initialization. (default: 0.25)
134
144
  - `--depth_threshold`: Threshold for splitting two distinct colors based on depth. (default: 0.05)
135
145
  - `--min_cluster_value`: Minimum normalized value for the lowest cluster (to avoid pure black). (default: 0.1)
@@ -142,22 +152,15 @@ I currently don't recommend it as the output is not as good as without it, but I
142
152
 
143
153
  After running, the following files will be created in your specified output folder:
144
154
 
145
- - **Discrete Composite Image**: `discrete_comp.png`
155
+ - **Discrete Composite Image**: `final_model.png`
146
156
  - **STL File**: `final_model.stl`
157
+ - **Hueforge Project File**: `project_file.hfp`
147
158
  - **Swap Instructions**: `swap_instructions.txt`
148
159
 
149
- Just a heads-up, this program is mainly concerned with realistic output and will give you VERY long swap instructions.
150
- Expect to switch your filament every 1-2 layers!
151
-
152
- For more artistic control or to reduce the number of swaps, consider buying [Hueforge](https://shop.thehueforge.com/).
153
-
154
160
  ## Known Bugs
155
161
 
156
- - There is a color discrepancy between our output and hueforge. If anyone has an idea what the problem is, please don't hesitate to submit a pull request :) \
157
- Although I would love to be it fully color compatible with hueforge, I don't think this will happen without a lot of work or the hueforge source code.
158
162
  - The optimizer can sometimes get stuck in a local minimum. If this happens, try running the optimization again with different settings.
159
163
  - Hueforge can't open STL files under linux. This is a known bug in hueforge.
160
- - The first version used a learnable height map which was nice but resulted in a lot of problems. Right now we compute the height map from the luminance values and slightly adjust the result. If somebody has an idea to make this better, please don't hesitate to submit a pull request :)
161
164
 
162
165
  ## License
163
166
 
@@ -181,9 +184,22 @@ AutoForge makes use of several open source libraries:
181
184
  - [TQDM](https://github.com/tqdm/tqdm)
182
185
  - [ConfigArgParse](https://github.com/bw2/ConfigArgParse)
183
186
 
184
- Example Images:
185
- <a href="https://www.vecteezy.com/free-photos/anime-girl">Anime Girl Stock photos by Vecteezy</a>
186
- <a href="https://www.vecteezy.com/free-photos/nature">Nature Stock photos by Vecteezy</a>
187
- <a href="https://www.vecteezy.com/free-photos/ai-generated">Ai Generated Stock photos by Vecteezy</a>
187
+ Example Images: \
188
+ <a href="https://www.vecteezy.com/free-photos/nature">Nature Stock photos by Vecteezy</a> \
189
+ <a href="https://www.vecteezy.com/free-photos/ai-generated">Ai Generated Stock photos by Vecteezy</a> \
190
+ <a href="https://www.vecteezy.com/free-photos/animal">Animal Stock photos by Vecteezy</a> \
191
+ <a href="https://www.vecteezy.com/free-photos/people">People Stock photos by Vecteezy</a> \
192
+ <a href="https://www.vecteezy.com/free-photos/psychedelic">Psychedelic Stock photos by Vecteezy</a> \
193
+ <a href="https://www.vecteezy.com/free-photos/ocean">Ocean Stock photos by Vecteezy</a> \
194
+ <a href="https://www.vecteezy.com/free-photos/psychic">Psychic Stock photos by Vecteezy</a> \
195
+ <a href="https://www.vecteezy.com/free-photos/psychedelic">Psychedelic Stock photos by Vecteezy</a> \
196
+ <a href="https://www.vecteezy.com/free-photos/pattern">Pattern Stock photos by Vecteezy</a> \
197
+ <a href="https://www.vecteezy.com/free-photos/forest">Forest Stock photos by Vecteezy</a> \
198
+ <a href="https://www.vecteezy.com/free-photos/stick-figure-kids">Stick Figure Kids Stock photos by Vecteezy</a> \
199
+ <a href="https://www.vecteezy.com/free-photos/forest">Forest Stock photos by Vecteezy</a> \
200
+ <a href="https://www.vecteezy.com/free-photos/nature">Nature Stock photos by Vecteezy</a> \
201
+ <a href="https://www.vecteezy.com/free-photos/ai-generated">Ai Generated Stock photos by Vecteezy</a>\
202
+ <a href="https://www.vecteezy.com/free-photos/animal">Animal Stock photos by Vecteezy</a>
203
+
188
204
 
189
205
  Happy printing!