Problem removing existing semantic labels and creating custom semantic labels in replicator

When I use rep.create.group on a list of different usd files I add a custom semantic label to the group. But the annotation json files generated for semantic segmentation labels somehow still contains two semantic labels. Attached a screenshot of the json file for example. In this screenshot, shelf and box are set by me but you can also see rack and crate labels. Please let me know why this happens and how to get rid of it

You can remove them manually via selecting in the Viewport and using the User Interface of the Semantic Schema Editor.

Currently rep.modify.semantics is additive as you’ve seen.

To do this via script to remove whatever semantic you would like:

# Using class:sphere as an example
import omni.replicator.core as rep
from semantics.schema.editor import remove_prim_semantics

# Get prims to remove semantics on - Execute this first by itself
my_spheres = rep.get.prims(semantics=[('class','sphere')])

# Run this next
get_targets = rep.utils.get_node_targets(my_spheres.node, "outputs_prims")
print(get_targets)
# [Sdf.Path('/Replicator/Sphere_Xform'), Sdf.Path('/Replicator/Sphere_Xform_01'), Sdf.Path('/Replicator/Sphere_Xform_02'), Sdf.Path('/Replicator/Sphere_Xform_03'), Sdf.Path('/Replicator/Sphere_Xform_04'), Sdf.Path('/Replicator/Sphere_Xform_05')]

# Loop through each prim_path and remove all semantic data
for prim_path in get_targets:
    prim = get_prim_at_path(prim_path)
    result = remove_prim_semantics(prim) # To remove all semantics
    result = remove_prim_semantics(prim, label_type='class') # To remove only 'class' semantics
    print(result)

# [REMOVE]: '/Replicator/Sphere_Xform_01' --> 'class':'sphere'
# [REMOVE]: '/Replicator/Sphere_Xform_02' --> 'class':'sphere'
# [REMOVE]: '/Replicator/Sphere_Xform_03' --> 'class':'sphere'
# [REMOVE]: '/Replicator/Sphere_Xform_04' --> 'class':'sphere'
# [REMOVE]: '/Replicator/Sphere_Xform_05' --> 'class':'sphere'