Using the same USD file, headless runs give different images than when using the Code GUI

Using a script based on the “Running Replicator Headlessly” tutorial, I loaded a cardboard box from Nucleus and got different results when running the script in Code. The object can be found at

omniverse://localhost/NVIDIA/Assets/Isaac/2022.1/Isaac/Environments/Simple_Warehouse/Props/SM_CardBoxA_01.usd

I downloaded the usd file and added it to my input volume mount when running with the container.

docker run --gpus all --entrypoint bash --rm \
 -v $PWD/replicator_input:/input \
 -v $PWD/replicator_output:/root/omni.replicator_out/_output \
 nvcr.io/nvidia/omniverse-replicator:1.4.7-r1 \
 ./startup.sh --allow-root --no-window --/omni/replicator/script=/input/test.py

The only difference in the script is I use the local USD file for the container while I use Nucleus from within Omniverse Code. The following script, headless_usd.py, creates 10 images of a cardboard box with random orientation with left-right position between -3 and 3 world units. The camera is created from a primitive and placed about 10 units away.

import omni.replicator.core as rep

with rep.new_layer():

    rep.create.light(light_type="Distant")

    # Y axis is up
    camera = rep.create.camera(position=(0, 1, 10))
    render_product = rep.create.render_product(camera, (1024, 1024))

    #boxA_file = 'omniverse://localhost/NVIDIA/Assets/Isaac/2022.1/Isaac/Environments/Simple_Warehouse/Props/SM_CardBoxA_01.usd'
    boxA_file = '/input/SM_CardBoxA_01.usd'
    def box_generator():
        # Y-axis is up
        box_obj = rep.create.from_usd(boxA_file, semantics=[('class', 'boxA')])
        with box_obj:
            rep.modify.pose(
                position=rep.distribution.uniform((-3, 0, 0), (3, 0, 0)),
                rotation=rep.distribution.uniform((-90,-45, 0), (-90, 45, 0)),
            )
        return box_obj
    
    # Setup randomization and create 10 images
    rep.randomizer.register(box_generator)
    with rep.trigger.on_frame(num_frames=10):
        rep.randomizer.box_generator()
    
    writer = rep.WriterRegistry.get("BasicWriter")
    writer.initialize(output_dir="_output", rgb=True,   bounding_box_2d_tight=True)
    writer.attach([render_product])

    rep.orchestrator.run()

Using code the box looks great, but using the container, it looks like the textures are not present.

Could the material content be in a separate file in the Omniverse nucleus assets?

1 Like

Hello @syntheticDataArchitect! I’ve asked the dev team for some assistance! They should be replying shortly!

1 Like

SOLVED!!! Inspection of the materials for the cardboard box when I had it open on Omniverse Code shows the textures are in …/Materials/Textures. I downloaded the whole Simple_Warehouse directory from Nucleus, and put it in my volume mounted input folder. I had to change permissions of the files, but now the replicator script runs with the container similar to how it runs in Code. The only difference is the container runs show the world axes as can be seen in the screenshot.

1 Like

Great that you figured out the issue!

Just as an aside, you can also pass in the arguments --network host --env OMNI_USER="<your username>" --env OMNI_PASS="your password>" in order to use omniverse://localhost asset URLs in your script.

1 Like

Thank you! These arguments worked to access my local Nucleus server with this script.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.