2023-07-25 20:36:57 +08:00
|
|
|
#!/bin/env python
|
|
|
|
|
2023-11-26 04:53:22 +08:00
|
|
|
"""Little command-line utility for probing a model on disk."""
|
|
|
|
|
2023-07-25 20:36:57 +08:00
|
|
|
import argparse
|
|
|
|
from pathlib import Path
|
2024-03-14 06:44:55 +08:00
|
|
|
from typing import get_args
|
2023-08-18 23:13:28 +08:00
|
|
|
|
2024-03-14 06:44:55 +08:00
|
|
|
from invokeai.backend.model_hash.model_hash import HASHING_ALGORITHMS
|
2023-11-27 02:37:47 +08:00
|
|
|
from invokeai.backend.model_manager import InvalidModelConfigException, ModelProbe
|
2023-07-25 20:36:57 +08:00
|
|
|
|
2024-03-14 06:44:55 +08:00
|
|
|
algos = ", ".join(set(get_args(HASHING_ALGORITHMS)))
|
|
|
|
|
2023-07-25 20:36:57 +08:00
|
|
|
parser = argparse.ArgumentParser(description="Probe model type")
|
|
|
|
parser.add_argument(
|
2023-07-28 03:01:00 +08:00
|
|
|
"model_path",
|
2023-07-25 20:36:57 +08:00
|
|
|
type=Path,
|
2023-08-03 22:26:52 +08:00
|
|
|
nargs="+",
|
2023-07-25 20:36:57 +08:00
|
|
|
)
|
2024-03-14 06:44:55 +08:00
|
|
|
parser.add_argument(
|
|
|
|
"--hash_algo",
|
|
|
|
type=str,
|
2024-03-21 14:38:46 +08:00
|
|
|
default="blake3_single",
|
|
|
|
help=f"Hashing algorithm to use (default: blake3_single), one of: {algos}",
|
2024-03-14 06:44:55 +08:00
|
|
|
)
|
2023-07-28 03:01:00 +08:00
|
|
|
args = parser.parse_args()
|
2023-07-25 20:36:57 +08:00
|
|
|
|
2023-08-03 22:26:52 +08:00
|
|
|
for path in args.model_path:
|
2023-11-26 04:53:22 +08:00
|
|
|
try:
|
2024-03-14 06:44:55 +08:00
|
|
|
info = ModelProbe.probe(path, hash_algo=args.hash_algo)
|
2023-11-26 04:53:22 +08:00
|
|
|
print(f"{path}:{info.model_dump_json(indent=4)}")
|
|
|
|
except InvalidModelConfigException as exc:
|
|
|
|
print(exc)
|