Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Categorical Exif Metadata support for Vision Dashboard #2348

Merged
merged 15 commits into from
Sep 25, 2023
Merged
Prev Previous commit
Next Next commit
Flyout Info fix
  • Loading branch information
Advitya17 committed Sep 20, 2023
commit 771b2d50d8bd1966cb07927a086792cfe673ea8a
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ export function preprocessData(

const trueY = mapClassNames(dataSummary.true_y, classNames);

const features = dataSummary.features?.map((featuresArr) => {
return Number((featuresArr[0] as number).toFixed(2));
});
const features = dataSummary.features;

const fieldNames = dataSummary.feature_names;
if (!features || !fieldNames) {
Expand All @@ -101,8 +99,11 @@ export function preprocessData(
predictedY: predictedY[index],
trueY: trueY[index]
};
fieldNames.forEach((fieldName) => {
item[fieldName] = features[index];
fieldNames.forEach((fieldName, fieldIndex) => {
item[fieldName] = features[index][fieldIndex] as string | number;
if (typeof item[fieldName] === "number") {
item[fieldName] = Number((item[fieldName] as number).toFixed(2));
}
});
const predictedYValue = getJoinedLabelString(item.predictedY);
const trueYValue = getJoinedLabelString(item.trueY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,23 @@ def reshape_image(image):
return np.expand_dims(image, axis=0)


def _feature_metadata_from_dict(feature_meta_dict):
"""Create a FeatureMetadata from a dictionary.

:param feature_meta_dict: The dictionary to create the FeatureMetadata
from.
:type feature_meta_dict: dict
:return: The FeatureMetadata created from the dictionary.
:rtype: FeatureMetadata
"""
return FeatureMetadata(
identity_feature_name=feature_meta_dict[_IDENTITY_FEATURE_NAME],
datetime_features=feature_meta_dict[_DATETIME_FEATURES],
time_series_id_features=feature_meta_dict[_TIME_SERIES_ID_FEATURES],
categorical_features=feature_meta_dict[_CATEGORICAL_FEATURES],
dropped_features=feature_meta_dict[_DROPPED_FEATURES])


class RAIVisionInsights(RAIBaseInsights):
"""Defines the top-level RAIVisionInsights API.

Expand Down Expand Up @@ -1015,17 +1032,10 @@ def _load_metadata(inst, path):
meta[Metadata.FEATURE_METADATA] is None):
inst.__dict__['_' + Metadata.FEATURE_METADATA] = FeatureMetadata()
else:
inst.__dict__['_' + Metadata.FEATURE_METADATA] = FeatureMetadata(
identity_feature_name=meta[Metadata.FEATURE_METADATA][
_IDENTITY_FEATURE_NAME],
datetime_features=meta[Metadata.FEATURE_METADATA][
_DATETIME_FEATURES],
time_series_id_features=meta[Metadata.FEATURE_METADATA][
_TIME_SERIES_ID_FEATURES],
categorical_features=meta[Metadata.FEATURE_METADATA][
_CATEGORICAL_FEATURES],
dropped_features=meta[Metadata.FEATURE_METADATA][
_DROPPED_FEATURES])
feature_metadata_dict = meta[Metadata.FEATURE_METADATA]
feature_metadata = _feature_metadata_from_dict(
feature_metadata_dict)
inst.__dict__['_' + Metadata.FEATURE_METADATA] = feature_metadata

# load the image downloader as part of metadata
RAIVisionInsights._load_image_downloader(inst, path)
Expand Down