qualitylib.result.Result

class Result(dataset_name, content_id, asset_id, feats, feat_names=array([], dtype='<U1'), agg_method='mean', score=None)[source]

Bases: object

Result object containing extracted features and asset data.

Parameters:
  • dataset_name (str) – Name of dataset.

  • content_id (int) – ID of source content of input asset.

  • asset_id (int) – ID of input asset from which features were extracted.

  • feats (ndarray) – Array of features extracted from asset.

  • feat_names (ndarray) – Optional names of extracted features.

  • agg_method (Union[str, callable]) – Temporal aggregation method. Defaults to ‘mean’.

  • score (Optional[float]) – Optional ground-truth subjective score. Defaults to None.

Raises:
  • ValueError – If feats is not a 2D array.

  • ValueError – If agg_method is neither a recognized string, nor a Callable.

  • ValueError – If the number of features in feats does not match the number of feature names, if provided.

Methods

exists

Check if result file exists in cache.

from_asset_and_fex

Load result from input asset and name-version string of the FeatureExtractor class.

from_dict

Create result from dictionary.

get_path

Get path in cache to/from which result is saved/loaded.

load

Load result from path.

save

Save result to path.

Attributes

agg_feats

Aggregated features, using the agg_method.

feats

Array of extracted features from each frame.

num_feats

Number of extracted features.

num_frames

Number of frames for which features are extracted.

property agg_feats: ndarray[source]

Aggregated features, using the agg_method.

static exists(asset_dict, fex_name_version)[source]

Check if result file exists in cache.

Parameters:
Returns:

Flag denoting whether the result file exists in the cache.

Return type:

bool

property feats: ndarray[source]

Array of extracted features from each frame.

classmethod from_asset_and_fex(asset_dict, fex_name_version)[source]

Load result from input asset and name-version string of the FeatureExtractor class.

Parameters:
Raises:

OSError – If path is not a valid readable file path

Return type:

Result

Returns:

Loaded result object

classmethod from_dict(result_dict)[source]

Create result from dictionary.

Parameters:

result_dict (Dict[str, Any]) – Dictionary containing result attributes.

Return type:

Result

Returns:

Result object.

static get_path(asset_dict, fex_name_version)[source]

Get path in cache to/from which result is saved/loaded.

Parameters:
  • asset_dict (Dict[str, Any]) – Input asset.

  • fex_name_version (str) – Name-version string of feature extractor.

Return type:

PathLike

Returns:

Path of result in cache.

classmethod load(path)[source]

Load result from path.

Parameters:

path (PathLike) – Path to result in cache.

Raises:

OSError – If path is not a valid readable file path

Return type:

Result

Returns:

Loaded result object

property num_feats: int[source]

Number of extracted features.

property num_frames: int[source]

Number of frames for which features are extracted.

save(path)[source]

Save result to path.

Parameters:

path (PathLike) – Path to which result must be saved.

Return type:

None