Metadata-Version: 2.4
Name: brach-assignment-bp-2026
Version: 0.1.0
Summary: A simple PyTorch wrapper for image classification using a pretrained ResNet18 model
Requires-Python: >=3.11
Requires-Dist: pillow
Requires-Dist: torch
Requires-Dist: torchvision
Description-Content-Type: text/markdown

# Vision Model Package: ResNet18 Wrapper

This package provides a simple, production-ready interface for image classification using a pretrained ResNet18 model. It is designed to be easily installable and used for quick inference tasks.

---

### Installation

The package can be installed via pip:

```pip install Dmytro-Shapovalov-brach-assignment-2026```

---

### Quick Start

```
from my_package import ModelWrapper

# Initialize the model (weights are loaded automatically)
inferer = ModelWrapper()

# Run prediction
img_path = "test_image.jpg"
predict = inferer.predict(img_path)

print(f"Predicted Class Index: {predict}")
```

---

### API reference

- ModelWrapper(model_path=None)

    The main class for managing the model and inference.

    model_path: Optional path to a custom .pth file. If None, it automatically loads the weights.pth bundled with the package.


- ModelWrapper.predict(image_path)

    Performs the full inference pipeline on a single image.

    Input: str path to the image file.

    Returns: int representing the predicted class index.

    Process: Handles image loading (PIL), resizing (224x224), normalization (ImageNet stats), and tensor conversion (Torch)

---

### Evaluation Proposal

To evaluate this model on a specific image classification task, I would use a standard validation pipeline to evaluate both accuracy and robustness.

- Dataset: A separate test set relevant to the task.


- Metrics:

    Accuracy: measures the percentage of correct predictions.
    
    F1-Score: evaluates performance across potentially imbalanced classes.
    
    Inference Latency: measures the average time taken for a single prediction.


- Pipeline:

    Data Loading: using torchvision.datasets and DataLoader feed images in batches.
    
    Inference Mode: setting the model to .eval() and using torch.no_grad() to disable gradient calculation and save memory.
    
    Comparison: comparing predicted indices against ground truth labels to generate a confusion matrix.
    
    Reporting: aggregating results to identify specific classes where the model might be underperforming.


- Evaluation Pseudocode:
    ```
    model.eval()
    results = []
    with torch.no_grad():
        for images, labels in test_loader:
            outputs = model(images)
            preds = torch.argmax(outputs, dim=1)
            results.extend((preds == labels).tolist())
    
    accuracy = sum(results) / len(results)
    print(f"Test Accuracy: {accuracy:.2%}")
    ```