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 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
Returns the “default value” for a type. Read more
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
Mutably borrows from an owned value. Read more
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> ⓘ
Converts
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> ⓘ
Converts
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