Skip to content

Commit ddf9d0f

Browse files
chore: warning on wrong shape of normMean/normStd
1 parent 30ecd90 commit ddf9d0f

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

  • packages/react-native-executorch/common/rnexecutorch/models/classification

packages/react-native-executorch/common/rnexecutorch/models/classification/Classification.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include <rnexecutorch/Error.h>
44
#include <rnexecutorch/ErrorCodes.h>
5+
#include <rnexecutorch/Log.h>
6+
57
#include <rnexecutorch/data_processing/ImageProcessing.h>
68
#include <rnexecutorch/data_processing/Numerical.h>
79

@@ -16,9 +18,15 @@ Classification::Classification(const std::string &modelSource,
1618
labelNames_(std::move(labelNames)) {
1719
if (normMean.size() == 3) {
1820
normMean_ = cv::Scalar(normMean[0], normMean[1], normMean[2]);
21+
} else if (!normMean.empty()) {
22+
log(LOG_LEVEL::Warn,
23+
"normMean must have 3 elements — ignoring provided value.");
1924
}
2025
if (normStd.size() == 3) {
2126
normStd_ = cv::Scalar(normStd[0], normStd[1], normStd[2]);
27+
} else if (!normStd.empty()) {
28+
log(LOG_LEVEL::Warn,
29+
"normStd must have 3 elements — ignoring provided value.");
2230
}
2331

2432
auto inputShapes = getAllInputShapes();

0 commit comments

Comments
 (0)