Skip to content
This repository was archived by the owner on Aug 25, 2025. It is now read-only.
This repository was archived by the owner on Aug 25, 2025. It is now read-only.

Semantic segmentation prediction in output.json #3

@sagarr

Description

@sagarr

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++

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions