Skip to content

Commit bd0e899

Browse files
committed
Redundancy for downloading some models
Fixes #442
1 parent 7a3a782 commit bd0e899

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

src/core.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,22 @@ def run_3dphoto(device, img_rgb, img_depth, inputnames, outpath, gen_inpainted_m
365365
# create paths to model if not present
366366
os.makedirs('./models/3dphoto/', exist_ok=True)
367367

368-
ensure_file_downloaded(edgemodel_path,
369-
"https://filebox.ece.vt.edu/~jbhuang/project/3DPhoto/model/edge-model.pth")
370-
ensure_file_downloaded(depthmodel_path,
371-
"https://filebox.ece.vt.edu/~jbhuang/project/3DPhoto/model/depth-model.pth")
372-
ensure_file_downloaded(colormodel_path,
373-
"https://filebox.ece.vt.edu/~jbhuang/project/3DPhoto/model/color-model.pth")
368+
ensure_file_downloaded(
369+
edgemodel_path,
370+
["https://huggingface.co/spaces/Epoching/3D_Photo_Inpainting/resolve/e389e564fd2a55cf/checkpoints/edge-model.pth",
371+
"https://filebox.ece.vt.edu/~jbhuang/project/3DPhoto/model/edge-model.pth"],
372+
"b1d768bd008ad5fe9f540004f870b8c3d355e4939b2009aa4db493fd313217c9")
373+
ensure_file_downloaded(
374+
depthmodel_path,
375+
["https://huggingface.co/spaces/Epoching/3D_Photo_Inpainting/resolve/e389e564fd2a55cf/checkpoints/depth-model.pth",
376+
"https://filebox.ece.vt.edu/~jbhuang/project/3DPhoto/model/depth-model.pth"],
377+
"2d0e63e89a22762ddfa8bc8c9f8c992e5532b140123274ffc6e4171baa1b76f8")
378+
ensure_file_downloaded(
379+
colormodel_path,
380+
["https://huggingface.co/spaces/Epoching/3D_Photo_Inpainting/resolve/e389e564fd2a55cf/checkpoints/color-model.pth",
381+
"https://filebox.ece.vt.edu/~jbhuang/project/3DPhoto/model/color-model.pth"],
382+
"383c9b1db70097907a6f9c8abb0303e7056f50d5456a36f34ab784592b8b2c20"
383+
)
374384

375385
print("Loading edge model ..")
376386
depth_edge_model = Inpaint_Edge_Net(init_weights=True)

src/misc.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ def get_commit_hash():
1919
SCRIPT_FULL_NAME = f"{SCRIPT_NAME} {SCRIPT_VERSION} ({get_commit_hash()})"
2020

2121

22+
# # Returns SHA256 hash of a file
23+
# import hashlib
24+
# def sha256sum(filename):
25+
# with open(filename, 'rb', buffering=0) as f:
26+
# return hashlib.file_digest(f, 'sha256').hexdigest()
2227
def ensure_file_downloaded(filename, url, sha256_hash_prefix=None):
2328
import torch
2429
# Do not check the hash every time - it is somewhat time-consumin
@@ -35,4 +40,5 @@ def ensure_file_downloaded(filename, url, sha256_hash_prefix=None):
3540
return # The correct model was downloaded, no need to try more
3641
except:
3742
pass
38-
raise RuntimeError('Download failed. Try again later or manually download the file to that location.')
43+
raise RuntimeError(f'Download failed. '
44+
f'Try again later or manually download the file {filename} to location {url}.')

0 commit comments

Comments
 (0)