Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -92,14 +92,14 @@ def read_img(img):
|
|
92 |
app = FastAPI()
|
93 |
class ImageType(BaseModel):
|
94 |
url: str
|
95 |
-
@app.post(
|
96 |
def ocr(request: Request,
|
97 |
-
file: bytes = File(
|
98 |
-
if request.method ==
|
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
|
|
|
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"
|