Created
March 20, 2023 13:53
-
-
Save pythonlessons/a24d4ad54e2faa0f238ee8b9bc2133b5 to your computer and use it in GitHub Desktop.
handwriting_recognition_pytorch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def download_and_unzip(url, extract_to='Datasets', chunk_size=1024*1024): | |
| http_response = urlopen(url) | |
| data = b'' | |
| iterations = http_response.length // chunk_size + 1 | |
| for _ in tqdm(range(iterations)): | |
| data += http_response.read(chunk_size) | |
| zipfile = ZipFile(BytesIO(data)) | |
| zipfile.extractall(path=extract_to) | |
| dataset_path = os.path.join('Datasets', 'IAM_Words') | |
| if not os.path.exists(dataset_path): | |
| download_and_unzip('https://git.io/J0fjL', extract_to='Datasets') | |
| file = tarfile.open(os.path.join(dataset_path, "words.tgz")) | |
| file.extractall(os.path.join(dataset_path, "words")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment