Sample¶
ImageSample¶
Definition of ImageSample class, representing a dataset image sample.
ImageSample ¶
ImageSample(inner: ImageTable)
Bases: Sample
Interface to a dataset image sample.
Many properties of the sample are directly accessible as attributes of this class.
print(f"Sample file name: {sample.file_name}")
print(f"Sample file path: {sample.file_path_abs}")
print(f"Sample width: {sample.width}")
print(f"Sample height: {sample.height}")
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inner |
ImageTable
|
The ImageTable SQLAlchemy model instance. |
required |
dataset_id
property
¶
dataset_id: UUID
Get the dataset ID this sample belongs to.
Returns:
| Type | Description |
|---|---|
UUID
|
The UUID of the dataset. |
metadata
property
¶
metadata: SampleMetadata
Get dictionary-like access to sample metadata.
Returns:
| Type | Description |
|---|---|
SampleMetadata
|
A dictionary-like object for accessing metadata. |
sample_table
property
¶
sample_table: SampleTable
Returns the SampleTable associated with this Sample.
tags
property
writable
¶
tags: set[str]
Get the tag names associated with this sample.
Returns:
| Type | Description |
|---|---|
set[str]
|
A set of tag names as strings. |
add_caption ¶
add_caption(text: str) -> None
Add a caption to this sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text |
str
|
The text of the caption to add. |
required |
add_tag ¶
add_tag(name: str) -> None
Add a tag to this sample.
If the tag doesn't exist, it will be created first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
The name of the tag to add. |
required |
get_object_session ¶
get_object_session() -> Session
Get the database session for this sample.
Returns:
| Type | Description |
|---|---|
Session
|
The SQLModel session. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If no active session is found. |
remove_tag ¶
remove_tag(name: str) -> None
Remove a tag from this sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
The name of the tag to remove. |
required |
VideoSample¶
Definition of VideoSample class, representing a dataset video sample.
VideoSample ¶
VideoSample(inner: VideoTable)
Bases: Sample
Interface to a dataset video sample.
Many properties of the sample are directly accessible as attributes of this class.
print(f"Sample file name: {sample.file_name}")
print(f"Sample file path: {sample.file_path_abs}")
print(f"Sample width: {sample.width}")
print(f"Sample height: {sample.height}")
print(f"Sample duration (seconds): {sample.duration_s}")
print(f"Sample FPS: {sample.fps}")
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inner |
VideoTable
|
The VideoTable SQLAlchemy model instance. |
required |
dataset_id
property
¶
dataset_id: UUID
Get the dataset ID this sample belongs to.
Returns:
| Type | Description |
|---|---|
UUID
|
The UUID of the dataset. |
metadata
property
¶
metadata: SampleMetadata
Get dictionary-like access to sample metadata.
Returns:
| Type | Description |
|---|---|
SampleMetadata
|
A dictionary-like object for accessing metadata. |
sample_table
property
¶
sample_table: SampleTable
Returns the SampleTable associated with this Sample.
tags
property
writable
¶
tags: set[str]
Get the tag names associated with this sample.
Returns:
| Type | Description |
|---|---|
set[str]
|
A set of tag names as strings. |
add_caption ¶
add_caption(text: str) -> None
Add a caption to this sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text |
str
|
The text of the caption to add. |
required |
add_tag ¶
add_tag(name: str) -> None
Add a tag to this sample.
If the tag doesn't exist, it will be created first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
The name of the tag to add. |
required |
get_object_session ¶
get_object_session() -> Session
Get the database session for this sample.
Returns:
| Type | Description |
|---|---|
Session
|
The SQLModel session. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If no active session is found. |
remove_tag ¶
remove_tag(name: str) -> None
Remove a tag from this sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
The name of the tag to remove. |
required |