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

Public Member Functions

AnnotatedImageSampleData load (self)
 
bool saveAnnotation (self, CoretexImageAnnotation coretexAnnotation)
 
- Public Member Functions inherited from coretex.coretex.sample.local_sample.LocalSample
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)
 

Detailed Description

    Represents the local Image Sample object\n
    Contains basic properties and functionality for local image Sample classes\n
    The class has several methods that allow users to access and
    manipulate local image data and annotations

Definition at line 29 of file local_image_sample.py.

Member Function Documentation

◆ load()

AnnotatedImageSampleData coretex.coretex.sample.image_sample.local_image_sample.LocalImageSample.load (   self)
    Loads image and its annotation if it exists

    Returns
    -------
    AnnotatedImageSampleData -> image data and annotation in Coretex.ai format

Reimplemented from coretex.coretex.sample.local_sample.LocalSample.

Definition at line 38 of file local_image_sample.py.

38  def load(self) -> AnnotatedImageSampleData:
39  """
40  Loads image and its annotation if it exists
41 
42  Returns
43  -------
44  AnnotatedImageSampleData -> image data and annotation in Coretex.ai format
45  """
46 
47  return AnnotatedImageSampleData(Path(self.path))
48 

◆ saveAnnotation()

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

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

Reimplemented in coretex.coretex.sample.image_sample.image_sample.ImageSample.

Definition at line 49 of file local_image_sample.py.

49  def saveAnnotation(self, coretexAnnotation: CoretexImageAnnotation) -> bool:
50  """
51  Updates annotation for the image
52 
53  Returns
54  -------
55  bool -> returns True if successful, False otherwise
56  """
57 
58  with open(Path(self.path) / "annotations.json", "w") as file:
59  json.dump(coretexAnnotation.encode(), file)
60 
61  zipPath = Path(self.zipPath)
62 
63  oldZipPath = zipPath.parent / f"{zipPath.stem}-old.zip"
64  zipPath.rename(oldZipPath)
65 
66  with ZipFile(zipPath, "w") as zipFile:
67  path = Path(self.path)
68  for element in os.listdir(path):
69  zipFile.write(path / element, arcname = element)
70 
71  oldZipPath.unlink()
72  return True

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