-
Notifications
You must be signed in to change notification settings - Fork 867
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
add resnet cpp handler #2514
base: cpp_backend
Are you sure you want to change the base?
add resnet cpp handler #2514
Conversation
Signed-off-by: jagadeesh <[email protected]>
Signed-off-by: jagadeesh <[email protected]>
4a9d16f
to
ec7e7f6
Compare
Signed-off-by: jagadeesh <[email protected]>
Signed-off-by: jagadeesh <[email protected]>
Signed-off-by: jagadeesh <[email protected]>
Signed-off-by: jagadeesh <[email protected]>
Signed-off-by: jagadeesh <[email protected]>
Signed-off-by: jagadeesh <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jagadeeshi2i thanks for your contribution! Overall it looks very good, please address the few comments I left.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to you create a local CMakeLists.txt in the image_classifier folder and use add_subfolder().
cpp/src/examples/CMakeLists.txt
Outdated
target_include_directories(resnet-18_handler PUBLIC ${OPENCV_DIR}) | ||
target_include_directories(resnet-18_handler PUBLIC ${RESNET_SRC_DIR}) | ||
target_link_libraries(resnet-18_handler PRIVATE ts_backends_torch_scripted ts_utils ${TORCH_LIBRARIES}) | ||
target_link_libraries(resnet-18_handler PRIVATE "/usr/local/lib/libopencv_imgcodecs.so") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be better to use find_package and use the parameters set there instead of absolute paths.
|
||
try { | ||
if (dtype_it->second == torchserve::PayloadType::kDATA_TYPE_BYTES) { | ||
// case2: the image is sent as bytesarray |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these commented out lines still needed?
|
||
// Check if the image was successfully decoded | ||
if (image.empty()) { | ||
std::cerr << "Failed to decode the image.\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we continue in case the image was unsuccessfully loaded? What happens with the code below if image is empty?
gpuImage.download(resultImage); | ||
|
||
// Create a tensor from the CPU Mat | ||
torch::Tensor tensorImage = torch::from_blob( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to create the tensor on GPU? Avoiding the gpuImage.download?
const torch::Tensor& data, | ||
std::pair<std::string&, std::map<uint8_t, std::string>&>& idx_to_req_id, | ||
std::shared_ptr<torchserve::InferenceResponseBatch>& response_batch) { | ||
std::ifstream jsonFile("index_to_name.json"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move loading of the file into the constructor to avoid reloading every time we do postprocessing?
- cleanup Signed-off-by: jagadeesh <[email protected]>
Description
Please read our CONTRIBUTING.md prior to creating your first pull request.
Please include a summary of the feature or issue being fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes #(issue)
Type of change
Please delete options that are not relevant.
Feature/Issue validation/testing
Please describe the Unit or Integration tests that you ran to verify your changes and relevant result summary. Provide instructions so it can be reproduced.
Please also list any relevant details for your test configuration.
Test A
Logs for Test A
Test B
Logs for Test B
Checklist: