mirror of
https://github.com/deepinsight/insightface.git
synced 2025-12-30 08:02:27 +00:00
47 lines
1.4 KiB
Python
47 lines
1.4 KiB
Python
import hashlib
|
|
import os
|
|
import json
|
|
import click
|
|
|
|
need_models = [
|
|
"Pikachu",
|
|
"Megatron",
|
|
]
|
|
|
|
def get_file_hash_sha256(file_path):
|
|
sha256 = hashlib.sha256()
|
|
with open(file_path, 'rb') as f:
|
|
for chunk in iter(lambda: f.read(4096), b''):
|
|
sha256.update(chunk)
|
|
return sha256.hexdigest()
|
|
|
|
@click.command()
|
|
@click.argument('model_dir', default="test_res/pack/")
|
|
@click.option('--models', '-m', multiple=True, help='Specify the model name to process')
|
|
def main(model_dir, models):
|
|
model_info = {}
|
|
|
|
# If no model is specified, process all predefined models
|
|
models_to_process = models if models else need_models
|
|
|
|
for file in models_to_process:
|
|
file_path = os.path.join(model_dir, file)
|
|
if os.path.exists(file_path):
|
|
md5 = get_file_hash_sha256(file_path)
|
|
model_info[file] = {
|
|
"url": f"https://github.com/HyperInspire/InspireFace/releases/download/v1.x/{file}",
|
|
"filename": file,
|
|
"md5": md5
|
|
}
|
|
else:
|
|
print(f"Warning: File {file_path} does not exist")
|
|
|
|
print("\033[33mNeed to modify the python/inspireface/modules/utils/resource.py, changes to the information release\033[0m")
|
|
# Output the result
|
|
print(json.dumps(model_info, indent=4, ensure_ascii=False))
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|
|
|