Spaces:
Sleeping
Sleeping
| # src/inference/base_model.py | |
| from abc import ABC, abstractmethod | |
| from typing import Dict, Any | |
| from PIL import Image | |
| class BaseModel(ABC): | |
| """Common interface for all pet recognition models.""" | |
| def __init__(self, name: str, labels: Dict[int, str]): | |
| self.name = name | |
| self.labels = labels | |
| def preprocess(self, image: Image.Image) -> Any: | |
| """Convert PIL image β model input (tensor / numpy / feature vector).""" | |
| pass | |
| def predict(self, image: Image.Image) -> Dict[str, Any]: | |
| """ | |
| Run full pipeline: preprocess β forward pass β postprocess. | |
| Returns: | |
| { | |
| "class_id": int, | |
| "class_name": str, | |
| "probs": Dict[str, float], # optional, top-k | |
| } | |
| """ | |
| pass | |