|
|
|
import platform |
|
import sys |
|
from typing import Dict, Any |
|
|
|
import packaging.version |
|
from rich import print |
|
|
|
_PY_VERSION: str = sys.version.split()[0].rstrip("+") |
|
|
|
if packaging.version.Version(_PY_VERSION) < packaging.version.Version("3.8.0"): |
|
import importlib_metadata |
|
else: |
|
import importlib.metadata as importlib_metadata |
|
|
|
_package_versions = {} |
|
|
|
_CANDIDATES = [ |
|
"torch", |
|
"Pillow", |
|
"diffusers", |
|
"transformers", |
|
"opencv-python", |
|
"xformers", |
|
"accelerate", |
|
"lama-cleaner" |
|
] |
|
|
|
for name in _CANDIDATES: |
|
_package_versions[name] = "N/A" |
|
try: |
|
_package_versions[name] = importlib_metadata.version(name) |
|
except importlib_metadata.PackageNotFoundError: |
|
pass |
|
|
|
|
|
def dump_environment_info() -> Dict[str, str]: |
|
"""Dump information about the machine to help debugging issues. """ |
|
|
|
|
|
info: Dict[str, Any] = { |
|
"Platform": platform.platform(), |
|
"Python version": platform.python_version(), |
|
} |
|
info.update(_package_versions) |
|
print("\n".join([f"- {prop}: {val}" for prop, val in info.items()]) + "\n") |
|
return info |
|
|