Spaces:
Sleeping
Sleeping
| 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() | |