-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/#4 convert fastapi #5
Conversation
@gogyzzz PR 리뷰어 설정했습니다. |
serving/server.py
Outdated
describtion="MNIST 모델을 추론하는 API입니다") | ||
namespace = api.namespace('mnist', description='MNIST 모델') | ||
from fastapi import FastAPI | ||
from handler import (Handler, Request, Response) |
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.
Response는 정의해놓고 안쓰이는 것 같은데 맞나요??
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.
@ app.post("/model/")
async def inference(request: Request):
response = handler(request)
return response
에서 response
는 Response 객체입니다.
Response 객체는 아래와 같구요.
class Response(BaseModel):
prediction: str
이 Response 객체는 Handler
의 던더메소드인 __call__
에서 오구요.
def __call__(self, request: Request) -> str:
base64image: str = request.base64_image_string
inputs: torch.Tensor = self._preprocessing(base64image)
prediction: str = self.model.inference(inputs)
return Response(prediction=prediction)
최종적으로 return된 Response객체는 브라우져에서 아래와 같이 보이게됩니다.
{
"prediction" : (str)
}
Codecov Report
@@ Coverage Diff @@
## master #5 +/- ##
=========================================
Coverage ? 31.32%
=========================================
Files ? 7
Lines ? 83
Branches ? 0
=========================================
Hits ? 26
Misses ? 57
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
Pull Request
레파지토리에 기여해주셔서 감사드립니다.
해당 PR을 제출하기 전에 아래 사항이 완료되었는지 확인 부탁드립니다:
1. 해당 PR은 어떤 내용인가요?
2. PR과 관련된 이슈가 있나요?
#4