Retina_Training / utils.py
Habeeb Okunade
Develop model training
39ec591
raw
history blame contribute delete
523 Bytes
from __future__ import annotations
from pathlib import Path
import zipfile
import shutil
def unzip_dataset(zip_path: str | Path, extract_to: str | Path) -> str:
zip_path = Path(zip_path)
extract_to = Path(extract_to)
extract_to.mkdir(parents=True, exist_ok=True)
with zipfile.ZipFile(zip_path, 'r') as zf:
zf.extractall(extract_to)
return str(extract_to)
def clean_dir(path: str | Path):
p = Path(path)
if p.exists():
shutil.rmtree(p)
p.mkdir(parents=True, exist_ok=True)