File size: 752 Bytes
e8b0040
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import uvicorn
from fastapi import FastAPI, Body
from pydantic import BaseModel, Field
import sys
import os
import json
from main_infer import INFER_API


infer_api = INFER_API()

# create FastAPI instance
app = FastAPI()


class inputModel(BaseModel):
    img_path: str = Field(..., description="image path", examples=[""])

# Call model interface, post request
@app.post("/inter_api")
def inter_api(input_model: inputModel):
    img_path = input_model.img_path
    infer_api = INFER_API()
    score = infer_api.test(img_path)
    return  score


# run
if __name__ == '__main__':
    uvicorn.run(app='infer_api:app',
                host='0.0.0.0',
                port=10005,
                reload=False,
                workers=1
                )