Spaces:
Sleeping
Sleeping
File size: 989 Bytes
dcd4485 896740b dcd4485 896740b dcd4485 896740b dcd4485 | 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 | from pathlib import Path
from PIL import Image
from model_service import get_model_config, get_model_service
IMAGE_PATH = Path("person.jpg")
# IMAGE_PATH = Path("no_person.jpg")
def main():
if not IMAGE_PATH.exists():
raise SystemExit(f"Image not found: {IMAGE_PATH}")
service = get_model_service()
config = get_model_config()
print(f"[INFO] device={service.device}")
print(f"[INFO] model_name={config.name}")
print(f"[INFO] model_backend={config.backend}")
print(f"[INFO] model_path={config.model_path}")
print(f"[INFO] image={IMAGE_PATH}")
img = Image.open(IMAGE_PATH).convert("RGB")
result = service.predict_image(img)
print("\n========== RESULT ==========")
print(f"Prediction: {result['label']}")
print(f"P(no_person) = {result['probabilities']['no_person']:.4f}")
print(f"P(person) = {result['probabilities']['person']:.4f}")
print("============================")
if __name__ == "__main__":
main()
|