Coretex
coretex.coretex.sample.image_sample.image_sample.ImageSample Class Reference
Inheritance diagram for coretex.coretex.sample.image_sample.image_sample.ImageSample:
coretex.coretex.sample.network_sample.NetworkSample coretex.coretex.sample.image_sample.image_sample_data.AnnotatedImageSampleData coretex.coretex.sample.image_sample.local_image_sample.LocalImageSample coretex.coretex.sample.sample.Sample coretex.coretex.sample.local_sample.LocalSample coretex.coretex.sample.image_sample.image_sample_data.AnnotatedImageSampleData coretex.coretex.sample.sample.Sample coretex.coretex.sample.image_segmentation_sample.image_segmentation_sample.ImageSegmentationSample

Public Member Functions

bool saveAnnotation (self, CoretexImageAnnotation coretexAnnotation)
 
Optional[Self] createImageSample (cls, int datasetId, Union[Path, str] imagePath)
 
- Public Member Functions inherited from coretex.coretex.sample.network_sample.NetworkSample
str path (self)
 
str zipPath (self)
 
bool download (self, bool ignoreCache=False)
 
- Public Member Functions inherited from coretex.coretex.sample.sample.Sample
None unzip (self, bool ignoreCache=False)
 
Path joinPath (self, Union[Path, str] other)
 
- Public Member Functions inherited from coretex.coretex.sample.image_sample.image_sample_data.AnnotatedImageSampleData
np.ndarray extractSegmentationMask (self, ImageDatasetClasses classes)
 
- Public Member Functions inherited from coretex.coretex.sample.image_sample.local_image_sample.LocalImageSample
AnnotatedImageSampleData load (self)
 
- Public Member Functions inherited from coretex.coretex.sample.local_sample.LocalSample
str path (self)
 
str zipPath (self)
 
bool download (self, bool ignoreCache=False)
 

Detailed Description

    Represents the generic image sample\n
    Contains basic properties and functionality for all image sample classes\n
    The class has several methods that allow users to access and
    manipulate image data and annotations, as well as to create new image samples

Definition at line 30 of file image_sample.py.

Member Function Documentation

◆ createImageSample()

Optional[Self] coretex.coretex.sample.image_sample.image_sample.ImageSample.createImageSample (   cls,
int  datasetId,
Union[Path, str]  imagePath 
)
    Creates a new image sample with specified properties\n
    For creating custom sample, sample must be an image of supported format

    Parameters
    ----------
    datasetId : int
id of dataset in which image sample will be created
    imagePath : Union[Path, str]
path to the image sample

    Returns
    -------
    The created image sample object

    Example
    -------
    >>> from coretex import ImageSample
    \b
    >>> sample = ImageSample.createImageSample(1023, "path/to/file.jpeg")
    >>> if sample is None:
    print("Failed to create image sample")

Definition at line 76 of file image_sample.py.

76  def createImageSample(cls, datasetId: int, imagePath: Union[Path, str]) -> Optional[Self]:
77  """
78  Creates a new image sample with specified properties\n
79  For creating custom sample, sample must be an image of supported format
80 
81  Parameters
82  ----------
83  datasetId : int
84  id of dataset in which image sample will be created
85  imagePath : Union[Path, str]
86  path to the image sample
87 
88  Returns
89  -------
90  The created image sample object
91 
92  Example
93  -------
94  >>> from coretex import ImageSample
95  \b
96  >>> sample = ImageSample.createImageSample(1023, "path/to/file.jpeg")
97  >>> if sample is None:
98  print("Failed to create image sample")
99  """
100 
101  parameters = {
102  "dataset_id": datasetId
103  }
104 
105  return cls._createSample(parameters, imagePath)

◆ saveAnnotation()

bool coretex.coretex.sample.image_sample.image_sample.ImageSample.saveAnnotation (   self,
CoretexImageAnnotation  coretexAnnotation 
)
    Updates annotation for the image

    Returns
    -------
    bool -> returns True if successful, False otherwise

Reimplemented from coretex.coretex.sample.image_sample.local_image_sample.LocalImageSample.

Definition at line 59 of file image_sample.py.

59  def saveAnnotation(self, coretexAnnotation: CoretexImageAnnotation) -> bool:
60  super().saveAnnotation(coretexAnnotation)
61 
62  parameters = {
63  "id": self.id,
64  "data": coretexAnnotation.encode()
65  }
66 
67  response = networkManager.genericJSONRequest(
68  endpoint = "session/save-annotations",
69  requestType = RequestType.post,
70  parameters = parameters
71  )
72 
73  return not response.hasFailed()
74 

The documentation for this class was generated from the following file: