Fix issue 232 (#235)

* fix(rapidocr_onnxruntime): Fixed padding_h variable before assignment

* feat(rapidocr_onnxruntime): Add resize function

* feat(rapidocr_onnxruntime): Add limit of max_side_len and min_side_len

* tests: Add __init__
This commit is contained in:
SWHL authored and GitHub committed 2024-10-17 22:24:31 +08:00
1 parent b2fd006ee6
commit fd520ffdad
10 files changed
+206 -14

No files matched your search

+23
View File
@@ -4,8 +4,11 @@
import importlib
import sys
from pathlib import Path
from typing import Union
import requests
import yaml
from tqdm import tqdm
class BaseModule:
@@ -30,3 +33,23 @@ class BaseModule:
with open(yaml_path, "rb") as f:
data = yaml.load(f, Loader=yaml.Loader)
return data
def download_file(url: str, save_path: Union[str, Path]):
response = requests.get(url, stream=True, timeout=60)
status_code = response.status_code
if status_code != 200:
raise DownloadModelError("Something went wrong while downloading models")
total_size_in_bytes = int(response.headers.get("content-length", 1))
block_size = 1024 # 1 Kibibyte
with tqdm(total=total_size_in_bytes, unit="iB", unit_scale=True) as pb:
with open(save_path, "wb") as file:
for data in response.iter_content(block_size):
pb.update(len(data))
file.write(data)
class DownloadModelError(Exception):
pass