MCPcopy Create free account
hub / github.com/apple/ml-4m / convert_string_to_bboxes

Function convert_string_to_bboxes

fourm/utils/plotting_utils.py:863–889  ·  view source on GitHub ↗

Converts a string of bboxes to a list of bboxes. Args: bboxes_str (str): String of bboxes bins (int): Number of bins (default: 1000)

(bboxes_str, bins=1000)

Source from the content-addressed store, hash-verified

861 ax.spines['left'].set_visible(False)
862
863def convert_string_to_bboxes(bboxes_str, bins=1000):
864 """
865 Converts a string of bboxes to a list of bboxes.
866
867 Args:
868 bboxes_str (str): String of bboxes
869 bins (int): Number of bins (default: 1000)
870 """
871 bboxes_str = bboxes_str.split(" ")
872 bboxes = []
873 for token in bboxes_str:
874 if "=" in token:
875 coord = token.split("=")[1]
876 coord = float(coord) / (bins - 1)
877
878 if token.startswith("v0="):
879 bboxes.append([coord,])
880 else:
881 bboxes[-1].append(coord)
882 elif len(bboxes[-1]) == 4:
883 bboxes[-1].append(token)
884 else:
885 bboxes[-1][4] = " ".join([bboxes[-1][4], token])
886
887 bboxes = [bbox for bbox in bboxes if len(bbox) == 5]
888
889 return bboxes
890
891def visualize_palettes_multi(palettes):
892 palettes = palettes.split()

Callers 1

visualize_bboxesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected