Author Topic: Batch process images through a graph  (Read 227 times)

Hi,

So I built a simple graph in Substance Designer, which takes 2 color image inputs, processes them for my desired result, and outputs 2 "finished" images.  The 2 images can be considered a "set" and I have many of these sets of images. 

Is it possible to use the Batch Tools to feed each "set" of input images to the graph and render my 2 output images in a large batch process?  Each image would be named accordingly, i.e. IMG_001_diff.tif and IMG_001_spec.tif. 

So grab the first set, IMG_001_*.tif, plug the corresponding *_diff.tif into proper input 1, and *_spec.tif into input 2, then render the output images.  Repeat this process for each set within an input directory.

How could I do this?

You can certainly do this.
The general workflow is:
1. Cook your SBS file to an SBSAR file (either in designer or using sbscooker)
2. Call sbsrender and use --set-entry to reference the images you want to use as input.
The call to sbsrender would look something like this:
sbsrender render cooked_sbsar.sbsar --set-entry input1@<path-to-first-image> --set-entry input2@<path-to-second-image>

In the automation toolkits there are wrappers in python for calling sbsrender and sbscooker and if you look at the variations or texture_mat examples you can see how to do it using the batchtools python module. If you prefer the command line route, look at demo_texturingtemplate.py or demos.py.

Let me know if you manage to get it working.

Hi David, and thank you for the response.

So using your example call to sbsrender:
sbsrender render cooked_sbsar.sbsar --set-entry input1@<path-to-first-image> --set-entry input2@<path-to-second-image>

The --set-entry pieces of "input1" and "input2" would be changed to match the node name I gave them in Designer before I cook it to an SBSAR? 

Then I would use the python wrapper you mentioned in such a way where I gather the list of all the images to be processed using python, then feed them into the sbsrender call using a loop till all images are done? 

Also, where are those python files you told me to reference?  I downloaded the Automation Toolkit, installed everything, but there are no sample python files, or am I looking in the wrong place?
Last Edit: November 23, 2017, 02:14:51 pm

Hi,

In order to accomplish what you are looking for you would need to identify the sets in a python script.
Typically you use the os.walk (https://www.tutorialspoint.com/python/os_walk.htm) or Glob (https://docs.python.org/2/library/glob.html) to find the files in a directory and some string operations to identify which files belong together.

When you have all the pairs you want to process together you just loop over those files and run the process on them.

Let me know if you manage to get it to work