Views
No views yet
| Model Variant | Sparsity | Top-1 Acc | Top-5 Acc | Params (M) | FLOPs (G) | Size (MB) |
|---|---|---|---|---|---|---|
| Original ResNet-50 | 0% | 76.13% | 92.86% | 25.56 | 4.12 | ~98 |
| ModHiFi-Tiny | ~67% | 73.85% | 91.83% | 8.38 | 1.13 | ~33 |
Note: "FLOPs" measures the number of floating-point operations required for a single inference pass. Lower is better for latency and battery life.
torchvision.transforms. The Hugging Face pipeline uses PIL (Pillow) for image resizing by default.preprocessor_config.json.pipeline with the exact PyTorch transforms used during training:1from torchvision import transforms
2from transformers import pipeline
3import torch
4
5# 1. Define the Exact PyTorch Transform
6val_transform = transforms.Compose([
7 transforms.Resize(256), # Resize shortest edge to 256
8 transforms.CenterCrop(224), # Center crop 224x224
9 transforms.ToTensor(), # Convert to Tensor (0-1)
10 transforms.Normalize( # ImageNet Normalization
11 mean=[0.485, 0.456, 0.406],
12 std=[0.229, 0.224, 0.225]
13 ),
14])
15
16# 2. Define a Wrapper to force Pipeline to use PyTorch
17class PyTorchProcessor:
18 def __init__(self, transform):
19 self.transform = transform
20 self.image_processor_type = "custom"
21
22 def __call__(self, images, **kwargs):
23 if not isinstance(images, list): images = [images]
24 # Apply transforms and stack
25 pixel_values = torch.stack([self.transform(img.convert("RGB")) for img in images])
26 return {"pixel_values": pixel_values}
27
28# 3. Initialize Pipeline with Custom Processor
29pipe = pipeline(
30 "image-classification",
31 model="MLLabIISc/ModHiFi-ResNet50-ImageNet-Tiny",
32 image_processor=PyTorchProcessor(val_transform), # <--- Fixes the accuracy gap
33 trust_remote_code=True,
34 device=0 # Use GPU if available
35)pip install torch transformers1import requests
2from PIL import Image
3from transformers import pipeline
4
5# Load model (ensure trust_remote_code=True for custom architecture)
6pipe = pipeline(
7 "image-classification",
8 model="MLLabIISc/ModHiFi-ResNet50-ImageNet-Tiny",
9 trust_remote_code=True
10)
11
12# Load an image
13url = "http://images.cocodataset.org/val2017/000000039769.jpg"
14image = Image.open(requests.get(url, stream=True).raw)
15
16# Run Inference
17results = pipe(image)
18print(f"Predicted Class: {results[0]['label']}")
19print(f"Confidence: {results[0]['score']:.4f}")@inproceedings{kashyap2026modhifi,
title = {ModHiFi: Identifying High Fidelity predictive components for Model Modification},
author = {Kashyap, Dhruva and Murti, Chaitanya and Nayak, Pranav and Narshana, Tanay and Bhattacharyya, Chiranjib},
booktitle = {Advances in Neural Information Processing Systems},
year = {2025},
eprint = {2511.19566},
archivePrefix = {arXiv},
primaryClass = {cs.LG},
url = {https://arxiv.org/abs/2511.19566},
}