inoryQwQ commited on
Commit
8568f38
·
verified ·
1 Parent(s): fd312bc

Upload python/example.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. python/example.py +23 -0
python/example.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """ResNet50 Age Classification Example."""
3
+ import sys
4
+ from resnet50_sdk import ResNet50Classifier
5
+
6
+ def main():
7
+ if len(sys.argv) < 2:
8
+ print("Usage: python example.py <image_path>")
9
+ sys.exit(1)
10
+
11
+ model_path = "../models/model.axmodel" # relative to package
12
+ image_path = sys.argv[1]
13
+
14
+ classifier = ResNet50Classifier(model_path)
15
+ results = classifier.classify(image_path, top_k=5)
16
+
17
+ print(f"Image: {image_path}")
18
+ print("Top-5 predictions:")
19
+ for i, r in enumerate(results):
20
+ print(f" {i+1}. {r['label']}: {r['confidence']:.4f}")
21
+
22
+ if __name__ == "__main__":
23
+ main()