Update NATS-Bench (sss version 1.0)

This commit is contained in:
D-X-Y
2020-08-28 06:02:35 +00:00
parent 3529b993ff
commit c68458f66c
9 changed files with 413 additions and 28 deletions

View File

@@ -3,3 +3,4 @@ from .gpu_manager import GPUManager
from .flop_benchmark import get_model_infos, count_parameters_in_MB
from .affine_utils import normalize_points, denormalize_points
from .affine_utils import identity2affine, solve2theta, affine2image
from .hash_utils import get_md5_file

16
lib/utils/hash_utils.py Normal file
View File

@@ -0,0 +1,16 @@
import os, hashlib
def get_md5_file(file_path, post_truncated=5):
md5_hash = hashlib.md5()
if os.path.exists(file_path):
xfile = open(file_path, "rb")
content = xfile.read()
md5_hash.update(content)
digest = md5_hash.hexdigest()
else:
raise ValueError('[get_md5_file] {:} does not exist'.format(file_path))
if post_truncated is None:
return digest
else:
return digest[-post_truncated:]