Skip to content

Commit 4b90874

Browse files
committed
fix: add BGR to RGB conversion
1 parent 01b12eb commit 4b90874

5 files changed

Lines changed: 4 additions & 4 deletions

File tree

packages/react-native-executorch/common/rnexecutorch/data_processing/ImageProcessing.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ cv::Mat readImage(const std::string &imageURI) {
111111
throw std::runtime_error("Read image error: invalid argument");
112112
}
113113

114+
cv::cvtColor(image, image, cv::COLOR_BGR2RGB);
114115
return image;
115116
}
116117

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ Classification::forward(std::string imageSource) {
4444

4545
TensorPtr Classification::preprocess(const std::string &imageSource) {
4646
cv::Mat image = imageprocessing::readImage(imageSource);
47-
cv::cvtColor(image, image, cv::COLOR_BGR2RGB);
4847
cv::resize(image, image, modelImageSize);
4948

5049
return imageprocessing::getTensorFromMatrix(getInputShape()[0], image);

packages/react-native-executorch/common/rnexecutorch/models/image_segmentation/ImageSegmentation.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ ImageSegmentation::forward(std::string imageSource,
5353
std::pair<TensorPtr, cv::Size>
5454
ImageSegmentation::preprocess(const std::string &imageSource) {
5555
cv::Mat input = imageprocessing::readImage(imageSource);
56-
cv::cvtColor(input, input, cv::COLOR_BGR2RGB);
5756
cv::Size inputSize = input.size();
5857

5958
cv::resize(input, input, modelImageSize);

packages/react-native-executorch/common/rnexecutorch/models/style_transfer/StyleTransfer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ StyleTransfer::StyleTransfer(const std::string &modelSource,
3636
std::pair<TensorPtr, cv::Size>
3737
StyleTransfer::preprocess(const std::string &imageSource) {
3838
cv::Mat image = imageprocessing::readImage(imageSource);
39-
cv::cvtColor(image, image, cv::COLOR_BGR2RGB);
4039
auto originalSize = image.size();
4140
cv::resize(image, image, modelImageSize);
4241

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
export class BaseNonStaticModule {
22
nativeModule: any = null;
33
delete() {
4-
this.nativeModule.unload();
4+
if (this.nativeModule !== null) {
5+
this.nativeModule.unload();
6+
}
57
}
68
}

0 commit comments

Comments
 (0)