InvokeAI/scripts/probe-model.py

34 lines
916 B
Python
Raw Normal View History

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