autoforge 1.8.1__tar.gz → 1.8.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.8.1 → autoforge-1.8.2}/PKG-INFO +1 -1
- {autoforge-1.8.1 → autoforge-1.8.2}/pyproject.toml +1 -1
- {autoforge-1.8.1 → autoforge-1.8.2}/src/AutoForge.egg-info/PKG-INFO +1 -1
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Helper/OptimizerHelper.py +0 -35
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Helper/PruningHelper.py +3 -8
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Modules/Optimizer.py +57 -17
- {autoforge-1.8.1 → autoforge-1.8.2}/README.md +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/setup.cfg +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/AutoForge.egg-info/SOURCES.txt +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/AutoForge.egg-info/dependency_links.txt +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/AutoForge.egg-info/entry_points.txt +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/AutoForge.egg-info/requires.txt +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/AutoForge.egg-info/top_level.txt +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Gui/__init__.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Gui/browser_gui/Views/__init__.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Gui/browser_gui/Views/backend_database.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Gui/browser_gui/Views/filament_editor.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Gui/browser_gui/app.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Gui/browser_gui/main.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Helper/CAdamW.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Helper/FilamentHelper.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Helper/Heightmaps/ChristofidesHeightMap.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Helper/Heightmaps/DepthEstimateHeightMap.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Helper/Heightmaps/OldHeightmap.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Helper/Heightmaps/__init__.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Helper/ImageHelper.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Helper/OutputHelper.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Helper/__init__.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Helper/filamentcolors_library.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Init_comparer/__init__.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Init_comparer/auto_forge_init_check.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Init_comparer/plot_results.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Loss/LossFunctions.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Loss/PerceptionLoss.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Loss/__init__.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Misc/__init__.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Misc/color_fit_all.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Modules/__init__.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/__init__.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/__main__.py +0 -0
- {autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/auto_forge.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "AutoForge"
|
|
7
|
-
version="1.8.
|
|
7
|
+
version="1.8.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"
|
|
@@ -277,38 +277,3 @@ def composite_image_disc(
|
|
|
277
277
|
comp = comp + rem_after.unsqueeze(-1) * background # [H,W,3]
|
|
278
278
|
|
|
279
279
|
return comp * 255.0
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
def discretize_solution(
|
|
283
|
-
params: dict, tau_global: float, h: float, max_layers: int, rng_seed: int = -1
|
|
284
|
-
):
|
|
285
|
-
"""
|
|
286
|
-
Convert continuous logs to discrete layer counts and discrete color IDs.
|
|
287
|
-
|
|
288
|
-
Args:
|
|
289
|
-
params (dict): Dictionary containing the parameters 'pixel_height_logits' and 'global_logits'.
|
|
290
|
-
tau_global (float): Temperature parameter for global material assignment.
|
|
291
|
-
h (float): Height of each layer.
|
|
292
|
-
max_layers (int): Maximum number of layers.
|
|
293
|
-
rng_seed (int, optional): Random seed for deterministic sampling. Defaults to -1.
|
|
294
|
-
|
|
295
|
-
Returns:
|
|
296
|
-
tuple: A tuple containing:
|
|
297
|
-
- torch.Tensor: Discrete global material assignments, shape [max_layers].
|
|
298
|
-
- torch.Tensor: Discrete height image, shape [H, W].
|
|
299
|
-
"""
|
|
300
|
-
pixel_height_logits = params["pixel_height_logits"]
|
|
301
|
-
global_logits = params["global_logits"]
|
|
302
|
-
pixel_heights = (max_layers * h) * torch.sigmoid(pixel_height_logits)
|
|
303
|
-
discrete_height_image = torch.round(pixel_heights / h).to(torch.int32)
|
|
304
|
-
discrete_height_image = torch.clamp(discrete_height_image, 0, max_layers)
|
|
305
|
-
|
|
306
|
-
num_layers = global_logits.shape[0]
|
|
307
|
-
discrete_global_vals = []
|
|
308
|
-
for j in range(num_layers):
|
|
309
|
-
p = deterministic_gumbel_softmax(
|
|
310
|
-
global_logits[j], tau_global, hard=True, rng_seed=rng_seed + j
|
|
311
|
-
)
|
|
312
|
-
discrete_global_vals.append(torch.argmax(p))
|
|
313
|
-
discrete_global = torch.stack(discrete_global_vals, dim=0)
|
|
314
|
-
return discrete_global, discrete_height_image
|
|
@@ -6,7 +6,7 @@ from tqdm import tqdm
|
|
|
6
6
|
from joblib import Parallel, delayed
|
|
7
7
|
import threading
|
|
8
8
|
|
|
9
|
-
from autoforge.Helper.OptimizerHelper import
|
|
9
|
+
from autoforge.Helper.OptimizerHelper import composite_image_disc
|
|
10
10
|
from autoforge.Loss.LossFunctions import compute_loss
|
|
11
11
|
from autoforge.Modules.Optimizer import FilamentOptimizer
|
|
12
12
|
|
|
@@ -349,16 +349,11 @@ def remove_layer_from_solution(
|
|
|
349
349
|
new_max_layers (int): Updated number of layers.
|
|
350
350
|
"""
|
|
351
351
|
# Get the current discrete height image (used to decide which pixels need adjusting)
|
|
352
|
-
|
|
353
352
|
effective_logits = optimizer._apply_height_offset(
|
|
354
353
|
params["pixel_height_logits"], params["height_offsets"]
|
|
355
354
|
)
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
{
|
|
359
|
-
"pixel_height_logits": effective_logits,
|
|
360
|
-
"global_logits": params["global_logits"],
|
|
361
|
-
},
|
|
355
|
+
_, disc_height = optimizer.discretize_solution(
|
|
356
|
+
params,
|
|
362
357
|
final_tau,
|
|
363
358
|
h,
|
|
364
359
|
current_max_layers,
|
|
@@ -9,9 +9,9 @@ from tqdm import tqdm
|
|
|
9
9
|
|
|
10
10
|
from autoforge.Helper.CAdamW import CAdamW
|
|
11
11
|
from autoforge.Helper.OptimizerHelper import (
|
|
12
|
-
discretize_solution,
|
|
13
12
|
composite_image_cont,
|
|
14
13
|
composite_image_disc,
|
|
14
|
+
deterministic_gumbel_softmax,
|
|
15
15
|
)
|
|
16
16
|
from autoforge.Loss.LossFunctions import loss_fn, compute_loss
|
|
17
17
|
|
|
@@ -115,6 +115,7 @@ class FilamentOptimizer:
|
|
|
115
115
|
self.params = {
|
|
116
116
|
"pixel_height_logits": self.pixel_height_logits,
|
|
117
117
|
"global_logits": global_logits_init,
|
|
118
|
+
"height_offsets": self.height_offsets,
|
|
118
119
|
}
|
|
119
120
|
|
|
120
121
|
# Tau schedule
|
|
@@ -303,6 +304,50 @@ class FilamentOptimizer:
|
|
|
303
304
|
|
|
304
305
|
return loss
|
|
305
306
|
|
|
307
|
+
def discretize_solution(
|
|
308
|
+
self,
|
|
309
|
+
params: dict,
|
|
310
|
+
tau_global: float,
|
|
311
|
+
h: float,
|
|
312
|
+
max_layers: int,
|
|
313
|
+
rng_seed: int = -1,
|
|
314
|
+
):
|
|
315
|
+
"""
|
|
316
|
+
Convert continuous logs to discrete layer counts and discrete color IDs.
|
|
317
|
+
|
|
318
|
+
Args:
|
|
319
|
+
params (dict): Dictionary containing the parameters 'pixel_height_logits' and 'global_logits'.
|
|
320
|
+
tau_global (float): Temperature parameter for global material assignment.
|
|
321
|
+
h (float): Height of each layer.
|
|
322
|
+
max_layers (int): Maximum number of layers.
|
|
323
|
+
rng_seed (int, optional): Random seed for deterministic sampling. Defaults to -1.
|
|
324
|
+
|
|
325
|
+
Returns:
|
|
326
|
+
tuple: A tuple containing:
|
|
327
|
+
- torch.Tensor: Discrete global material assignments, shape [max_layers].
|
|
328
|
+
- torch.Tensor: Discrete height image, shape [H, W].
|
|
329
|
+
"""
|
|
330
|
+
pixel_logits = params["pixel_height_logits"]
|
|
331
|
+
pixel_offset = params["height_offsets"]
|
|
332
|
+
effective_logits = self._apply_height_offset(
|
|
333
|
+
pixel_logits=pixel_logits, height_offsets=pixel_offset
|
|
334
|
+
)
|
|
335
|
+
|
|
336
|
+
global_logits = params["global_logits"]
|
|
337
|
+
pixel_heights = (max_layers * h) * torch.sigmoid(effective_logits)
|
|
338
|
+
discrete_height_image = torch.round(pixel_heights / h).to(torch.int32)
|
|
339
|
+
discrete_height_image = torch.clamp(discrete_height_image, 0, max_layers)
|
|
340
|
+
|
|
341
|
+
num_layers = global_logits.shape[0]
|
|
342
|
+
discrete_global_vals = []
|
|
343
|
+
for j in range(num_layers):
|
|
344
|
+
p = deterministic_gumbel_softmax(
|
|
345
|
+
global_logits[j], tau_global, hard=True, rng_seed=rng_seed + j
|
|
346
|
+
)
|
|
347
|
+
discrete_global_vals.append(torch.argmax(p))
|
|
348
|
+
discrete_global = torch.stack(discrete_global_vals, dim=0)
|
|
349
|
+
return discrete_global, discrete_height_image
|
|
350
|
+
|
|
306
351
|
def log_to_tensorboard(
|
|
307
352
|
self, interval: int = 100, namespace: str = "", step: int = None
|
|
308
353
|
):
|
|
@@ -489,13 +534,8 @@ class FilamentOptimizer:
|
|
|
489
534
|
)
|
|
490
535
|
|
|
491
536
|
if best:
|
|
492
|
-
|
|
493
|
-
self.best_params
|
|
494
|
-
self.best_params["height_offsets"],
|
|
495
|
-
)
|
|
496
|
-
current_params["pixel_height_logits"] = effective_logits
|
|
497
|
-
disc_global, disc_height_image = discretize_solution(
|
|
498
|
-
current_params,
|
|
537
|
+
disc_global, disc_height_image = self.discretize_solution(
|
|
538
|
+
self.best_params,
|
|
499
539
|
self.vis_tau,
|
|
500
540
|
self.h,
|
|
501
541
|
self.max_layers,
|
|
@@ -505,7 +545,7 @@ class FilamentOptimizer:
|
|
|
505
545
|
else:
|
|
506
546
|
tau_height, tau_global = self._get_tau()
|
|
507
547
|
with torch.no_grad():
|
|
508
|
-
disc_global, disc_height_image = discretize_solution(
|
|
548
|
+
disc_global, disc_height_image = self.discretize_solution(
|
|
509
549
|
current_params,
|
|
510
550
|
tau_height,
|
|
511
551
|
self.h,
|
|
@@ -603,18 +643,14 @@ class FilamentOptimizer:
|
|
|
603
643
|
tau_h, tau_g = self.vis_tau, self.vis_tau
|
|
604
644
|
with torch.no_grad():
|
|
605
645
|
effective_logits = self._apply_height_offset()
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
"global_logits": self.params["global_logits"],
|
|
609
|
-
}
|
|
610
|
-
disc_global, disc_height_image = discretize_solution(
|
|
611
|
-
params_with_offset, tau_g, self.h, self.max_layers, rng_seed=seed
|
|
646
|
+
disc_global, disc_height_image = self.discretize_solution(
|
|
647
|
+
self.params, tau_g, self.h, self.max_layers, rng_seed=seed
|
|
612
648
|
)
|
|
613
649
|
|
|
614
650
|
# 2) Compute discrete-mode composite
|
|
615
651
|
with torch.no_grad():
|
|
616
652
|
comp_disc = composite_image_disc(
|
|
617
|
-
|
|
653
|
+
effective_logits,
|
|
618
654
|
self.params["global_logits"],
|
|
619
655
|
self.vis_tau,
|
|
620
656
|
self.vis_tau,
|
|
@@ -659,8 +695,12 @@ class FilamentOptimizer:
|
|
|
659
695
|
best_loss = start_loss
|
|
660
696
|
for i in tqdm(range(num_seeds), desc="Searching for new best seed"):
|
|
661
697
|
seed = np.random.randint(0, 1000000)
|
|
662
|
-
|
|
698
|
+
effective_logits = self._apply_height_offset(
|
|
663
699
|
self.best_params["pixel_height_logits"],
|
|
700
|
+
self.best_params["height_offsets"],
|
|
701
|
+
)
|
|
702
|
+
comp_disc = composite_image_disc(
|
|
703
|
+
effective_logits,
|
|
664
704
|
self.best_params["global_logits"],
|
|
665
705
|
self.vis_tau,
|
|
666
706
|
self.vis_tau,
|
|
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
|
{autoforge-1.8.1 → autoforge-1.8.2}/src/autoforge/Helper/Heightmaps/ChristofidesHeightMap.py
RENAMED
|
File without changes
|
{autoforge-1.8.1 → autoforge-1.8.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
|