autoforge 1.6.2__tar.gz → 1.6.3__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 (41) hide show
  1. {autoforge-1.6.2 → autoforge-1.6.3}/PKG-INFO +2 -2
  2. {autoforge-1.6.2 → autoforge-1.6.3}/README.md +1 -1
  3. {autoforge-1.6.2 → autoforge-1.6.3}/pyproject.toml +1 -1
  4. {autoforge-1.6.2 → autoforge-1.6.3}/src/AutoForge.egg-info/PKG-INFO +2 -2
  5. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Helper/Heightmaps/ChristofidesHeightMap.py +22 -25
  6. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/auto_forge.py +1 -1
  7. {autoforge-1.6.2 → autoforge-1.6.3}/setup.cfg +0 -0
  8. {autoforge-1.6.2 → autoforge-1.6.3}/src/AutoForge.egg-info/SOURCES.txt +0 -0
  9. {autoforge-1.6.2 → autoforge-1.6.3}/src/AutoForge.egg-info/dependency_links.txt +0 -0
  10. {autoforge-1.6.2 → autoforge-1.6.3}/src/AutoForge.egg-info/entry_points.txt +0 -0
  11. {autoforge-1.6.2 → autoforge-1.6.3}/src/AutoForge.egg-info/requires.txt +0 -0
  12. {autoforge-1.6.2 → autoforge-1.6.3}/src/AutoForge.egg-info/top_level.txt +0 -0
  13. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Gui/__init__.py +0 -0
  14. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Gui/browser_gui/Views/__init__.py +0 -0
  15. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Gui/browser_gui/Views/backend_database.py +0 -0
  16. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Gui/browser_gui/Views/filament_editor.py +0 -0
  17. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Gui/browser_gui/app.py +0 -0
  18. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Gui/browser_gui/main.py +0 -0
  19. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Helper/CAdamW.py +0 -0
  20. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Helper/FilamentHelper.py +0 -0
  21. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Helper/Heightmaps/DepthEstimateHeightMap.py +0 -0
  22. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Helper/Heightmaps/OldHeightmap.py +0 -0
  23. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Helper/Heightmaps/__init__.py +0 -0
  24. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Helper/ImageHelper.py +0 -0
  25. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Helper/OptimizerHelper.py +0 -0
  26. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Helper/OutputHelper.py +0 -0
  27. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Helper/PruningHelper.py +0 -0
  28. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Helper/__init__.py +0 -0
  29. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Helper/filamentcolors_library.py +0 -0
  30. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Init_comparer/__init__.py +0 -0
  31. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Init_comparer/auto_forge_init_check.py +0 -0
  32. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Init_comparer/plot_results.py +0 -0
  33. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Loss/LossFunctions.py +0 -0
  34. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Loss/PerceptionLoss.py +0 -0
  35. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Loss/__init__.py +0 -0
  36. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Misc/__init__.py +0 -0
  37. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Misc/color_fit_all.py +0 -0
  38. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Modules/Optimizer.py +0 -0
  39. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/Modules/__init__.py +0 -0
  40. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/__init__.py +0 -0
  41. {autoforge-1.6.2 → autoforge-1.6.3}/src/autoforge/__main__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: AutoForge
3
- Version: 1.6.2
3
+ Version: 1.6.3
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
@@ -61,7 +61,7 @@ The pruning is set to a maximum of 8 color and 20 swaps, so each image uses at m
61
61
 
62
62
  ## [Google Colab Notebook](https://colab.research.google.com/drive/13sWCss9-ew2xnoJl4c4SSpComSNi-1ih)
63
63
 
64
- If you're new to Google Colab, follow these simple steps to run the notebook:
64
+ If you're new to Google Colab, follow these simple steps to run autoforge and get your output:
65
65
 
66
66
  1. **Open the Notebook:**
67
67
  Click [here](https://colab.research.google.com/drive/13sWCss9-ew2xnoJl4c4SSpComSNi-1ih) to open the notebook in Google Colab.
@@ -37,7 +37,7 @@ The pruning is set to a maximum of 8 color and 20 swaps, so each image uses at m
37
37
 
38
38
  ## [Google Colab Notebook](https://colab.research.google.com/drive/13sWCss9-ew2xnoJl4c4SSpComSNi-1ih)
39
39
 
40
- If you're new to Google Colab, follow these simple steps to run the notebook:
40
+ If you're new to Google Colab, follow these simple steps to run autoforge and get your output:
41
41
 
42
42
  1. **Open the Notebook:**
43
43
  Click [here](https://colab.research.google.com/drive/13sWCss9-ew2xnoJl4c4SSpComSNi-1ih) to open the notebook in Google Colab.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "AutoForge"
7
- version="1.6.2"
7
+ version="1.6.3"
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"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: AutoForge
3
- Version: 1.6.2
3
+ Version: 1.6.3
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
@@ -61,7 +61,7 @@ The pruning is set to a maximum of 8 color and 20 swaps, so each image uses at m
61
61
 
62
62
  ## [Google Colab Notebook](https://colab.research.google.com/drive/13sWCss9-ew2xnoJl4c4SSpComSNi-1ih)
63
63
 
64
- If you're new to Google Colab, follow these simple steps to run the notebook:
64
+ If you're new to Google Colab, follow these simple steps to run autoforge and get your output:
65
65
 
66
66
  1. **Open the Notebook:**
67
67
  Click [here](https://colab.research.google.com/drive/13sWCss9-ew2xnoJl4c4SSpComSNi-1ih) to open the notebook in Google Colab.
@@ -240,25 +240,28 @@ def create_mapping(final_ordering, labs, all_labels):
240
240
 
241
241
  def tsp_order_christofides_path(nodes, labs, bg, fg):
242
242
  """
243
- nodes: list of cluster indices (must include bg and fg)
243
+ Ensure that the background and foreground nodes are always in the TSP cycle.
244
+ nodes: list of cluster indices (ideally including bg and fg)
244
245
  labs: Lab-space coordinates (indexed by cluster index)
245
246
  bg, fg: background and foreground cluster indices
246
-
247
247
  Returns an ordering (list of cluster indices) that contains all nodes,
248
248
  starts with bg and ends with fg.
249
249
  """
250
+ # Guarantee that bg and fg are included in nodes.
251
+ nodes = list(set(nodes) | {bg, fg})
252
+
250
253
  artificial = -1
251
- augmented_nodes = nodes + [artificial]
252
254
  LARGE = 1e6
255
+ n = len(nodes)
253
256
 
254
- # Precompute the distance matrix for original nodes.
257
+ # Precompute the distance matrix for the given nodes.
255
258
  D = build_distance_matrix(labs, nodes)
256
- n = len(nodes)
257
259
 
258
- # Build an augmented matrix of size (n+1)x(n+1).
260
+ # Build an augmented (n+1)x(n+1) matrix.
259
261
  aug_mat = np.zeros((n + 1, n + 1))
260
262
  aug_mat[:n, :n] = D
261
- # For the artificial node, set cost = 0 for bg/fg, LARGE otherwise.
263
+
264
+ # For the artificial node, set cost = 0 for bg/fg and LARGE for others.
262
265
  for i, u in enumerate(nodes):
263
266
  if u in {bg, fg}:
264
267
  aug_mat[i, n] = 0.0
@@ -268,32 +271,33 @@ def tsp_order_christofides_path(nodes, labs, bg, fg):
268
271
  aug_mat[n, i] = LARGE
269
272
  aug_mat[n, n] = 0.0
270
273
 
271
- # Convert the augmented matrix into a graph dictionary.
274
+ # Create augmented nodes list.
272
275
  aug_nodes = nodes + [artificial]
273
276
  graph = matrix_to_graph(aug_mat, aug_nodes)
274
277
 
275
- # Run Christofides on the augmented graph.
278
+ # Run Christofides algorithm on the augmented graph.
276
279
  cycle = christofides_tsp(graph)
277
- # Remove the artificial node.
280
+ # Remove the artificial node if present.
278
281
  cycle = [node for node in cycle if node != artificial]
279
282
 
283
+ # Ensure bg and fg are in the cycle.
284
+ if bg not in cycle:
285
+ cycle.insert(0, bg)
286
+ if fg not in cycle:
287
+ cycle.append(fg)
288
+
280
289
  # Rotate the cycle so that bg is first.
281
- if bg in cycle:
290
+ if cycle[0] != bg:
282
291
  idx = cycle.index(bg)
283
292
  cycle = cycle[idx:] + cycle[:idx]
284
- else:
285
- raise ValueError("Background node missing from cycle")
286
293
 
287
294
  # Force fg to be the last element.
288
- if fg not in cycle:
289
- raise ValueError("Foreground node missing from cycle")
290
295
  if cycle[-1] != fg:
291
296
  cycle.remove(fg)
292
297
  cycle.append(fg)
293
298
 
294
- # --- NEW: Check if reversing the internal order yields a lower ordering metric ---
299
+ # Optionally, check if reversing the internal order improves the ordering metric.
295
300
  if len(cycle) > 2:
296
- # Reverse the ordering of the nodes between bg and fg.
297
301
  reversed_cycle = [cycle[0]] + cycle[1:-1][::-1] + [cycle[-1]]
298
302
  if compute_ordering_metric(reversed_cycle, labs) < compute_ordering_metric(
299
303
  cycle, labs
@@ -449,14 +453,7 @@ def init_height_map(
449
453
  nodes = unique_clusters
450
454
 
451
455
  # Get the ordering via TSP ordering function.
452
- for i in range(50):
453
- try:
454
- final_ordering = tsp_order_christofides_path(nodes, labs, bg_cluster, fg_cluster)
455
- break
456
- except Exception:
457
- print(f"Failed to find ordering, retrying {i+1}/10")
458
- if i == 49:
459
- raise ValueError("Failed to find ordering after 50 retries")
456
+ final_ordering = tsp_order_christofides_path(nodes, labs, bg_cluster, fg_cluster)
460
457
 
461
458
  # Optionally prune out outliers.
462
459
  final_ordering = prune_ordering(
@@ -302,7 +302,7 @@ def main():
302
302
  args.layer_height,
303
303
  bgr_tuple,
304
304
  random_seed=random_seed,
305
- num_threads=16,
305
+ num_threads=8,
306
306
  init_method="kmeans",
307
307
  cluster_layers=18,
308
308
  lab_space=True,
File without changes