Downloads · 30 days
4
17% of all-time downloads
madhavkarthi/project-1-location-classifier-resnet18
project-1-location-classifier-resnet18 is a image classification model from madhavkarthi. Use it when you need a label for an image. It is set up for pytorch. The card lists the license as mit.
This model is a fine-tuned version of ResNet-18 pretrained on ImageNet. It classifies images into 4 scene categories: cafe, gym, library, and outdoor.
Downloads · 30 days
4
17% of all-time downloads
All-time downloads
23
Public
Repo size
44.8 MB
Likes
0
Public
Click a slice to open those files.
.pth44.8 MB · 100%
From the Hugging Face model README
This model is a fine-tuned version of ResNet-18 pretrained on ImageNet. It classifies images into 4 scene categories: cafe, gym, library, and outdoor.
This model uses a dataset of video frames extracted from recordings of different indoor and outdoor locations. The ResNet-18 architecture was chosen for its balance of accuracy and computational efficiency, using transfer learning from ImageNet pretrained weights. Only the final fully-connected layer was retrained for the 4-class classification task.
The model is part of a larger pipeline that generates contextual music based on scene classification combined with weather and temporal metadata.
Intended use:
Limitations:
Dataset: Dataset used is: madhavkarthi/project-1-location-classification-dataset Video frame extraction from 4 scene categories
The dataset represents real-world indoor and outdoor environments with varying lighting conditions, angles, and compositions.
Images were preprocessed with resize to 224x224 and converted to tensors.
The following hyperparameters were used during training:
Training was conducted over 3 epochs with consistent loss reduction:
| Epoch | Training Loss | Status |
|---|---|---|
| 1 | 0.3395 | ✓ |
| 2 | 0.0111 | ✓ |
| 3 | 0.0041 | ✓ |
Note: Formal validation metrics were not computed during training. Model was validated qualitatively on held-out images.
This can be used to classify any input image into one of four classifiers: Library, Cafe, Gym, Outdoor.
import torch from torchvision import models, transforms from PIL import Image
device = torch.device("cuda" if torch.cuda.is_available() else "cpu") model = models.resnet18(weights=None) model.fc = torch.nn.Linear(model.fc.in_features, 4) model.load_state_dict(torch.load("pytorch_model.pth", map_location=device)) model = model.to(device) model.eval()
transform = transforms.Compose([ transforms.Resize((224, 224)), transforms.ToTensor(), ])
class_labels = ["cafe", "gym", "library", "outdoor"]
image = Image.open("your_image.jpg") if image.mode != 'RGB': image = image.convert('RGB')
input_tensor = transform(image).unsqueeze(0).to(device)
with torch.no_grad(): outputs = model(input_tensor) predicted_idx = outputs.argmax(dim=1).item() predicted_class = class_labels[predicted_idx] confidence = torch.softmax(outputs, dim=1)[0][predicted_idx].item()
print(f"Predicted: {predicted_class} (confidence: {confidence:.2%})")
ResNet-18 Structure:
This model was developed as part of a course project (24-679) exploring multimodal AI systems. It serves as the visual classification component in an image-to-music generation pipeline that combines scene recognition, metadata extraction, weather context, and music synthesis.
AI- ChatGPT, Claude were used in the creation of this model and dataset