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

About result. #30

Open
cainiaoshidai opened this issue Nov 14, 2023 · 6 comments
Open

About result. #30

cainiaoshidai opened this issue Nov 14, 2023 · 6 comments

Comments

@cainiaoshidai
Copy link

Hi , The result I got after reasoning with this code is as follows. Can you give me some advice, how can I solve this problem.

@cainiaoshidai
Copy link
Author

1699961685006

@OroChippw
Copy link
Owner

Did you pull the code from the master branch? Since the code is currently being iterated, the code was merged incorrectly on the master branch😂😂😂. You can try switching to the dev branch and modify the parameters in the code to see if the problem still exists. When the subsequent master branch repair is completed, you will also be notified. Thank you for paying attention to this repository .❤️❤️❤️

@cainiaoshidai
Copy link
Author

Did you pull the code from the master branch? Since the code is currently being iterated, the code was merged incorrectly on the master branch😂😂😂. You can try switching to the dev branch and modify the parameters in the code to see if the problem still exists. When the subsequent master branch repair is completed, you will also be notified. Thank you for paying attention to this repository .❤️❤️❤️

Yes, I pull the code from the master branch. But when I switching to the dev branch the problem is still exist. I just use myself onnx model. It's useful in python.

@cainiaoshidai
Copy link
Author

Hi, I think I found the reason. I compared the python code and found that the image normalization operation is missing in the image processing. When I added the normalization operation, the results were great. Thank you for your project, it is very helpful to me.

input_image_torch = torch.as_tensor(input_image, device=device)

input_image_torch = input_image_torch.permute(2, 0, 1).contiguous()[None, :, :, :]

pixel_mean = torch.Tensor([123.675, 116.28, 103.53]).view(-1, 1, 1).to(device)

pixel_std = torch.Tensor([58.395, 57.12, 57.375]).view(-1, 1, 1).to(device)

x = (input_image_torch - pixel_mean) / pixel_std

@OroChippw
Copy link
Owner

Which part of the code needs to be modified? Can you give me the correct example for reference? Thank you for your contribution.

@cainiaoshidai
Copy link
Author

I change the code Image_PreProcess to follow.

    std::cout << "PreProcess Image ..." << std::endl;
cv::Mat rgbImage;
cv::cvtColor(srcImage, rgbImage, cv::COLOR_BGR2RGB);
cv::Mat floatImage;
rgbImage.convertTo(floatImage, CV_32FC3);
cv::Mat pixelMean = cv::Mat::ones(cv::Size(1024, 1024), CV_32FC3);
cv::Mat pixelStd = cv::Mat::ones(cv::Size(1024, 1024), CV_32FC3);
pixelMean = cv::Scalar(123.675, 116.28, 103.53);
pixelStd = cv::Scalar(58.395, 57.12, 57.375);
floatImage -= pixelMean;
floatImage /= pixelStd;
cv::Mat resizeImage = ResizeLongestSide_apply_image(floatImage, EncoderInputSize);
// Normalization
// resizeImage.convertTo(resizeImage, 1.0 / 255.0);

int pad_h = EncoderInputSize - resizeImage.rows;
int pad_w = EncoderInputSize - resizeImage.cols;

cv::Mat paddingImage;
cv::copyMakeBorder(resizeImage, paddingImage, 0, pad_h, 0, pad_w, cv::BorderTypes::BORDER_CONSTANT, cv::Scalar(0, 0, 0));

std::cout << "paddingImage width : " << paddingImage.cols << ", paddingImage height : " << paddingImage.rows << std::endl;
return paddingImage;

I think the image is normalized in this way, rather than normalized to 0 to 1 or not normalized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants