File size: 780 Bytes
e92bd0b | 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 | from ArabicOcr import arabicocr
import json
import numpy as np
from io import BytesIO
from PIL import Image
from aiohttp import ClientSession
async def getImage(img_url):
async with ClientSession() as session:
async with session.get(img_url) as response:
img_data = await response.read()
return BytesIO(img_data)
async def main_det(image):
try:
# image_path = image
out = "data.jpg"
results=await arabicocr.arabic_ocr(image,"a.jpg")
print(results)
words=[]
for i in range(len(results)):
word=results[i][1]
words.append(word)
return json.dumps({"prediction":words})
except Exception as e:
raise ValueError(f"Error in main_det: {str(e)}")
|