mirror of
https://github.com/RapidAI/RapidOCR.git
synced 2026-11-11 13:30:51 +08:00
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:
10 files changed
+206
-14
No files matched your search
@@ -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
|
||||
Reference in new issue
Block a user