synthval.features_extraction.FeatureExtractor#
- class synthval.features_extraction.FeatureExtractor#
Bases:
abc.ABCAbstract base class representing a generic feature extractor. Child classes must implement the batch_feature_extraction method for batch processing.
- abstractmethod batch_feature_extraction(images)#
Abstract method to extract features from a batch of images.
- Parameters:
images (List[PIL.Image.Image]) – List of PIL images to extract features from.
- Returns:
A NumPy array containing extracted features for the batch.
- Return type:
numpy.ndarray
- group_feature_extraction(source_folder_path, batch_size=16, verbose=True)#
Extract features from all images in a specified folder using batch processing.
- Parameters:
source_folder_path (str) – Path to the folder containing images.
batch_size (int, optional) – Number of images to process in a single batch (default: 16).
verbose (bool, optional) – If True, logs progress during extraction (default: True).
- Returns:
A DataFrame containing extracted features for all images.
- Return type:
pandas.DataFrame
- get_features_df(source_folder_path, save_path=None, batch_size=16, verbose=True)#
Extract features from images in a folder and optionally save them to a CSV file.
- Parameters:
source_folder_path (str) – Path to the folder containing images.
save_path (str, optional) – Path to save the features DataFrame as a CSV file. If a CSV file exists, it will be loaded instead.
batch_size (int, optional) – Number of images to process per batch (default: 16).
verbose (bool, optional) – If True, logs progress during extraction (default: True).
- Returns:
DataFrame containing extracted features for all images.
- Return type:
pandas.DataFrame