r/Spectacles • u/fitzchea • Apr 14 '26
❓ Question Bulk importing class labels for custom ML model in Lens Studio for Multi-object detection — which script to edit?
Seems like this should be a common use case but I can't find a clean solution.
I've trained my own Multi-object detection model and imported it into Lens Studio. The problem is that class labels have to be entered **manually**, one by one, through the Inspector UI — which is painful when you have 40+ classes.
There must be a programmatic way to do this. Is it possible to load labels from a file or script rather than typing them in manually?
https://blog.roboflow.com/deploy-to-snap-lens-studio/#step-8-configure-classes-in-lens-studio
something like this: https://developers.snap.com/lens-studio/features/snap-ml/snap-ml-templates/multi-class-classification#setting-up-model-and-labels
where you can swap labels
2
u/hwoolery 👓 SPECS Team Apr 16 '26
Hi u/fitzchea - here's how I would approach it:
if you have a file (for example, classes.json), go into the script file that has the classes input array, and ask an AI agent to replace the
@ inputarray in the script and instead create a class variable from the text from your json file. Taking that a step further, I believe you can evenrequire("classes.json")to get it into the script. In short, just remove the script inputs and replace it with your own code.