Skip to content

Commit

Permalink
fix: model downloads on Windows platform
Browse files Browse the repository at this point in the history
  • Loading branch information
jinlong.wu committed Dec 17, 2024
1 parent a839a6e commit 29ae290
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 129 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,22 @@ __pycache__/

# Distribution / packaging
.Python
.DS_Store
data/
models/
output-*/
outputs-*/
outputs/
*.jpg
*.jpeg
*.png
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
.idea/
lib/
lib64/
parts/
Expand Down
15 changes: 6 additions & 9 deletions pix2text/doc_xl_layout/doc_xl_layout_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
box2list,
x_overlap,
merge_boxes,
prepare_model_files2,
)

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -124,15 +125,11 @@ def _prepare_model_files(self, root, model_info):
model_fp = model_dir / 'DocXLayout_231012.pth'
if model_fp.exists():
return model_fp
if model_dir.exists():
shutil.rmtree(str(model_dir))
model_dir.mkdir(parents=True)
download_cmd = f'huggingface-cli download --repo-type model --resume-download --local-dir-use-symlinks False breezedeus/pix2text-layout --local-dir {model_dir}'
os.system(download_cmd)
if not model_fp.exists(): # download failed above
if model_dir.exists():
shutil.rmtree(str(model_dir))
os.system('HF_ENDPOINT=https://hf-mirror.com ' + download_cmd)
model_fp = prepare_model_files2(
model_fp_or_dir=model_fp,
remote_repo="breezedeus/pix2text-layout",
file_or_dir="file",
)
return model_fp

def convert_eval_format(self, all_bboxes, opt):
Expand Down
Loading

0 comments on commit 29ae290

Please sign in to comment.