num_objs is defined as num_objs = len(obj_ids), while obj_ids is created via:
obj_ids = np.unique(mask)
# first id is the background, so remove it
obj_ids = obj_ids[1:]

so I assume your suggestion should work for your described use case.
Would you mind creating an issue here 17 and describe the problem?