Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save pythonlessons/a24d4ad54e2faa0f238ee8b9bc2133b5 to your computer and use it in GitHub Desktop.

Select an option

Save pythonlessons/a24d4ad54e2faa0f238ee8b9bc2133b5 to your computer and use it in GitHub Desktop.
handwriting_recognition_pytorch
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