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

Semantic segmentation prediction in output.json #3

Open
sagarr opened this issue Jun 3, 2020 · 3 comments
Open

Semantic segmentation prediction in output.json #3

sagarr opened this issue Jun 3, 2020 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@sagarr
Copy link

sagarr commented Jun 3, 2020

Hi,

Is it possible to return base64 encoded image segmentation result in output.json?

This is the code I came up with after googling

auto output = module.forward({normalized_tensor}).toTensor();
torch::Tensor outputTensor = torch::sigmoid(output.detach().to(torch::kCPU));
outputTensor= torch::where(outputTensor >= 0.75, torch::ones(1), torch::zeros(1));
outputTensor = outputTensor.permute({ 0, 2, 3, 1 });
outputTensor = outputTensor.squeeze(0).detach();
outputTensor = outputTensor.mul(255).clamp(0, 255).to(torch::kU8);
outputTensor = outputTensor.to(torch::kCPU);
const auto outBuffer = outputTensor.data_ptr();
// TODO encode to base64 and return as json string

Not sure how can I return base64 encoded string back?

PS: Im not familiar with C++

@szymonmaszke
Copy link
Owner

Yes it should be fairly easy with .yaml settings. Will add a comment with it tomorrow.

BTW. Usually you don't need to delve into C++ with this tool.

@szymonmaszke
Copy link
Owner

Update: base64 return type is not currently supported, you would have to create C++ on your own based on torchlambda template generated setup.

@szymonmaszke szymonmaszke added enhancement New feature or request help wanted Extra attention is needed labels Jun 8, 2020
@szymonmaszke
Copy link
Owner

For now, you can see how to modify C++ source code in this issue, transforming to base64 needs some knowledge of C++ and AWS API & PyTorch C++ API though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants