autoforge 1.9.0__tar.gz → 1.9.2__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.
- {autoforge-1.9.0 → autoforge-1.9.2}/PKG-INFO +1 -1
- {autoforge-1.9.0 → autoforge-1.9.2}/pyproject.toml +1 -1
- {autoforge-1.9.0 → autoforge-1.9.2}/src/AutoForge.egg-info/PKG-INFO +1 -1
- {autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/Helper/Heightmaps/ChristofidesHeightMap.py +42 -22
- {autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/auto_forge.py +23 -35
- {autoforge-1.9.0 → autoforge-1.9.2}/README.md +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/setup.cfg +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/AutoForge.egg-info/SOURCES.txt +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/AutoForge.egg-info/dependency_links.txt +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/AutoForge.egg-info/entry_points.txt +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/AutoForge.egg-info/requires.txt +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/AutoForge.egg-info/top_level.txt +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/Helper/CAdamW.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/Helper/FilamentHelper.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/Helper/Heightmaps/DepthEstimateHeightMap.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/Helper/Heightmaps/__init__.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/Helper/ImageHelper.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/Helper/OptimizerHelper.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/Helper/OtherHelper.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/Helper/OutputHelper.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/Helper/PruningHelper.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/Helper/__init__.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/Helper/filamentcolors_library.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/Init_comparer/__init__.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/Init_comparer/auto_forge_init_check.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/Init_comparer/plot_results.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/Loss/LossFunctions.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/Loss/PerceptionLoss.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/Loss/__init__.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/Misc/__init__.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/Misc/color_fit_all.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/Modules/Optimizer.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/Modules/__init__.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/__init__.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/__main__.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/priority_mask_editor.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/tests/test_cadamw.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/tests/test_christofides_height_map.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/tests/test_christofides_heightmap.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/tests/test_depth_adjusted_height_map.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/tests/test_depth_estimate_height_map.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/tests/test_end_to_end_optimizer.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/tests/test_filament_and_output.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/tests/test_filament_helper.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/tests/test_flatforge.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/tests/test_heightmap_init.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/tests/test_image_helper.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/tests/test_loss_functions.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/tests/test_optimizer_helper.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/tests/test_optimizer_module.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/tests/test_optimizer_smoke.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/tests/test_output_helper.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/tests/test_output_helper_extended.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/tests/test_perception_and_pruning.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/tests/test_property_based.py +0 -0
- {autoforge-1.9.0 → autoforge-1.9.2}/tests/test_pruning_helper.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "AutoForge"
|
|
7
|
-
version="1.9.
|
|
7
|
+
version="1.9.2"
|
|
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"
|
{autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/Helper/Heightmaps/ChristofidesHeightMap.py
RENAMED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import os
|
|
2
1
|
import random
|
|
3
2
|
from typing import Optional
|
|
4
3
|
|
|
@@ -613,7 +612,8 @@ def run_init_threads(
|
|
|
613
612
|
background_tuple,
|
|
614
613
|
eps=1e-6,
|
|
615
614
|
random_seed=None,
|
|
616
|
-
num_threads=
|
|
615
|
+
num_threads=4,
|
|
616
|
+
num_runs=32,
|
|
617
617
|
init_method="kmeans",
|
|
618
618
|
cluster_layers=None,
|
|
619
619
|
material_colors=None,
|
|
@@ -625,26 +625,46 @@ def run_init_threads(
|
|
|
625
625
|
random_seed = np.random.randint(1e6)
|
|
626
626
|
lab_space = True
|
|
627
627
|
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
628
|
+
if num_threads > 1:
|
|
629
|
+
|
|
630
|
+
tasks = [
|
|
631
|
+
delayed(init_height_map)(
|
|
632
|
+
target,
|
|
633
|
+
max_layers,
|
|
634
|
+
h,
|
|
635
|
+
background_tuple,
|
|
636
|
+
eps,
|
|
637
|
+
random_seed + i,
|
|
638
|
+
init_method=init_method,
|
|
639
|
+
cluster_layers=cluster_layers,
|
|
640
|
+
lab_space=lab_space,
|
|
641
|
+
material_colors=material_colors,
|
|
642
|
+
focus_map=focus_map,
|
|
643
|
+
focus_boost=focus_boost,
|
|
644
|
+
)
|
|
645
|
+
for i in range(num_runs)
|
|
646
|
+
]
|
|
647
|
+
|
|
648
|
+
# Execute tasks in parallel; adjust n_jobs to match your available cores
|
|
649
|
+
results = Parallel(n_jobs=num_threads, verbose=10)(tasks)
|
|
650
|
+
|
|
651
|
+
else:
|
|
652
|
+
results = [
|
|
653
|
+
init_height_map(
|
|
654
|
+
target,
|
|
655
|
+
max_layers,
|
|
656
|
+
h,
|
|
657
|
+
background_tuple,
|
|
658
|
+
eps,
|
|
659
|
+
random_seed + i,
|
|
660
|
+
init_method=init_method,
|
|
661
|
+
cluster_layers=cluster_layers,
|
|
662
|
+
lab_space=lab_space,
|
|
663
|
+
material_colors=material_colors,
|
|
664
|
+
focus_map=focus_map,
|
|
665
|
+
focus_boost=focus_boost,
|
|
666
|
+
) for i in range(num_runs)
|
|
667
|
+
]
|
|
648
668
|
|
|
649
669
|
metrics = [(r[2] / r[3]) / (r[4] + 1e-6) for r in results]
|
|
650
670
|
mean_metric = np.mean(metrics)
|
|
@@ -15,6 +15,7 @@ The implementation intentionally keeps side-effects (disk writes / prints) order
|
|
|
15
15
|
preserve prior behavior. Helper functions are factored out for readability; no functional
|
|
16
16
|
behavior should have changed relative to the previous monolithic version.
|
|
17
17
|
"""
|
|
18
|
+
|
|
18
19
|
import argparse
|
|
19
20
|
import sys
|
|
20
21
|
import os
|
|
@@ -154,7 +155,6 @@ def parse_args() -> argparse.Namespace:
|
|
|
154
155
|
|
|
155
156
|
parser.add_argument(
|
|
156
157
|
"--visualize",
|
|
157
|
-
type=bool,
|
|
158
158
|
default=True,
|
|
159
159
|
help="Enable visualization during optimization",
|
|
160
160
|
action=argparse.BooleanOptionalAction,
|
|
@@ -435,9 +435,7 @@ def _auto_select_background_color(
|
|
|
435
435
|
f.write(f"chosen_filament_color={chosen_hex}\n")
|
|
436
436
|
f.write(f"closest_filament_index={closest_idx}\n")
|
|
437
437
|
if getattr(args, "background_material_name", None):
|
|
438
|
-
f.write(
|
|
439
|
-
f"closest_filament_name={args.background_material_name}\n"
|
|
440
|
-
)
|
|
438
|
+
f.write(f"closest_filament_name={args.background_material_name}\n")
|
|
441
439
|
except Exception:
|
|
442
440
|
traceback.print_exc()
|
|
443
441
|
else:
|
|
@@ -447,7 +445,10 @@ def _auto_select_background_color(
|
|
|
447
445
|
|
|
448
446
|
|
|
449
447
|
def _prepare_background_and_materials(
|
|
450
|
-
args,
|
|
448
|
+
args,
|
|
449
|
+
device: torch.device,
|
|
450
|
+
material_colors_np: np.ndarray,
|
|
451
|
+
material_TDs_np: np.ndarray,
|
|
451
452
|
) -> Tuple[Tuple[int, int, int], torch.Tensor, torch.Tensor, torch.Tensor]:
|
|
452
453
|
"""Create torch tensors for materials & background color.
|
|
453
454
|
|
|
@@ -566,11 +567,12 @@ def _initialize_heightmap(
|
|
|
566
567
|
args.layer_height,
|
|
567
568
|
bgr_tuple,
|
|
568
569
|
random_seed=random_seed,
|
|
569
|
-
num_threads=
|
|
570
|
+
num_threads=4,
|
|
570
571
|
init_method="kmeans",
|
|
571
572
|
cluster_layers=args.num_init_cluster_layers,
|
|
572
573
|
material_colors=material_colors_np,
|
|
573
574
|
focus_map=None,
|
|
575
|
+
num_runs=args.num_init_rounds,
|
|
574
576
|
)
|
|
575
577
|
)
|
|
576
578
|
return pixel_height_logits_init, global_logits_init, pixel_height_labels
|
|
@@ -648,7 +650,9 @@ def _build_optimizer(
|
|
|
648
650
|
return optimizer
|
|
649
651
|
|
|
650
652
|
|
|
651
|
-
def _run_optimization_loop(
|
|
653
|
+
def _run_optimization_loop(
|
|
654
|
+
optimizer: FilamentOptimizer, args, device: torch.device
|
|
655
|
+
) -> None:
|
|
652
656
|
"""Execute the main gradient-based optimization iterations.
|
|
653
657
|
|
|
654
658
|
Features:
|
|
@@ -729,26 +733,6 @@ def _post_optimize_and_export(
|
|
|
729
733
|
optimizer.pixel_height_labels = torch.tensor(
|
|
730
734
|
pixel_height_labels, dtype=torch.int32, device=device
|
|
731
735
|
)
|
|
732
|
-
if hasattr(optimizer, "height_residual"):
|
|
733
|
-
with torch.no_grad():
|
|
734
|
-
hr = optimizer.height_residual.detach()
|
|
735
|
-
full_h, full_w = optimizer.pixel_height_logits.shape[:2]
|
|
736
|
-
if hr.shape != (full_h, full_w):
|
|
737
|
-
hr4d = hr.unsqueeze(0).unsqueeze(0)
|
|
738
|
-
hr_full = (
|
|
739
|
-
torch.nn.functional.interpolate(
|
|
740
|
-
hr4d,
|
|
741
|
-
size=(full_h, full_w),
|
|
742
|
-
mode="bilinear",
|
|
743
|
-
align_corners=False,
|
|
744
|
-
)
|
|
745
|
-
.squeeze(0)
|
|
746
|
-
.squeeze(0)
|
|
747
|
-
)
|
|
748
|
-
optimizer.height_residual.data = hr_full.to(device)
|
|
749
|
-
optimizer.best_params["height_residual"] = (
|
|
750
|
-
optimizer.height_residual.detach().clone()
|
|
751
|
-
)
|
|
752
736
|
if focus_map_proc is not None and focus_map_full is not None:
|
|
753
737
|
optimizer.focus_map = focus_map_full
|
|
754
738
|
|
|
@@ -932,8 +916,10 @@ def start(args) -> float:
|
|
|
932
916
|
)
|
|
933
917
|
|
|
934
918
|
# Prepare background color tensor and material tensors
|
|
935
|
-
bgr_tuple, background, material_colors, material_TDs =
|
|
936
|
-
|
|
919
|
+
bgr_tuple, background, material_colors, material_TDs = (
|
|
920
|
+
_prepare_background_and_materials(
|
|
921
|
+
args, device, material_colors_np, material_TDs_np
|
|
922
|
+
)
|
|
937
923
|
)
|
|
938
924
|
|
|
939
925
|
# Compute sizes
|
|
@@ -951,12 +937,14 @@ def start(args) -> float:
|
|
|
951
937
|
focus_map_full = _load_priority_mask(args, output_img_np, device)
|
|
952
938
|
|
|
953
939
|
# Initialize heightmap
|
|
954
|
-
pixel_height_logits_init, global_logits_init, pixel_height_labels =
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
940
|
+
pixel_height_logits_init, global_logits_init, pixel_height_labels = (
|
|
941
|
+
_initialize_heightmap(
|
|
942
|
+
args,
|
|
943
|
+
output_img_np,
|
|
944
|
+
bgr_tuple,
|
|
945
|
+
material_colors_np,
|
|
946
|
+
random_seed,
|
|
947
|
+
)
|
|
960
948
|
)
|
|
961
949
|
|
|
962
950
|
# Prepare processing targets and focus map (processing-res)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{autoforge-1.9.0 → autoforge-1.9.2}/src/autoforge/Helper/Heightmaps/DepthEstimateHeightMap.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|