Update main.py
Browse files
main.py
CHANGED
@@ -41,14 +41,16 @@ async def ocr(
|
|
41 |
# languages: list = Body(["eng"])
|
42 |
):
|
43 |
try:
|
44 |
-
|
45 |
# # Check if the file format is allowed
|
46 |
# file_extension = image.filename.split(".")[-1].lower()
|
47 |
# if file_extension not in VALID_IMAGE_EXTENSIONS:
|
48 |
# raise HTTPException(status_code=400, detail="Invalid file format. Only .jpg, .jpeg, and .png are allowed.")
|
49 |
|
50 |
content = await image.read()
|
|
|
51 |
image = Image.open(BytesIO(content))
|
|
|
52 |
text = pytesseract.image_to_string(image, lang = 'eng')
|
53 |
# text = pytesseract.image_to_string(image, lang="+".join(languages))
|
54 |
except Exception as e:
|
|
|
41 |
# languages: list = Body(["eng"])
|
42 |
):
|
43 |
try:
|
44 |
+
|
45 |
# # Check if the file format is allowed
|
46 |
# file_extension = image.filename.split(".")[-1].lower()
|
47 |
# if file_extension not in VALID_IMAGE_EXTENSIONS:
|
48 |
# raise HTTPException(status_code=400, detail="Invalid file format. Only .jpg, .jpeg, and .png are allowed.")
|
49 |
|
50 |
content = await image.read()
|
51 |
+
print("[content]", content)
|
52 |
image = Image.open(BytesIO(content))
|
53 |
+
print("[image]", image)
|
54 |
text = pytesseract.image_to_string(image, lang = 'eng')
|
55 |
# text = pytesseract.image_to_string(image, lang="+".join(languages))
|
56 |
except Exception as e:
|