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

add methods to InferenceAPI #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

FlorianMF
Copy link
Contributor

add get_predictions
add get_explanations
add get_workflow_predictions

add get_predictions
add get_explanations
add get_workflow_predictions
@FlorianMF
Copy link
Contributor Author

I created my own branch from your 'inference' branch.
I added what I had already impelemnted + docstrings.

I'm not sure whether to return the response or its jsonified version.

@FlorianMF
Copy link
Contributor Author

I don't think we should implement a logic depending on the input type inside of the InferenceApi.
It should work no matter if the input_ is a buffer, a byte array, a file path, idk.
Same for the task type, the InferenceAPi should behave the same way for images, text, ...

@cceyda
Copy link
Owner

cceyda commented Jun 24, 2021

I don't think we should implement a logic depending on the input type inside of the InferenceApi.
It should work no matter if the input_ is a buffer, a byte array, a file path, idk.

yes, it feels straightforward to convert the inputs to a common type input_ and send a request to the torchserver.
But the problem is we don't know what structure/type of input the model server/handler is expecting. Is it json, is it a data stream, is it a string, is it form-encoded etc etc.

Input request parsing logics are here and also here. We can just implement things the predefined/base classes (for now).

For example VisionHandler request would be

input_=open(file_path).read()
httpx.post(PRED_API, data=input_) #or files={'data': input_} ?

That said, I have built custom handlers that expect different inputs like:

input_={
"path":file_path,
"some_other_param":'blahblah'
}
httpx.post(PRED_API, json=input_) # which requires a whole different request format and would fail otherwise

Same for the task type, the InferenceAPi should behave the same way for images, text, ...

Also it is not possible to determine which UI to show for which model endpoint.
I guess we can show all input modalities and the person can choose/combine smartly...and we would send everything with a default encoding format.

But that wouldn't be as cool as swagger UI.

Fastapi uses a pydantic BaseModel to define a response type class to solve this problem. From BaseModel it is possible to get an openapi schema. I think the request_envelope is a similar concept just less developed (no schema).
It might be worth looking at replacing base envelope with pydantic, don't know how much of an extensive change this would require on torchserve side.

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

Successfully merging this pull request may close these issues.

2 participants