Inference general interface. For image, video, audio etc binary data, need encoded with base64. Args: request (Request): The request object. request_info (ModelScopeRequest): The post body. Returns: ApiResponse: For binary field, encoded with base64
(
request: Request,
body: BaseModel = Body(examples=[{
'usage': 'copy body from describe'
}]))
| 11 | |
| 12 | @router.post('/call') |
| 13 | async def inference( |
| 14 | request: Request, |
| 15 | body: BaseModel = Body(examples=[{ |
| 16 | 'usage': 'copy body from describe' |
| 17 | }])): # noqa E125 |
| 18 | """Inference general interface. |
| 19 | |
| 20 | For image, video, audio etc binary data, need encoded with base64. |
| 21 | |
| 22 | Args: |
| 23 | request (Request): The request object. |
| 24 | request_info (ModelScopeRequest): The post body. |
| 25 | |
| 26 | Returns: |
| 27 | ApiResponse: For binary field, encoded with base64 |
| 28 | """ |
| 29 | pipeline_service = request.app.state.pipeline |
| 30 | pipeline_info = request.app.state.pipeline_info |
| 31 | request_json = await request.json() |
| 32 | result = call_pipeline_with_json(pipeline_info, pipeline_service, |
| 33 | request_json) |
| 34 | # convert output to json, if binary field, we need encoded. |
| 35 | output = pipeline_output_to_service_base64_output( |
| 36 | pipeline_info['task_name'], result) |
| 37 | return output |
| 38 | |
| 39 | |
| 40 | @router.get('/describe') |
searching dependent graphs…