omkar56 commited on
Commit
0931754
·
1 Parent(s): 47b56d3

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +5 -5
main.py CHANGED
@@ -92,14 +92,14 @@ def read_img(img):
92
  app = FastAPI()
93
  class ImageType(BaseModel):
94
  url: str
95
- @app.post(“/api/ocr)
96
  def ocr(request: Request,
97
- file: bytes = File()):
98
- if request.method == POST”:
99
  image_stream = io.BytesIO(file)
100
  image_stream.seek(0)
101
  file_bytes = np.asarray(bytearray(image_stream.read()), dtype=np.uint8)
102
  frame = cv2.imdecode(file_bytes, cv2.IMREAD_COLOR)
103
  label = read_img(frame)
104
- return label
105
- return No post request found
 
92
  app = FastAPI()
93
  class ImageType(BaseModel):
94
  url: str
95
+ @app.post("/api/ocr", response_model=dict)
96
  def ocr(request: Request,
97
+ file: bytes = File(...)):
98
+ if request.method == "POST":
99
  image_stream = io.BytesIO(file)
100
  image_stream.seek(0)
101
  file_bytes = np.asarray(bytearray(image_stream.read()), dtype=np.uint8)
102
  frame = cv2.imdecode(file_bytes, cv2.IMREAD_COLOR)
103
  label = read_img(frame)
104
+ return {"ImageText" : label}
105
+ return "No post request found"