Python library for computer vision labeling tasks. The core functionality is to translate bounding box annotations between different formats-for example, from coco to yolo.

Overview

PyLabel

pip install pylabel

   Open In Colab

PyLabel is a Python package to help you prepare image datasets for computer vision models including PyTorch and YOLOv5. It can translate bounding box annotations between different formats. (For example, COCO to YOLO.) And it includes an AI-assisted labeling tool that runs in a Jupyter notebook.

  • Translate: Convert annotation formats with a single line of code:
    importer.ImportCoco(path_to_annotations).ExportToYoloV5()
    
  • Analyze: PyLabel stores annotatations in a pandas dataframe so you can easily perform analysis on image datasets.
  • Split: Divide image datasets into train, test, and val with stratification to get consistent class distribution.
  • Label: PyLabel also includes an image labeling tool that runs in a Jupyter notebook that can annotate images manually or perform automatic labeling using a pre-trained model.

  • Visualize: Render images from your dataset with bounding boxes overlaid so you can confirm the accuracy of the annotations.

Tutorial Notebooks

See PyLabel in action in these sample Jupyter notebooks:

About PyLabel

PyLabel is being developed by Jeremy Fraenkel, Alex Heaton, and Derek Topper as the Capstope project for the Master of Information and Data Science (MIDS) at the UC Berkeley School of Information. If you have any questions or feedback please create an issue. Please let us know how we can make PyLabel more useful.

Comments
  • "No objects to concatenate" conversion yolo to coco

    I'm doing a yolo 2 coco conversion with yaml, everything works just fine until I do dataset.export.ExportToCoco(cat_id_index=0) i tried with cat_id_index=1 as well. The full error is as it follows: Traceback (most recent call last): File "/home/usuaris/imatge/ilias.khayat/TFG/yolo22coco.py", line 45, in <module> dataset.export.ExportToCoco(cat_id_index=1) File "/home/usuaris/imatge/ilias.khayat/TFG/pylabel/pylabel/exporter.py", line 744, in ExportToCoco mergedI = pd.concat(df_outputI, ignore_index=True) File "/home/usuaris/imatge/ilias.khayat/venv/detectron2-/lib/python3.9/site-packages/pandas/util/_decorators.py", line 311, in wrapper return func(*args, **kwargs) File "/home/usuaris/imatge/ilias.khayat/venv/detectron2-/lib/python3.9/site-packages/pandas/core/reshape/concat.py", line 347, in concat op = _Concatenator( File "/home/usuaris/imatge/ilias.khayat/venv/detectron2-/lib/python3.9/site-packages/pandas/core/reshape/concat.py", line 404, in __init__ raise ValueError("No objects to concatenate") ValueError: No objects to concatenate srun: error: gpic10: task 0: Exited with exit code 1 I'd appreciate any suggestions. `

    opened by 88ili88 12
  • ValueError: not enough values to unpack (expected 5, got 0).

    ValueError: not enough values to unpack (expected 5, got 0).

    I think this happens with images that don't have annotations, meaning their respective .txt files are empty.

    ---------------------------------------------------------------------------
    ValueError                                Traceback (most recent call last)
    ~\AppData\Local\Temp/ipykernel_24072/4001401144.py in <module>
          9 print("Here")
         10 dataset1 = importer.ImportYoloV5(path=path_to_annotations, path_to_images=path_to_images, cat_names=yoloclasses,
    ---> 11     img_ext="jpeg", name="view, cut, plan")
         12 print("Here 2")
         13 
    
    ~\Anaconda3\envs\yolov5\lib\site-packages\pylabel\importer.py in ImportYoloV5(path, img_ext, cat_names, path_to_images, name)
        300                     width_norm,
        301                     height_norm,
    --> 302                 ) = line.split()
        303                 row["img_folder"] = path_to_images
        304                 row["img_filename"] = filename.name.replace("txt", img_ext)
    
    ValueError: not enough values to unpack (expected 5, got 0)
    
    
    opened by isspid 9
  • ValueError: cannot convert float NaN to integer

    ValueError: cannot convert float NaN to integer

    Occurs on calling visualize when bounding boxes have nan values:

    from IPython.display import Image, display
    display(ds.visualize.ShowBoundingBoxes(5))
    
    ---------------------------------------------------------------------------
    ValueError                                Traceback (most recent call last)
    /Users/robin/Documents/GitHub/oil-storage-tank/pylabel.ipynb Cell 7' in <cell line: 2>()
          [1](vscode-notebook-cell:/Users/robin/Documents/GitHub/oil-storage-tank/pylabel.ipynb#ch0000002?line=0)[ from IPython.display import Image, display
    ----> ]()[2](vscode-notebook-cell:/Users/robin/Documents/GitHub/oil-storage-tank/pylabel.ipynb#ch0000002?line=1)[ display(ds.visualize.ShowBoundingBoxes(5))
    
    File ~/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pylabel/visualize.py:34, in Visualize.ShowBoundingBoxes(self, img_id, img_filename)
         ]()[32](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pylabel/visualize.py?line=31)[ for index, row in df_single_img_annots.iterrows():
         ]()[33](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pylabel/visualize.py?line=32)[     labels.append(row['cat_name'])
    ---> ]()[34](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pylabel/visualize.py?line=33)[     bboxes.append([int(row['ann_bbox_xmin']),int(row['ann_bbox_ymin']),int(row['ann_bbox_xmax']),int(row['ann_bbox_ymax'])])
         ]()[36](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pylabel/visualize.py?line=35)[ img_with_boxes = bbv.draw_multiple_rectangles(img, bboxes)
         ]()[37](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pylabel/visualize.py?line=36)[ img_with_boxes = bbv.add_multiple_labels(img_with_boxes, labels, bboxes)
    
    ValueError: cannot convert float NaN to integer]()
    

    I guess this occurs as I have images with zero annotations

    opened by robmarkcole 8
  • Cannot import PASCAL VOC dataset

    Cannot import PASCAL VOC dataset

    The dataset is in PASCAL VOC format, as exported by CVAT. When importing, I receive the traceback

    Traceback (most recent call last):
      File "path\to\convert_annotations.py", line 5, in <module>
        voc_data = importer.ImportVOC(voc_folder)
      File "path\to\.venv\lib\site-packages\pylabel\importer.py", line 207, in ImportVOC
        row["ann_pose"] = _GetValueOrBlank(o.find("pose"))
      File "path\to\.venv\lib\site-packages\pylabel\importer.py", line 27, in _GetValueOrBlank
        return element.text
    AttributeError: 'NoneType' object has no attribute 'text'
    

    Here is an example of an annotation xml exported by CVAT:

    <?xml version="1.0"?>
    <annotation>
    <folder>myfolder</folder>
    <filename>myfile.png</filename>
    <source>
    <database>Unknown</database>
    <annotation>Unknown</annotation>
    <image>Unknown</image>
    </source>
    <size>
    <width>5328</width>
    <height>4608</height>
    <depth/>
    </size>
    <segmented>0</segmented>
    <object>
    <name>my_object</name>
    <truncated>0</truncated>
    <occluded>0</occluded>
    <difficult>0</difficult>
    <bndbox>
    <xmin>127.06</xmin>
    <ymin>632.19</ymin>
    <xmax>161.12</xmax>
    <ymax>666.86</ymax>
    </bndbox>
    <attributes>
    <attribute>
    <name>rotation</name>
    <value>0.0</value>
    </attribute>
    </attributes>
    </annotation>```
    opened by emillundh 7
  • Category_id exported as string instead of int

    Category_id exported as string instead of int

    Hi,

    Thank you for create this nice utility!

    I encountered an issue with ExportToCoco, the category_id in the exported json file is stored as a string instead of an integer, which caused trouble when registering datasets in detectron2. My quick fix was just cast all category_id to int.

    opened by ytzeng1 7
  • Issue if image has no bounding boxes

    Issue if image has no bounding boxes

    Hi, I was converting from YOLO to VOC, and it seems that if an image doesnt have any bounding boxes, then it causes an error to occur. This is the error: ValueError: invalid literal for int() with base 10: '. This arises in the exporter.py script.

    opened by n12iB 5
  • Cast `category_id` field value from `str` to `int`

    Cast `category_id` field value from `str` to `int`

    This PR casts the category_id field value from str to int data type to be consistent with the COCO data format.

    I have also checked the other fields and found everything is consistent with the format outlined in https://cocodataset.org/#format-data

    Closes #46

    opened by dnth 5
  • Cvat compatibility and bug fixes

    Cvat compatibility and bug fixes

    CVAT Compatibility and over bug fixes

    I tried using this package to convert my coco annotations of a custom data-set, which was annotated in CVAT, to YOLOV5 labels. I ran into some issues and have fixed them and hope they may be of use to others as well.

    The issues are also explained in the commit messages.

    1. importer.py: the tag "img_folder" was required to be in coco annotations but this is not a necessary tag, it is often left blank or not included at all, when it is not included a KeyError occured. There was an attempt at this in place with a call _GetValueOrBlank(images["img_folder"], path_to_images) which though still requires there to be an "img_folder" in images even if an alternative path was given by the user. Fixed by checking if this tag/column exists and creating it empty if it does not yet exist

    2. Same issue as 1. only with img_depth, it is not required in the coco annotation format and is not given when exporting from cvat

    3. exporter.py, ExportToYoloV5(): -default value of yaml_file=None leads to TypeError: expected str, ... fixed by setting default value to the recommended yaml_file='dataset.yaml' -fix to the issue that not using splits created "UnboundLocalError: local variable 'split_dir' referenced before assignment" fixed by setting split_dir = '' if no split is wanted

    4. analize.py bug: i in cat_names was assumed to be str and caused error "AttributeError: 'float' object has no attribute 'strip'" fix: typecast str(i) before calling strip

    Please let me know if there is anything you need me to change and thank you for creating this package.

    bug good first issue 
    opened by landegt 5
  • _ReindexCatIds is broken

    _ReindexCatIds is broken

    https://github.com/thovden/pylabel/blob/c17d2c644f1dcb85ef3f9835c8771b96b969a673/pylabel/shared.py#L39

    The __ReindexCatIds function is broken, mainly because it's operating on a copy of a DataFrame.

    The following code does not work in-place by default:

        df = df.replace(r"^\s*$", np.nan, regex=True)
    

    Hence, the rest of the function operates on a copy of the DataFrame, but the intention is to do in-place replacements of df['cat_id'].

    I also suspect the intention of the following code is probably to coerce df['cat_id'] to an numeric type:

    pd.to_numeric(df["cat_id"])
    

    However, these values are not written back to the original data frame.

    I'm going to cleanup this function a little and submit a PR.

    opened by thovden 4
  • !_src.empty() in function 'cvtColor'

    !_src.empty() in function 'cvtColor'

    image
    from IPython.display import Image, display
    display(dataset.visualize.ShowBoundingBoxes(100))
    
    ---------------------------------------------------------------------------
    error                                     Traceback (most recent call last)
    /Users/robin/Documents/GitHub/oil-storage-tank/pylabel.ipynb Cell 3' in <cell line: 2>()
          [1](vscode-notebook-cell:/Users/robin/Documents/GitHub/oil-storage-tank/pylabel.ipynb#ch0000002?line=0)[ from IPython.display import Image, display
    ----> ]()[2](vscode-notebook-cell:/Users/robin/Documents/GitHub/oil-storage-tank/pylabel.ipynb#ch0000002?line=1)[ display(dataset.visualize.ShowBoundingBoxes(100))
    
    File ~/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pylabel/visualize.py:27, in Visualize.ShowBoundingBoxes(self, img_id, img_filename)
         ]()[25](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pylabel/visualize.py?line=24)[ full_image_path = str(Path(ds.path_to_annotations, df_single_img_annots.iloc[0].img_folder, df_single_img_annots.iloc[0].img_filename))
         ]()[26](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pylabel/visualize.py?line=25)[ img = cv2.imread(str(full_image_path))
    ---> ]()[27](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pylabel/visualize.py?line=26)[ img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
         ]()[29](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pylabel/visualize.py?line=28)[ labels = []
         ]()[30](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pylabel/visualize.py?line=29)[ bboxes = []
    
    error: OpenCV(4.5.5) /Users/runner/work/opencv-python/opencv-python/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor']()
    

    I was suspicious the img_path col is empty, but updating this doesn't resolve

    opened by robmarkcole 4
  • keep images without annotation

    keep images without annotation

    Hi, thanks for opensourcing this great tool! It's quite helpful. Do you know if there is a walk-around that I can use to keep the image information for images that do not have annotations? For example, if one image does not have any annotation, ideally it will be kept in the "images" field when exported to the coco format.

    question 
    opened by vincentlux 3
  • IndexError: index 8 is out of bounds for axis 0 with size 7

    IndexError: index 8 is out of bounds for axis 0 with size 7

    Code:

    #Specify path to the coco.json file
    path_to_annotations = "data/coco.json"
    #Specify the path to the images (if they are in a different folder than the annotations)
    path_to_images = "data/image_patches/"
    
    #Import the dataset into the pylable schema 
    dataset = importer.ImportCoco(path_to_annotations, path_to_images=path_to_images, name="tanks_coco")
    dataset.df.head(5)
    

    Error:

    ---------------------------------------------------------------------------
    IndexError                                Traceback (most recent call last)
    /Users/robin/Documents/GitHub/oil-storage-tank/pre-processing.ipynb Cell 7' in <cell line: 7>()
          [4](vscode-notebook-cell:/Users/robin/Documents/GitHub/oil-storage-tank/pre-processing.ipynb#ch0000010?line=3)[ path_to_images = "data/image_patches/"
          ]()[6](vscode-notebook-cell:/Users/robin/Documents/GitHub/oil-storage-tank/pre-processing.ipynb#ch0000010?line=5)[ #Import the dataset into the pylable schema 
    ----> ]()[7](vscode-notebook-cell:/Users/robin/Documents/GitHub/oil-storage-tank/pre-processing.ipynb#ch0000010?line=6)[ dataset = importer.ImportCoco(path_to_annotations, path_to_images=path_to_images, name="tanks_coco")
          ]()[8](vscode-notebook-cell:/Users/robin/Documents/GitHub/oil-storage-tank/pre-processing.ipynb#ch0000010?line=7)[ dataset.df.head(5)
    
    File ~/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pylabel/importer.py:94, in ImportCoco(path, path_to_images, name)
         ]()[89](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pylabel/importer.py?line=88)[ df.ann_category_id = df.ann_category_id.astype(str)
         ]()[91](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pylabel/importer.py?line=90)[ df[
         ]()[92](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pylabel/importer.py?line=91)[     ["ann_bbox_xmin", "ann_bbox_ymin", "ann_bbox_width", "ann_bbox_height"]
         ]()[93](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pylabel/importer.py?line=92)[ ] = pd.DataFrame(df.ann_bbox.tolist(), index=df.index)
    ---> ]()[94](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pylabel/importer.py?line=93)[ df.insert(8, "ann_bbox_xmax", df["ann_bbox_xmin"] + df["ann_bbox_width"])
         ]()[95](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pylabel/importer.py?line=94)[ df.insert(10, "ann_bbox_ymax", df["ann_bbox_ymin"] + df["ann_bbox_height"])
         ]()[97](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pylabel/importer.py?line=96)[ # debug print(df.info())
         ]()[98](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pylabel/importer.py?line=97)[ 
         ]()[99](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pylabel/importer.py?line=98)[ # Join the annotions with the information about the image to add the image columns to the dataframe
    
    File ~/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/frame.py:4439, in DataFrame.insert(self, loc, column, value, allow_duplicates)
       ]()[4436](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/frame.py?line=4435)[     raise TypeError("loc must be int")
       ]()[4438](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/frame.py?line=4437)[ value = self._sanitize_column(value)
    -> ]()[4439](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/frame.py?line=4438)[ self._mgr.insert(loc, column, value)]()
    File ~/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/internals/managers.py:1230, in BlockManager.insert(self, loc, item, value)
       [1220](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/internals/managers.py?line=1219)[ """
       ]()[1221](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/internals/managers.py?line=1220)[ Insert item at selected position.
       ]()[1222](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/internals/managers.py?line=1221)[ 
       (...)
       ]()[1227](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/internals/managers.py?line=1226)[ value : np.ndarray or ExtensionArray
       ]()[1228](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/internals/managers.py?line=1227)[ """
       ]()[1229](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/internals/managers.py?line=1228)[ # insert to the axis; this could possibly raise a TypeError
    -> ]()[1230](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/internals/managers.py?line=1229)[ new_axis = self.items.insert(loc, item)
       ]()[1232](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/internals/managers.py?line=1231)[ if value.ndim == 2:
       ]()[1233](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/internals/managers.py?line=1232)[     value = value.T
    
    File ~/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/indexes/base.py:6602, in Index.insert(self, loc, item)
       ]()[6595](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/indexes/base.py?line=6594)[ if arr.dtype != object or not isinstance(
       ]()[6596](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/indexes/base.py?line=6595)[     item, (tuple, np.datetime64, np.timedelta64)
       ]()[6597](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/indexes/base.py?line=6596)[ ):
       ]()[6598](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/indexes/base.py?line=6597)[     # with object-dtype we need to worry about numpy incorrectly casting
       ]()[6599](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/indexes/base.py?line=6598)[     # dt64/td64 to integer, also about treating tuples as sequences
       ]()[6600](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/indexes/base.py?line=6599)[     # special-casing dt64/td64 https://github.com/numpy/numpy/issues/12550
       ]()[6601](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/indexes/base.py?line=6600)[     casted = arr.dtype.type(item)
    -> ]()[6602](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/indexes/base.py?line=6601)[     new_values = np.insert(arr, loc, casted)
       ]()[6604](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/indexes/base.py?line=6603)[ else:
       ]()[6605](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/indexes/base.py?line=6604)[     # No overload variant of "insert" matches argument types
       ]()[6606](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/indexes/base.py?line=6605)[     # "ndarray[Any, Any]", "int", "None"  [call-overload]
       ]()[6607](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/pandas/core/indexes/base.py?line=6606)[     new_values = np.insert(arr, loc, None)  # type: ignore[call-overload]
    
    File <__array_function__ internals>:180, in insert(*args, **kwargs)
    
    File ~/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/numpy/lib/function_base.py:5280, in insert(arr, obj, values, axis)
       ]()[5278](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/numpy/lib/function_base.py?line=5277)[ index = indices.item()
       ]()[5279](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/numpy/lib/function_base.py?line=5278)[ if index < -N or index > N:
    -> ]()[5280](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/numpy/lib/function_base.py?line=5279)[     raise IndexError(f"index {obj} is out of bounds for axis {axis} "
       ]()[5281](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/numpy/lib/function_base.py?line=5280)[                      f"with size {N}")
       ]()[5282](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/numpy/lib/function_base.py?line=5281)[ if (index < 0):
       ]()[5283](file:///Users/robin/Documents/GitHub/oil-storage-tank/venv/lib/python3.9/site-packages/numpy/lib/function_base.py?line=5282)[     index += N
    
    IndexError: index 8 is out of bounds for axis 0 with size 7]()
    
    opened by robmarkcole 10
  • Error during exporting of split dataset (with null class values).

    Error during exporting of split dataset (with null class values).

    ---------------------------------------------------------------------------
    TypeError                                 Traceback (most recent call last)
    ~\Anaconda3\envs\yolov5\lib\site-packages\pandas\core\ops\array_ops.py in na_arithmetic_op(left, right, op, is_cmp)
        142     try:
    --> 143         result = expressions.evaluate(op, left, right)
        144     except TypeError:
    
    ~\Anaconda3\envs\yolov5\lib\site-packages\pandas\core\computation\expressions.py in evaluate(op, a, b, use_numexpr)
        232         if use_numexpr:
    --> 233             return _evaluate(op, op_str, a, b)  # type: ignore
        234     return _evaluate_standard(op, op_str, a, b)
    
    ~\Anaconda3\envs\yolov5\lib\site-packages\pandas\core\computation\expressions.py in _evaluate_standard(op, op_str, a, b)
         67     with np.errstate(all="ignore"):
    ---> 68         return op(a, b)
         69 
    
    TypeError: can't multiply sequence by non-int of type 'float'
    
    During handling of the above exception, another exception occurred:
    
    TypeError                                 Traceback (most recent call last)
    ~\AppData\Local\Temp/ipykernel_59916/1620987889.py in <module>
    ----> 1 dataset.export.ExportToYoloV5(output_path='model_training/labels',yaml_file='dataset.yaml', use_splits=True)
    
    ~\Anaconda3\envs\yolov5\lib\site-packages\pylabel\exporter.py in ExportToYoloV5(self, output_path, yaml_file, copy_images, use_splits, cat_id_index)
        486 
        487         yolo_dataset["center_x_scaled"] = (
    --> 488             yolo_dataset["ann_bbox_xmin"] + (yolo_dataset["ann_bbox_width"] * 0.5)
        489         ) / yolo_dataset["img_width"]
        490         yolo_dataset["center_y_scaled"] = (
    
    ~\Anaconda3\envs\yolov5\lib\site-packages\pandas\core\ops\common.py in new_method(self, other)
         63         other = item_from_zerodim(other)
         64 
    ---> 65         return method(self, other)
         66 
         67     return new_method
    
    ~\Anaconda3\envs\yolov5\lib\site-packages\pandas\core\ops\__init__.py in wrapper(left, right)
        341         lvalues = extract_array(left, extract_numpy=True)
        342         rvalues = extract_array(right, extract_numpy=True)
    --> 343         result = arithmetic_op(lvalues, rvalues, op)
        344 
        345         return left._construct_result(result, name=res_name)
    
    ~\Anaconda3\envs\yolov5\lib\site-packages\pandas\core\ops\array_ops.py in arithmetic_op(left, right, op)
        188     else:
        189         with np.errstate(all="ignore"):
    --> 190             res_values = na_arithmetic_op(lvalues, rvalues, op)
        191 
        192     return res_values
    
    ~\Anaconda3\envs\yolov5\lib\site-packages\pandas\core\ops\array_ops.py in na_arithmetic_op(left, right, op, is_cmp)
        148             #  will handle complex numbers incorrectly, see GH#32047
        149             raise
    --> 150         result = masked_arith_op(left, right, op)
        151 
        152     if is_cmp and (is_scalar(result) or result is NotImplemented):
    
    ~\Anaconda3\envs\yolov5\lib\site-packages\pandas\core\ops\array_ops.py in masked_arith_op(x, y, op)
        110         if mask.any():
        111             with np.errstate(all="ignore"):
    --> 112                 result[mask] = op(xrav[mask], y)
        113 
        114     result, _ = maybe_upcast_putmask(result, ~mask, np.nan)
    
    TypeError: can't multiply sequence by non-int of type 'float'
    
    opened by isspid 8
  • Multiple image extension for YOLOv5 dataset

    Multiple image extension for YOLOv5 dataset

    My Yolov5 dataset has got multiple image extensions files such as jpg, jpeg, png, etc. What is the best way to handle these cases?

    dataset = importer.ImportYoloV5(path=path_to_annotations, path_to_images=path_to_images, cat_names=yoloclasses,
        img_ext="jpg", name="coco128")
    

    in img_ext we can only specify one extension format.

    opened by dnth 8
  • reindexing category id when exporting to coco json format

    reindexing category id when exporting to coco json format

    Instead of changing the category Ids, it might be a nice feature to add a "background" category at category_id = 0, that is how other libraries do it.

    opened by Daniel-R-Armstrong 3
Releases(v0.1.42)
  • v0.1.42(Dec 29, 2022)

    What's Changed

    • To resolve issue #66 with voc exporting by @alexheat in https://github.com/pylabel-project/pylabel/pull/67

    Full Changelog: https://github.com/pylabel-project/pylabel/compare/v0.1.41...v0.1.42

    Source code(tar.gz)
    Source code(zip)
  • v0.1.41(Aug 27, 2022)

    This should resolve issue https://github.com/pylabel-project/pylabel/issues/61 "Cannot import PASCAL VOC dataset"

    What's Changed

    • GetValueOrBlank should return a blank if the element is missing by @emillundh in https://github.com/pylabel-project/pylabel/pull/62

    New Contributors

    • @emillundh made their first contribution in https://github.com/pylabel-project/pylabel/pull/62

    Full Changelog: https://github.com/pylabel-project/pylabel/compare/v0.1.40...v0.1.41

    Source code(tar.gz)
    Source code(zip)
  • v0.1.40(Jun 3, 2022)

    What's Changed

    • Resolve issues #57 in ImportYoloV5WithYaml method by @alexheat in https://github.com/pylabel-project/pylabel/pull/59

    Full Changelog: https://github.com/pylabel-project/pylabel/compare/v0.1.39...v0.1.40

    Source code(tar.gz)
    Source code(zip)
  • v0.1.39(May 1, 2022)

    This release will resolve issue https://github.com/pylabel-project/pylabel/issues/52 discovered by @thovden who also supplied a fix that resolved the issue. The ReindexCatIds function was broken. Additional tests have been added to catch this issue in the future.

    What's Changed

    • Write converted cat_ids back to orignal data frame by @thovden in https://github.com/pylabel-project/pylabel/pull/53

    Full Changelog: https://github.com/pylabel-project/pylabel/compare/v0.1.38...v0.1.39

    Source code(tar.gz)
    Source code(zip)
  • v0.1.38(Apr 28, 2022)

    This release will resolve issue #49 when there are file names with multiple periods discovered by @thovden who also supplied a fix that resolved the issue.

    What's Changed

    • Ensure the annotation files have complete filenames. by @thovden in https://github.com/pylabel-project/pylabel/pull/50

    New Contributors

    • @thovden made their first contribution in https://github.com/pylabel-project/pylabel/pull/50

    Full Changelog: https://github.com/pylabel-project/pylabel/compare/v0.1.37...v0.1.38

    Source code(tar.gz)
    Source code(zip)
  • v0.1.37(Apr 24, 2022)

    This release (.37) will resolve an issue discovered by @dnth where category_ids were being exported as string values instead of ints. (Issue https://github.com/pylabel-project/pylabel/issues/46) @dnth supplied a fix that resolved the issue.

    What's Changed

    • Cast category_id field value from str to int by @dnth in https://github.com/pylabel-project/pylabel/pull/47

    New Contributors

    • @dnth made their first contribution in https://github.com/pylabel-project/pylabel/pull/47

    Full Changelog: https://github.com/pylabel-project/pylabel/compare/v0.1.36...v0.1.37

    Source code(tar.gz)
    Source code(zip)
  • v0.1.36(Apr 15, 2022)

    What's Changed

    This release should fix issues reported by users when importing coco files that had images without annotations. It should be able to handle those cases without errors and export annotation files even when there are no annotations.

    • Fixes issues with missing anots in coco files issue #35 by @alexheat in https://github.com/pylabel-project/pylabel/pull/44

    Full Changelog: https://github.com/pylabel-project/pylabel/compare/v0.1.35...v0.1.36

    Source code(tar.gz)
    Source code(zip)
  • v0.1.35(Mar 17, 2022)

    What's Changed

    • Fix for issue #40 when importing Yolo files by @alexheat in https://github.com/pylabel-project/pylabel/pull/41

    Full Changelog: https://github.com/pylabel-project/pylabel/compare/v0.1.34...v0.1.35

    Source code(tar.gz)
    Source code(zip)
  • v0.1.34.2(Mar 16, 2022)

  • v0.1.34(Mar 16, 2022)

    What's Changed

    • To fix errors when rendering images with no boxes by @alexheat in https://github.com/pylabel-project/pylabel/pull/36

    Full Changelog: https://github.com/pylabel-project/pylabel/compare/v0.1.33...v0.1.34

    Source code(tar.gz)
    Source code(zip)
  • v0.1.33(Feb 26, 2022)

    What's Changed

    • Resolve issues #29 no annotations in Yolo file by @alexheat in https://github.com/pylabel-project/pylabel/pull/30

    Full Changelog: https://github.com/pylabel-project/pylabel/compare/v0.1.32...v0.1.33

    Source code(tar.gz)
    Source code(zip)
  • v0.1.32(Feb 20, 2022)

    What's Changed

    • Add support for multiple image extension for YOLOv5 dataset by @alexheat in https://github.com/pylabel-project/pylabel/pull/27
    • This should resolve issue #26 (https://github.com/pylabel-project/pylabel/issues/26) by adding support to be able to import a Yolov5 dataset with images in multi image formats. For example jpg and png.

    Full Changelog: https://github.com/pylabel-project/pylabel/compare/v0.1.31...v0.1.32

    Source code(tar.gz)
    Source code(zip)
  • v0.1.31(Feb 11, 2022)

    This release resolves issue #23

    What's Changed

    • Update README.md by @alexheat in https://github.com/pylabel-project/pylabel/pull/19
    • Resolve Issue #23 by @alexheat in https://github.com/pylabel-project/pylabel/pull/24

    Full Changelog: https://github.com/pylabel-project/pylabel/compare/v0.1.29...v0.1.31

    Source code(tar.gz)
    Source code(zip)
  • v0.1.30(Jan 13, 2022)

    This is a test of the auto publish action

    What's Changed

    • Fixing tests that use nbmake by @alexheat in https://github.com/pylabel-project/pylabel/pull/12
    • Merge by @alexheat in https://github.com/pylabel-project/pylabel/pull/13
    • fix "Max Recursion Level Reached" issue by @Daniel-R-Armstrong in https://github.com/pylabel-project/pylabel/pull/14
    • Push latest work to main by @alexheat in https://github.com/pylabel-project/pylabel/pull/17
    • Push latest to main by @alexheat in https://github.com/pylabel-project/pylabel/pull/18
    • Update README.md by @alexheat in https://github.com/pylabel-project/pylabel/pull/19
    • Push latest to main by @alexheat in https://github.com/pylabel-project/pylabel/pull/20

    New Contributors

    • @Daniel-R-Armstrong made their first contribution in https://github.com/pylabel-project/pylabel/pull/14

    Full Changelog: https://github.com/pylabel-project/pylabel/compare/v0.1.28...v0.1.30

    Source code(tar.gz)
    Source code(zip)
  • v0.1.29(Jan 12, 2022)

    New Contributors

    • @Daniel-R-Armstrong made their first contribution in https://github.com/pylabel-project/pylabel/pull/14

    What's Changed

    • Fixing tests that use nbmake by @alexheat in https://github.com/pylabel-project/pylabel/pull/12
    • Merge by @alexheat in https://github.com/pylabel-project/pylabel/pull/13
    • fix "Max Recursion Level Reached" issue by @Daniel-R-Armstrong in https://github.com/pylabel-project/pylabel/pull/14
    • Push latest work to main by @alexheat in https://github.com/pylabel-project/pylabel/pull/17
    • Push latest to main by @alexheat in https://github.com/pylabel-project/pylabel/pull/18

    Full Changelog: https://github.com/pylabel-project/pylabel/compare/v0.1.28...v0.1.29

    Source code(tar.gz)
    Source code(zip)
  • v0.1.28(Jan 12, 2022)

    Added new property. analyze.class_name_id_map. See docs at https://pylabel.readthedocs.io/en/latest/pylabel.html#pylabel.analyze.Analyze.class_name_id_map

    Full Changelog: https://github.com/pylabel-project/pylabel/compare/v0.1.27...v0.1.28

    Source code(tar.gz)
    Source code(zip)
  • v0.1.26(Jan 11, 2022)

    Fixed small bug caused when saving images with no annotations to Yolo format.

    Full Changelog: https://github.com/pylabel-project/pylabel/compare/v0.1.25...v0.1.26

    Source code(tar.gz)
    Source code(zip)
  • v0.1.25(Jan 6, 2022)

    This release fixes a bug found in the VOC exporter by convert bbox coordinates to ints.

    Full Changelog: https://github.com/pylabel-project/pylabel/compare/v0.1.24...v0.1.25

    Source code(tar.gz)
    Source code(zip)
  • v0.1.24(Dec 30, 2021)

    What's Changed

    • Added more doc strings and created documentation at https://pylabel.readthedocs.io/en/latest/. See new badge on readme to access the docs Documentation Status
    • Add workflow to enable CI on the package by @rajasvu in https://github.com/pylabel-project/pylabel/pull/8
    • Main by @alexheat in https://github.com/pylabel-project/pylabel/pull/10

    New Contributors

    • @rajasvu made their first contribution in https://github.com/pylabel-project/pylabel/pull/8

    Full Changelog: https://github.com/pylabel-project/pylabel/compare/v0.1.22...v0.1.24

    Source code(tar.gz)
    Source code(zip)
  • v0.1.22(Dec 23, 2021)

    The output of dataset.analyze.classes and dataset.analyze.class_ids are now sorted by the class id. For example:

    ` Class ids: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 13, 14, 15, 16, 17, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 38, 39, 40, 41, 42, 43, 44, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 67, 68, 69, 71, 72, 73, 74, 75, 76, 77, 79]

    Classes: ['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'stop sign', 'bench', 'bird', 'cat', 'dog', 'horse', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'cell phone', 'microwave', 'oven', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'toothbrush'] `

    Full Changelog: https://github.com/pylabel-project/pylabel/compare/v0.1.21...v0.1.22

    Source code(tar.gz)
    Source code(zip)
  • v0.1.21(Dec 18, 2021)

    What's Changed

    • ExportToCoco function mapping cat_ids to [index_base, index_base + nu… by @ytzeng1 in https://github.com/pylabel-project/pylabel/pull/7
    • Added new methods and parameters to handle non-continuous class ids, which cause problems when training models with many computer vision frameworks including Yolo and Detection. Use the dataset.ReindexCatIds() method to make all the cat_ids continuous starting from 0 or 1. Use the cat_id_index parameter in export functions to make the cat_ids of the output annotations continuous, without changing the the dataset itself.

    New Contributors

    • @ytzeng1 made their first contribution in https://github.com/pylabel-project/pylabel/pull/7

    Full Changelog: https://github.com/pylabel-project/pylabel/compare/v0.1.20...v0.1.21

    Source code(tar.gz)
    Source code(zip)
  • v0.1.20(Dec 14, 2021)

    This update partially fixes the issues mentioned in #6 (Category_id exported as string instead of int )

    • cat_id is now an int in the COCO export
    • iscrowd value defaults to 0 in COCO export

    You can see an example of the COCO output by running this notebook https://github.com/pylabel-project/samples/blob/main/yolo2coco.ipynb

    Thank you @ytzeng1 for reporting this issue

    Full Changelog: https://github.com/pylabel-project/pylabel/compare/v0.1.19...v0.1.20

    Source code(tar.gz)
    Source code(zip)
  • v0.1.19(Dec 5, 2021)

  • v0.1.18(Dec 4, 2021)

    What's Changed

    • Cvat compatibility and bug fixes by @landegt in https://github.com/pylabel-project/pylabel/pull/1

    New Contributors

    • @landegt made their first contribution in https://github.com/pylabel-project/pylabel/pull/1

    Full Changelog: https://github.com/pylabel-project/pylabel/compare/v0.1.14...v0.1.18

    Source code(tar.gz)
    Source code(zip)
  • v0.1.14(Nov 28, 2021)

  • v0.1.11(Nov 17, 2021)

Owner
PyLabel Project
Home of the PyLabel Python package and labeling tool for computer vision annotations.
PyLabel Project
Segcache: a memory-efficient and scalable in-memory key-value cache for small objects

Segcache: a memory-efficient and scalable in-memory key-value cache for small objects This repo contains the code of Segcache described in the followi

TheSys Group @ CMU CS 78 Jan 07, 2023
CKD - Collaborative Knowledge Distillation for Heterogeneous Information Network Embedding

Collaborative Knowledge Distillation for Heterogeneous Information Network Embed

zhousheng 9 Dec 05, 2022
Employs neural networks to classify images into four categories: ship, automobile, dog or frog

Neural Net Image Classifier Employs neural networks to classify images into four categories: ship, automobile, dog or frog Viterbi_1.py uses a classic

Riley Baker 1 Jan 18, 2022
Accommodating supervised learning algorithms for the historical prices of the world's favorite cryptocurrency and boosting it through LightGBM.

Accommodating supervised learning algorithms for the historical prices of the world's favorite cryptocurrency and boosting it through LightGBM.

1 Nov 27, 2021
Message Passing on Cell Complexes

CW Networks This repository contains the code used for the papers Weisfeiler and Lehman Go Cellular: CW Networks (Under review) and Weisfeiler and Leh

Twitter Research 108 Jan 05, 2023
Repo for the paper Extrapolating from a Single Image to a Thousand Classes using Distillation

Extrapolating from a Single Image to a Thousand Classes using Distillation by Yuki M. Asano* and Aaqib Saeed* (*Equal Contribution) Extrapolating from

Yuki M. Asano 16 Nov 04, 2022
Bridging the Gap between Label- and Reference based Synthesis(ICCV 2021)

Bridging the Gap between Label- and Reference based Synthesis(ICCV 2021) Tensorflow implementation of Bridging the Gap between Label- and Reference-ba

huangqiusheng 8 Jul 13, 2022
A general python framework for single object tracking in LiDAR point clouds, based on PyTorch Lightning.

Open3DSOT A general python framework for single object tracking in LiDAR point clouds, based on PyTorch Lightning. The official code release of BAT an

Kangel Zenn 172 Dec 23, 2022
PyTorch implementation for "Sharpness-aware Quantization for Deep Neural Networks".

Sharpness-aware Quantization for Deep Neural Networks This is the official repository for our paper: Sharpness-aware Quantization for Deep Neural Netw

Zhuang AI Group 30 Dec 19, 2022
Time-series-deep-learning - Developing Deep learning LSTM, BiLSTM models, and NeuralProphet for multi-step time-series forecasting of stock price.

Stock Price Prediction Using Deep Learning Univariate Time Series Predicting stock price using historical data of a company using Neural networks for

Abdultawwab Safarji 7 Nov 27, 2022
An official implementation of the Anchor DETR.

Anchor DETR: Query Design for Transformer-Based Detector Introduction This repository is an official implementation of the Anchor DETR. We encode the

MEGVII Research 276 Dec 28, 2022
Speedy Implementation of Instance-based Learning (IBL) agents in Python

A Python library to create single or multi Instance-based Learning (IBL) agents that are built based on Instance Based Learning Theory (IBLT) 1 Instal

0 Nov 18, 2021
NBEATSx: Neural basis expansion analysis with exogenous variables

NBEATSx: Neural basis expansion analysis with exogenous variables We extend the NBEATS model to incorporate exogenous factors. The resulting method, c

Cristian Challu 100 Dec 31, 2022
The first dataset of composite images with rationality score indicating whether the object placement in a composite image is reasonable.

Object-Placement-Assessment-Dataset-OPA Object-Placement-Assessment (OPA) is to verify whether a composite image is plausible in terms of the object p

BCMI 53 Nov 15, 2022
This is an official implementation for "Video Swin Transformers".

Video Swin Transformer By Ze Liu*, Jia Ning*, Yue Cao, Yixuan Wei, Zheng Zhang, Stephen Lin and Han Hu. This repo is the official implementation of "V

Swin Transformer 981 Jan 03, 2023
This is the official implementation of the paper "Object Propagation via Inter-Frame Attentions for Temporally Stable Video Instance Segmentation".

ObjProp Introduction This is the official implementation of the paper "Object Propagation via Inter-Frame Attentions for Temporally Stable Video Insta

Anirudh S Chakravarthy 6 May 03, 2022
[CVPR 2021] Modular Interactive Video Object Segmentation: Interaction-to-Mask, Propagation and Difference-Aware Fusion

[CVPR 2021] Modular Interactive Video Object Segmentation: Interaction-to-Mask, Propagation and Difference-Aware Fusion

Rex Cheng 364 Jan 03, 2023
(Personalized) Page-Rank computation using PyTorch

torch-ppr This package allows calculating page-rank and personalized page-rank via power iteration with PyTorch, which also supports calculation on GP

Max Berrendorf 69 Dec 03, 2022
Multi-layer convolutional LSTM with Pytorch

Convolution_LSTM_pytorch Thanks for your attention. I haven't got time to maintain this repo for a long time. I recommend this repo which provides an

Zijie Zhuang 733 Dec 30, 2022
STRIVE: Scene Text Replacement In Videos

STRIVE: Scene Text Replacement In Videos Dataset Types: RoboText SynthText RealWorld videos RoboText : Videos of texts collected using navigation robo

15 Jul 11, 2022