-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Update ultralytics models (#592)
Co-authored-by: Helio Machado <[email protected]>
1 parent
ebc19c6
commit b62d091
Showing
10 changed files
with
812 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from . import yolo | ||
from .bbox import BBox | ||
from . import ultralytics | ||
from .bbox import BBox, OBBox | ||
from .pose import Pose, Pose3D | ||
from .segment import Segments | ||
|
||
__all__ = ["BBox", "Pose", "Pose3D", "yolo"] | ||
__all__ = ["BBox", "OBBox", "Pose", "Pose3D", "Segments", "ultralytics"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from pydantic import Field | ||
|
||
from datachain.lib.data_model import DataModel | ||
|
||
|
||
class Segments(DataModel): | ||
""" | ||
A data model for representing segments. | ||
Attributes: | ||
title (str): The title of the segments. | ||
x (list[int]): The x-coordinates of the segments. | ||
y (list[int]): The y-coordinates of the segments. | ||
The segments are represented as lists of x and y coordinates, where each index | ||
corresponds to a specific segment. | ||
""" | ||
|
||
title: str = Field(default="") | ||
x: list[int] = Field(default=None) | ||
y: list[int] = Field(default=None) | ||
|
||
@staticmethod | ||
def from_list(points: list[list[float]], title: str = "") -> "Segments": | ||
assert len(points) == 2, "Segments coordinates must be a list of 2 lists." | ||
points_x, points_y = points | ||
assert len(points_x) == len( | ||
points_y | ||
), "Segments x and y coordinates must have the same length." | ||
assert all( | ||
isinstance(value, (int, float)) for value in [*points_x, *points_y] | ||
), "Segments coordinates must be integers or floats." | ||
return Segments( | ||
title=title, | ||
x=[round(coord) for coord in points_x], | ||
y=[round(coord) for coord in points_y], | ||
) | ||
|
||
@staticmethod | ||
def from_dict(points: dict[str, list[float]], title: str = "") -> "Segments": | ||
assert set(points) == { | ||
"x", | ||
"y", | ||
}, "Segments coordinates must contain keys 'x' and 'y'." | ||
points_x, points_y = points["x"], points["y"] | ||
assert all( | ||
isinstance(value, (int, float)) for value in [*points_x, *points_y] | ||
), "Segments coordinates must be integers or floats." | ||
return Segments( | ||
title=title, | ||
x=[round(coord) for coord in points_x], | ||
y=[round(coord) for coord in points_y], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from .bbox import YoloBBox, YoloBBoxes, YoloOBBox, YoloOBBoxes | ||
from .pose import YoloPose, YoloPoses | ||
from .segment import YoloSegment, YoloSegments | ||
|
||
__all__ = [ | ||
"YoloBBox", | ||
"YoloBBoxes", | ||
"YoloOBBox", | ||
"YoloOBBoxes", | ||
"YoloPose", | ||
"YoloPoses", | ||
"YoloSegment", | ||
"YoloSegments", | ||
] |
Oops, something went wrong.