model
Browse files- api.py +3 -2
- model/craft_mlt_25k.pth +3 -0
- model/english_g2.pth +3 -0
- model/latin_g2.pth +3 -0
api.py
CHANGED
|
@@ -8,6 +8,7 @@ import easyocr
|
|
| 8 |
import fitz
|
| 9 |
|
| 10 |
app = FastAPI()
|
|
|
|
| 11 |
|
| 12 |
@app.get('/')
|
| 13 |
async def index():
|
|
@@ -52,14 +53,14 @@ def apply_ocr_on_pdf(buffer):
|
|
| 52 |
|
| 53 |
results = []
|
| 54 |
for image in images:
|
| 55 |
-
reader = easyocr.Reader(['tr'])
|
| 56 |
result = reader.readtext(image, min_size=50, detail=0, paragraph=False, width_ths=0.9, blocklist="|[]{}")
|
| 57 |
results.extend(result)
|
| 58 |
|
| 59 |
return results
|
| 60 |
|
| 61 |
def apply_ocr_on_image(buffer):
|
| 62 |
-
reader = easyocr.Reader(['tr'])
|
| 63 |
image = cv2.imdecode(np.frombuffer(buffer.read(), np.uint8), cv2.IMREAD_COLOR)
|
| 64 |
image = preprocess_image(image)
|
| 65 |
result = reader.readtext(image, min_size=50, detail=0, paragraph=False, width_ths=1)
|
|
|
|
| 8 |
import fitz
|
| 9 |
|
| 10 |
app = FastAPI()
|
| 11 |
+
current_directory = os.getcwd()
|
| 12 |
|
| 13 |
@app.get('/')
|
| 14 |
async def index():
|
|
|
|
| 53 |
|
| 54 |
results = []
|
| 55 |
for image in images:
|
| 56 |
+
reader = easyocr.Reader(['tr'], gpu=True, model_storage_directory=f"{current_directory}/model", user_network_directory=f"{current_directory}/user_network", download_enabled=False)
|
| 57 |
result = reader.readtext(image, min_size=50, detail=0, paragraph=False, width_ths=0.9, blocklist="|[]{}")
|
| 58 |
results.extend(result)
|
| 59 |
|
| 60 |
return results
|
| 61 |
|
| 62 |
def apply_ocr_on_image(buffer):
|
| 63 |
+
reader = easyocr.Reader(['tr'], gpu=True, model_storage_directory=f"{current_directory}/model", user_network_directory=f"{current_directory}/user_network", download_enabled=False)
|
| 64 |
image = cv2.imdecode(np.frombuffer(buffer.read(), np.uint8), cv2.IMREAD_COLOR)
|
| 65 |
image = preprocess_image(image)
|
| 66 |
result = reader.readtext(image, min_size=50, detail=0, paragraph=False, width_ths=1)
|
model/craft_mlt_25k.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4a5efbfb48b4081100544e75e1e2b57f8de3d84f213004b14b85fd4b3748db17
|
| 3 |
+
size 83152330
|
model/english_g2.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e2272681d9d67a04e2dff396b6e95077bc19001f8f6d3593c307b9852e1c29e8
|
| 3 |
+
size 15143997
|
model/latin_g2.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:aaa95be1c4a9cb3496879bed7c520886ce1164f89e026f0c54488394e74e8c55
|
| 3 |
+
size 15406141
|