Skip to content

Commit

Permalink
updae
Browse files Browse the repository at this point in the history
  • Loading branch information
pbcquoc committed Dec 3, 2022
1 parent aee02a3 commit ef83b9b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion vietocr/model/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(self, config, pretrained=True, augmentor=ImgAugTransform()):
self.logger = Logger(logger)

if pretrained:
weight_file = download_weights(**config['pretrain'], quiet=config['quiet'])
weight_file = download_weights(config['pretrain'], quiet=config['quiet'])
self.load_weights(weight_file)

self.iter = 0
Expand Down
7 changes: 4 additions & 3 deletions vietocr/tool/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
import uuid
import requests
import tempfile
from tqdm import tqdm

def download_weights(uri, cached=None, md5=None, quiet=False):
if uri.startswith('http'):
return download(url=uri)
return download(url=uri, quiet)
return uri

def download(url):
def download(url, quiet=False):
tmp_dir = tempfile.gettempdir()
filename = url.split('/')[-1]
full_path = os.path.join(tmp_dir, filename)
Expand All @@ -23,7 +24,7 @@ def download(url):
with requests.get(url, stream=True) as r:
r.raise_for_status()
with open(full_path, 'wb') as f:
for chunk in r.iter_content(chunk_size=8192):
for chunk in tqdm(r.iter_content(chunk_size=8192)):
# If you have chunk encoded response uncomment if
# and set chunk_size parameter to None.
#if chunk:
Expand Down

0 comments on commit ef83b9b

Please sign in to comment.