pytorch / serve

Serve, optimize and scale PyTorch models in production
https://pytorch.org/serve/
Apache License 2.0
4.23k stars 864 forks source link

Read data from local directory of Torchserve server side #1778

Closed nhthanh0809 closed 2 years ago

nhthanh0809 commented 2 years ago

Hi all, Currently, i'm trying to send request to Torchserve by sending "image path" instead of "image data" (REST API) Although I put the image file to Current directory of Torchserve, but in Torchserve sever side I can not read this file (File can not be found) I tried to change TEMP env, but even put image file to there, Torchserve server still can not read it. Do have any solution for this issue? Thank you!

lxning commented 2 years ago

@nhthanh0809 TorchServe does not support a directory as the inference input payload. Can you clarify if "image path" is a directory?

nhthanh0809 commented 2 years ago

@lxning Thank for your responce, Actually, my idea is described as below: IDEA: I would like to send request to my customized object detection Torchserve model by using JSON like bellow: {"image": "/path/to/abc.jpeg"} Then in server side (XXX_handler.py) I want read this image file via "/path/to/abc.jpeg" path. Subsequently, I want to save the output of the model to specific directory (save image to "/path/to/output/dir/output.jpeg") IMPLEMENTATION: I've tried to put abc.jpeg into Torchserve Current directory, but in server side, the torchserve handler can not find this abc.jpeg. I also tried to save the output of the model (image) to file, Torchserve handler alway saves the output image to its TEMP directory. QUESTION: So do you have any solution or suggestion?

lxning commented 2 years ago

@nhthanh0809 you can write your own handler to process this request. you can save the output is the model dir in your handler. model dir can be found at here

nhthanh0809 commented 2 years ago

@lxning Many thanks for your suggestion. My goal is Torchserve can integrate with NFS server. I hope that Torchserve have this feature in future.