-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheck-model-files.py
More file actions
executable file
·100 lines (81 loc) · 3.01 KB
/
Copy pathcheck-model-files.py
File metadata and controls
executable file
·100 lines (81 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env python3
"""
Quick script to verify that a HuggingFace model repository has all required files for inference.
Usage:
python check-model-files.py bdhillon/PIv2
python check-model-files.py lerobot/pi0
"""
import sys
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
def check_model_files(repo_id: str):
"""Check if a HuggingFace model has all required files for inference."""
try:
from huggingface_hub import list_repo_files, repo_info
except ImportError:
logger.error("huggingface_hub not installed. Run: pip install huggingface_hub")
return False
logger.info(f"Checking model repository: {repo_id}")
logger.info("=" * 60)
# Required files for inference
required_files = [
"config.json",
"model.safetensors",
"policy_preprocessor.json",
"policy_postprocessor.json",
]
try:
# Get repository info
info = repo_info(repo_id, repo_type="model")
logger.info(f"Repository: {info.id}")
logger.info(f"Author: {info.author}")
if hasattr(info, 'lastModified'):
logger.info(f"Last modified: {info.lastModified}")
# List all files
logger.info("\n" + "=" * 60)
logger.info("All files in repository:")
logger.info("=" * 60)
files = list(list_repo_files(repo_id))
for f in sorted(files):
logger.info(f" {f}")
# Check required files
logger.info("\n" + "=" * 60)
logger.info("Required files check:")
logger.info("=" * 60)
all_present = True
for req_file in required_files:
if req_file in files:
logger.info(f" ✓ {req_file}")
else:
logger.error(f" ✗ MISSING: {req_file}")
all_present = False
# Summary
logger.info("\n" + "=" * 60)
if all_present:
logger.info("✓ SUCCESS: All required files are present!")
logger.info("This model is ready for inference.")
return True
else:
logger.error("✗ FAILURE: Some required files are missing!")
logger.error("This model cannot be used for inference until all files are present.")
return False
except Exception as e:
logger.error(f"Error accessing repository: {e}")
logger.info("\nPossible issues:")
logger.info(" 1. Repository doesn't exist")
logger.info(" 2. Repository is private (run: huggingface-cli login)")
logger.info(" 3. No internet connection")
return False
def main():
if len(sys.argv) != 2:
print("Usage: python check-model-files.py <huggingface-repo-id>")
print("\nExamples:")
print(" python check-model-files.py bdhillon/PIv2")
print(" python check-model-files.py lerobot/pi0")
sys.exit(1)
repo_id = sys.argv[1]
success = check_model_files(repo_id)
sys.exit(0 if success else 1)
if __name__ == "__main__":
main()