Going somewhere with a glass of wine.

This commit is contained in:
didier committed 2024-11-08 19:46:49 -05:00
1 parent 4171dd2bc4
commit bcadb5b9f7
3 files changed
+8 -37

No files matched your search

+2 -32
View File
@@ -4,40 +4,10 @@ import numpy as np
import pandera as pa
from pandera.dtypes import Float32, Float64
XCoord = NewType('XCoord', float)
YCoord = NewType('YCoord', float)
Score = NewType('Confidence', float)
Category = NewType('Category', float)
@dataclass
class Point:
x: XCoord
y: YCoord
VideoFrame = NewType('Frame', float)
VideoTimestamp = float
@dataclass
class DetectedObject:
xmin: XCoord
ymin: YCoord
xmax: XCoord
ymax: YCoord
score: Score
category: Category
def as_int_box(self) -> tuple[tuple[int, int], tuple[int, int]]:
return (int(self.xmin), int(self.ymin)), (
int(self.xmax), int(self.ymax))
def as_nparray(self):
return np.array([self.xmin, self.ymax, self.xmax, self.ymax, self.score,
self.category])
def tensor_of(data_type: pa.DataType, cols: list[str]) -> pa.DataFrameSchema:
return pa.DataFrameSchema({col: pa.Column(data_type) for col in cols})
@@ -45,8 +15,8 @@ def tensor_of(data_type: pa.DataType, cols: list[str]) -> pa.DataFrameSchema:
DetectedObject_ = tensor_of(Float32, ["xmin", "ymin", "xmax", "ymax", "score",
"category"])
TrackedDetectedObject_ = tensor_of(Float64,
list(DetectedObject_.columns) + ["object_id", "index"])
TrackedDetectedObject = tensor_of(Float64,
list(DetectedObject_.columns) + ["object_id", "index"])
# ["xmin", "ymin", "xmax", "ymax", "object_id", "score", "category", "index"])