1- __version__ = "1 .0"
1+ __version__ = "2 .0"
22
33from re import M
44from meshroom .core import desc
55from meshroom .core .utils import VERBOSE_LEVEL
6-
7- class SPAR3DNodeSize (desc .MultiDynamicNodeSize ):
8- def computeSize (self , node ):
9- from pathlib import Path
10- import itertools
11-
12- input_path_param = node .attribute (self ._params [0 ])
13- extension_param = node .attribute (self ._params [1 ])
14-
15- input_path = input_path_param .value
16- extension = extension_param .value
17- include_suffixes = [extension .lower (), extension .upper ()]
18-
19- size = 1
20- if Path (input_path ).is_dir ():
21- image_paths = list (itertools .chain (* (Path (input_path ).glob (f'*.{ suffix } ' ) for suffix in include_suffixes )))
22- size = len (image_paths )
23- elif node .attribute (self ._params [0 ]).isLink :
24- size = node .attribute (self ._params [0 ]).inputLink .node .size
25-
26- return size
27-
6+ from pyalicevision import parallelization as avpar
287
298class SPAR3DBlockSize (desc .Parallelization ):
309 def getSizes (self , node ):
@@ -44,25 +23,16 @@ class SPAR3D(desc.Node):
4423
4524 gpu = desc .Level .INTENSIVE
4625
47- size = SPAR3DNodeSize ([ ' inputImages' , 'inputExtension' ] )
26+ size = avpar . DynamicViewsSize ( " inputImages" )
4827 parallelization = SPAR3DBlockSize ()
4928
5029 inputs = [
5130 desc .File (
5231 name = "inputImages" ,
5332 label = "Input Images" ,
54- description = "Input images to estimate the depth from. Folder path or sfmData filepath" ,
33+ description = "sfmData filepath" ,
5534 value = "" ,
5635 ),
57- desc .ChoiceParam (
58- name = "inputExtension" ,
59- label = "Input Extension" ,
60- description = "Extension of the input images. This will be used to determine which images are to be used if \n "
61- "a directory is provided as the input." ,
62- values = ["jpg" , "jpeg" , "png" , "exr" ],
63- value = "jpg" ,
64- exclusive = True ,
65- ),
6636 desc .IntParam (
6737 name = "textureResolution" ,
6838 label = "Texture Resolution" ,
@@ -143,10 +113,9 @@ class SPAR3D(desc.Node):
143113 ]
144114
145115 def preprocess (self , node ):
146- extension = node .inputExtension .value
147116 input_path = node .inputImages .value
148117
149- image_paths = get_image_paths_list (input_path , extension )
118+ image_paths = get_image_paths_list (input_path )
150119
151120 if len (image_paths ) == 0 :
152121 raise FileNotFoundError (f'No image files found in { input_path } ' )
@@ -163,7 +132,6 @@ def processChunk(self, chunk):
163132 from PIL import Image
164133
165134 import torch
166- #from img_proc import image
167135 import os
168136 from contextlib import nullcontext
169137 import numpy as np
@@ -252,18 +220,14 @@ def processChunk(self, chunk):
252220 finally :
253221 chunk .logManager .end ()
254222
255- def get_image_paths_list (input_path , extension ):
223+ def get_image_paths_list (input_path ):
256224 from pyalicevision import sfmData
257225 from pyalicevision import sfmDataIO
258226 from pathlib import Path
259- import itertools
260227
261- include_suffixes = [extension .lower (), extension .upper ()]
262228 image_paths = []
263229
264- if Path (input_path ).is_dir ():
265- image_paths = sorted (itertools .chain (* (Path (input_path ).glob (f'*.{ suffix } ' ) for suffix in include_suffixes )))
266- elif Path (input_path ).suffix .lower () in [".sfm" , ".abc" ]:
230+ if Path (input_path ).suffix .lower () in [".sfm" , ".abc" ]:
267231 if Path (input_path ).exists ():
268232 dataAV = sfmData .SfMData ()
269233 if sfmDataIO .load (dataAV , input_path , sfmDataIO .ALL ):
0 commit comments