pub struct CocoDatasetBuilder { /* private fields */ }Expand description
Builder for constructing a COCO dataset.
Provides a convenient API for incrementally building a COCO dataset.
Implementations§
Source§impl CocoDatasetBuilder
impl CocoDatasetBuilder
Sourcepub fn add_category(&mut self, name: &str, supercategory: Option<&str>) -> u32
pub fn add_category(&mut self, name: &str, supercategory: Option<&str>) -> u32
Add a category, returning its ID.
Sourcepub fn add_category_with_id(
&mut self,
id: u32,
name: &str,
supercategory: Option<&str>,
) -> u32
pub fn add_category_with_id( &mut self, id: u32, name: &str, supercategory: Option<&str>, ) -> u32
Add a category with a specific ID, returning its ID.
Used when round-tripping datasets that have explicit category IDs (e.g., COCO, LVIS) to preserve the original numbering.
Sourcepub fn add_image(&mut self, file_name: &str, width: u32, height: u32) -> u64
pub fn add_image(&mut self, file_name: &str, width: u32, height: u32) -> u64
Add an image, returning its ID.
Sourcepub fn add_annotation(
&mut self,
image_id: u64,
category_id: u32,
bbox: [f64; 4],
segmentation: Option<CocoSegmentation>,
) -> u64
pub fn add_annotation( &mut self, image_id: u64, category_id: u32, bbox: [f64; 4], segmentation: Option<CocoSegmentation>, ) -> u64
Add an annotation, returning its ID.
Sourcepub fn add_annotation_with_iscrowd(
&mut self,
image_id: u64,
category_id: u32,
bbox: [f64; 4],
segmentation: Option<CocoSegmentation>,
iscrowd: u8,
) -> u64
pub fn add_annotation_with_iscrowd( &mut self, image_id: u64, category_id: u32, bbox: [f64; 4], segmentation: Option<CocoSegmentation>, iscrowd: u8, ) -> u64
Add an annotation with an explicit iscrowd flag, returning its ID.
Sourcepub fn add_annotation_with_id(
&mut self,
id: Option<u64>,
image_id: u64,
category_id: u32,
bbox: [f64; 4],
segmentation: Option<CocoSegmentation>,
iscrowd: u8,
) -> u64
pub fn add_annotation_with_id( &mut self, id: Option<u64>, image_id: u64, category_id: u32, bbox: [f64; 4], segmentation: Option<CocoSegmentation>, iscrowd: u8, ) -> u64
Add an annotation with an optional explicit ID and iscrowd flag, returning its ID.
When id is Some(explicit), the caller-supplied ID is used directly
and next_annotation_id is bumped past it so that subsequent
auto-generated IDs do not collide. When id is None, an
auto-incremented ID is assigned (the standard path).
Used to round-trip COCO/LVIS datasets through Arrow while preserving
the original annotation id for downstream tools that rely on a
stable per-instance identifier (most notably prompted-segmentation
workflows where the ID links a predicted mask back to the
ground-truth instance that prompted it).
Caller is responsible for ensuring uniqueness across explicit IDs
(mirrors add_category_with_id
semantics).
Sourcepub fn set_annotation_score(&mut self, annotation_id: u64, score: f64)
pub fn set_annotation_score(&mut self, annotation_id: u64, score: f64)
Set the score on an annotation by ID.
Sourcepub fn set_image_neg_categories(
&mut self,
image_id: u64,
neg_category_ids: Option<Vec<u32>>,
not_exhaustive_category_ids: Option<Vec<u32>>,
)
pub fn set_image_neg_categories( &mut self, image_id: u64, neg_category_ids: Option<Vec<u32>>, not_exhaustive_category_ids: Option<Vec<u32>>, )
Set LVIS annotation metadata on an image.
Sourcepub fn set_category_metadata(
&mut self,
name: &str,
synset: Option<String>,
frequency: Option<String>,
synonyms: Option<Vec<String>>,
def: Option<String>,
)
pub fn set_category_metadata( &mut self, name: &str, synset: Option<String>, frequency: Option<String>, synonyms: Option<Vec<String>>, def: Option<String>, )
Set LVIS metadata on a category by name.
Only updates fields that are Some; leaves existing values intact
for fields passed as None.
Sourcepub fn set_category_supercategory(&mut self, name: &str, supercategory: &str)
pub fn set_category_supercategory(&mut self, name: &str, supercategory: &str)
Set the supercategory on a category by name.
Sourcepub fn build(self) -> CocoDataset
pub fn build(self) -> CocoDataset
Build the final dataset.
Trait Implementations§
Source§impl Debug for CocoDatasetBuilder
impl Debug for CocoDatasetBuilder
Source§impl Default for CocoDatasetBuilder
impl Default for CocoDatasetBuilder
Source§fn default() -> CocoDatasetBuilder
fn default() -> CocoDatasetBuilder
Auto Trait Implementations§
impl Freeze for CocoDatasetBuilder
impl RefUnwindSafe for CocoDatasetBuilder
impl Send for CocoDatasetBuilder
impl Sync for CocoDatasetBuilder
impl Unpin for CocoDatasetBuilder
impl UnsafeUnpin for CocoDatasetBuilder
impl UnwindSafe for CocoDatasetBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more