Downloads · 30 days
0
MasalaDosai/resnet_genre
resnet_genre is a machine learning model from MasalaDosai. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This model uses a ResNet34 architecture trained on mel spectrograms generated from audio files to classify music genres.
Downloads · 30 days
0
Access
Public
Updated Apr 10, 2026
Repo size
85.3 MB
Likes
1
Public
Click a slice to open those files.
.pth85.3 MB · 100%
From the Hugging Face model README
This model uses a ResNet34 architecture trained on mel spectrograms generated from audio files to classify music genres.
Audio input is first converted into a spectrogram using librosa, then resized and passed into the CNN.
best_resnet34_librosa.pthThe model does NOT take raw audio directly.
Steps:
sr=22050)Replace this with your actual labels:
0 → Genre_1
1 → Genre_2
2 → Genre_3
3 → Genre_4
4 → Genre_5
5 → Genre_6
6 → Genre_7
7 → Genre_8
8 → Genre_9
9 → Genre_10
import torch
import torchvision.models as models
NUM_CLASSES = 10
model = models.resnet34()
model.fc = torch.nn.Linear(model.fc.in_features, NUM_CLASSES)
checkpoint = torch.load("best_resnet34_librosa.pth", map_location="cpu")
model.load_state_dict(checkpoint)
model.eval()
Fill this properly:
torch
torchvision
librosa
numpy