Clemylia / Musica1

huggingface.co
Total runs: 26
24-hour runs: 0
7-day runs: 7
30-day runs: 26
Model's Last Updated: October 11 2025
audio-classification

Introduction of Musica1

Model Details of Musica1

🩷🌸 Musica 🌸🩷

Musica

🦋 c'est quoi ?

Musica est un projet de machine learning, de type classification d'audio, il a été conçu pour classifier les chansons au niveau de leur rythme (calé ou décalé), C'est-à-dire de percevoir les décalages rythmiques dans les chansons.

❤️ Comment utiliser ?

Pour utiliser Musica, Qui a été crée from scratch sur la dataset Clemylia/Tempo, Vous devez reconstruire le code d'inférence, Voici un exemple de code d'utilisation :

import torch
import torch.nn as nn
import torch.nn.functional as F
import torchaudio
import numpy as np
from huggingface_hub import hf_hub_download
from datasets import load_dataset, Audio # On garde l'import au cas où

# =============================================================================
# PARTIE 1 : DÉFINITION DE L'ARCHITECTURE (inchangée)
# =============================================================================

NUM_CLASSES = 2
N_MELS = 128

class AudioClassifier(nn.Module):
    """Réseau de Neurones Convolutionnels (CNN) que nous avons entraîné."""
    def __init__(self):
        super(AudioClassifier, self).__init__()
        self.conv1 = nn.Conv2d(in_channels=1, out_channels=32, kernel_size=(5, 5), padding=2)
        self.bn1 = nn.BatchNorm2d(32)
        self.pool1 = nn.MaxPool2d(kernel_size=(2, 2))
        self.conv2 = nn.Conv2d(in_channels=32, out_channels=64, kernel_size=(3, 3), padding=1)
        self.bn2 = nn.BatchNorm2d(64)
        self.pool2 = nn.MaxPool2d(kernel_size=(2, 2))
        self.conv3 = nn.Conv2d(in_channels=64, out_channels=128, kernel_size=(3, 3), padding=1)
        self.bn3 = nn.BatchNorm2d(128)
        self.pool3 = nn.MaxPool2d(kernel_size=(2, 2))
        self.avgpool = nn.AdaptiveAvgPool2d((1, 1))
        self.fc1 = nn.Linear(128 * 1 * 1, NUM_CLASSES)

    def forward(self, x):
        x = self.pool1(F.relu(self.bn1(self.conv1(x))))
        x = self.pool2(F.relu(self.bn2(self.conv2(x))))
        x = self.pool3(F.relu(self.bn3(self.conv3(x))))
        x = self.avgpool(x)
        x = torch.flatten(x, 1)
        return self.fc1(x)


# =============================================================================
# PARTIE 2 : FONCTIONS DE PRÉPARATION POUR L'INFÉRENCE (inchangée)
# =============================================================================

SAMPLING_RATE = 16000
N_FFT = 400
HOP_LENGTH = 160
MAX_TIME_STEPS = 300

def prepare_spectrogram(audio_path):
    """
    Charge un fichier audio, calcule le Log-Mel Spectrogramme, et le prépare
    pour le modèle.
    """
    # 1. Charger et Rééchantillonner
    waveform, sr = torchaudio.load(audio_path)
    if sr != SAMPLING_RATE:
        resampler = torchaudio.transforms.Resample(orig_freq=sr, new_freq=SAMPLING_RATE)
        waveform = resampler(waveform)

    if waveform.shape[0] > 1:
        waveform = torch.mean(waveform, dim=0, keepdim=True)

    # 2. Calculer le Log-Mel Spectrogramme
    mel_spectrogram_transform = torchaudio.transforms.MelSpectrogram(
        sample_rate=SAMPLING_RATE,
        n_fft=N_FFT,
        hop_length=HOP_LENGTH,
        n_mels=N_MELS,
    )
    mel_spectrogram = mel_spectrogram_transform(waveform.squeeze(0))
    log_mel_spectrogram = torchaudio.transforms.AmplitudeToDB()(mel_spectrogram)

    # 3. Tronquer
    if log_mel_spectrogram.shape[1] > MAX_TIME_STEPS:
        log_mel_spectrogram = log_mel_spectrogram[:, :MAX_TIME_STEPS]

    # 4. Ajouter les dimensions Batch et Channel : [1, 1, N_MELS, Time_Steps]
    input_tensor = log_mel_spectrogram.unsqueeze(0).unsqueeze(0)

    return input_tensor


def predict_audio(model, audio_tensor):
    """
    Effectue la prédiction et retourne l'étiquette.
    """
    model.eval()
    device = next(model.parameters()).device

    with torch.no_grad():
        audio_tensor = audio_tensor.to(device)
        outputs = model(audio_tensor)

        probabilities = F.softmax(outputs, dim=1)
        predicted_index = torch.argmax(probabilities, dim=1).item()

        # Décodeur des classes (assumant 0 = Calé, 1 = Décalé)
        class_labels = {0: "Calé (On Beat)", 1: "Décalé (Off Beat)"}

        return class_labels[predicted_index], probabilities[0].cpu().numpy()


# =============================================================================
# PARTIE 3 : CHARGEMENT DU MODÈLE ET EXÉCUTION DU TEST (CORRIGÉE)
# =============================================================================

# --- Configuration Hugging Face ---
REPO_ID = "Clemylia/Musica1"
MODEL_FILENAME = "pytorch_model.bin"

# 1. Télécharger les poids du modèle
print(f"1. Téléchargement des poids du modèle depuis {REPO_ID}...")
try:
    model_path = hf_hub_download(repo_id=REPO_ID, filename=MODEL_FILENAME)
except Exception as e:
    print(f"Erreur de téléchargement : {e}. Vérifiez le nom du dépôt et les permissions.")
    exit()

# 2. Charger le modèle
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = AudioClassifier()

try:
    model.load_state_dict(torch.load(model_path, map_location=device))
    model.to(device)
    print(f"2. Modèle chargé avec succès sur {device}.")
except Exception as e:
    print(f"Erreur lors du chargement des poids : {e}")
    exit()

# 3. Préparer une donnée de test

# *** CORRECTION MAJEURE ***
# Veuillez remplacer le chemin ci-dessous par un chemin valide sur votre système !
# Exemple : "C:/Users/Clemylia/Desktop/mes_sons/calé_test.wav" ou "./data/audio_test.mp3"
# ----------------------------------------------------------------------------------
AUDIO_TEST_FILE = input("Veuillez entrer le chemin complet d'un fichier audio (ex: /path/to/test.wav): ")
# ----------------------------------------------------------------------------------

print(f"\n3. Préparation d'un échantillon de test à partir de: {AUDIO_TEST_FILE}...")

try:
    input_tensor = prepare_spectrogram(AUDIO_TEST_FILE)
    audio_test_path = AUDIO_TEST_FILE # Pour l'affichage final

except Exception as e:
    print(f"Erreur lors de la préparation de l'échantillon de test (le fichier existe-t-il ? le format est-il pris en charge par torchaudio ?) : {e}")
    input_tensor = None


# 4. Exécuter la prédiction
if input_tensor is not None:
    print(f"\n4. Exécution de la prédiction sur l'échantillon...")

    prediction, probabilities = predict_audio(model, input_tensor)

    # Affichage des résultats
    print("\n-------------------------------------------")
    print(f"FICHIER TESTÉ: {audio_test_path}")
    print(f"PRÉDICTION: {prediction}")
    print(f"PROBABILITÉS: Calé={probabilities[0]:.4f}, Décalé={probabilities[1]:.4f}")
    print("-------------------------------------------")
else:
    print("Test annulé faute de pouvoir traiter le fichier audio.")
❤️🔥 Informations sur Musica

nom : Musica version : 1 (entraînement sur un tout petit dataset) développeur : Clemylia Tache : détecter si une chanson est dans le rythme où pas

❤️**amusez vous bien à détecter si vos chansons d'anniversaire, vos bruits de bouches, vos cover de chansons ou autre sont calé et si vous avez le rythme !**❤️

Runs of Clemylia Musica1 on huggingface.co

26
Total runs
0
24-hour runs
2
3-day runs
7
7-day runs
26
30-day runs

More Information About Musica1 huggingface.co Model

More Musica1 license Visit here:

https://choosealicense.com/licenses/mit

Musica1 huggingface.co

Musica1 huggingface.co is an AI model on huggingface.co that provides Musica1's model effect (), which can be used instantly with this Clemylia Musica1 model. huggingface.co supports a free trial of the Musica1 model, and also provides paid use of the Musica1. Support call Musica1 model through api, including Node.js, Python, http.

Clemylia Musica1 online free

Musica1 huggingface.co is an online trial and call api platform, which integrates Musica1's modeling effects, including api services, and provides a free online trial of Musica1, you can try Musica1 online for free by clicking the link below.

Clemylia Musica1 online free url in huggingface.co:

https://huggingface.co/Clemylia/Musica1

Musica1 install

Musica1 is an open source model from GitHub that offers a free installation service, and any user can find Musica1 on GitHub to install. At the same time, huggingface.co provides the effect of Musica1 install, users can directly use Musica1 installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

Musica1 install url in huggingface.co:

https://huggingface.co/Clemylia/Musica1

Url of Musica1

Provider of Musica1 huggingface.co

Clemylia
ORGANIZATIONS

Other API from Clemylia

huggingface.co

Total runs: 439
Run Growth: 79
Growth Rate: 18.00%
Updated:September 29 2025
huggingface.co

Total runs: 364
Run Growth: 41
Growth Rate: 11.26%
Updated:October 30 2025
huggingface.co

Total runs: 316
Run Growth: 316
Growth Rate: 100.00%
Updated:December 02 2025
huggingface.co

Total runs: 263
Run Growth: 263
Growth Rate: 100.00%
Updated:November 05 2025
huggingface.co

Total runs: 214
Run Growth: 214
Growth Rate: 100.00%
Updated:November 23 2025
huggingface.co

Total runs: 197
Run Growth: 28
Growth Rate: 14.21%
Updated:October 30 2025
huggingface.co

Total runs: 168
Run Growth: 23
Growth Rate: 13.69%
Updated:October 19 2025
huggingface.co

Total runs: 162
Run Growth: 162
Growth Rate: 100.00%
Updated:October 07 2025
huggingface.co

Total runs: 162
Run Growth: 86
Growth Rate: 53.09%
Updated:November 05 2025
huggingface.co

Total runs: 131
Run Growth: 13
Growth Rate: 9.92%
Updated:October 03 2025
huggingface.co

Total runs: 127
Run Growth: 127
Growth Rate: 100.00%
Updated:November 26 2025
huggingface.co

Total runs: 126
Run Growth: 126
Growth Rate: 100.00%
Updated:November 27 2025
huggingface.co

Total runs: 106
Run Growth: 50
Growth Rate: 47.17%
Updated:November 29 2025
huggingface.co

Total runs: 97
Run Growth: 97
Growth Rate: 100.00%
Updated:November 05 2025
huggingface.co

Total runs: 94
Run Growth: 94
Growth Rate: 100.00%
Updated:November 17 2025
huggingface.co

Total runs: 85
Run Growth: 31
Growth Rate: 36.47%
Updated:November 13 2025
huggingface.co

Total runs: 84
Run Growth: -80
Growth Rate: -95.24%
Updated:December 01 2025
huggingface.co

Total runs: 81
Run Growth: 81
Growth Rate: 100.00%
Updated:November 23 2025
huggingface.co

Total runs: 71
Run Growth: 71
Growth Rate: 100.00%
Updated:November 14 2025
huggingface.co

Total runs: 71
Run Growth: 71
Growth Rate: 100.00%
Updated:November 29 2025
huggingface.co

Total runs: 67
Run Growth: 67
Growth Rate: 100.00%
Updated:December 06 2025
huggingface.co

Total runs: 61
Run Growth: 16
Growth Rate: 26.23%
Updated:November 08 2025
huggingface.co

Total runs: 57
Run Growth: 57
Growth Rate: 100.00%
Updated:November 30 2025
huggingface.co

Total runs: 55
Run Growth: 5
Growth Rate: 9.09%
Updated:November 14 2025
huggingface.co

Total runs: 54
Run Growth: 5
Growth Rate: 9.26%
Updated:November 09 2025
huggingface.co

Total runs: 54
Run Growth: 54
Growth Rate: 100.00%
Updated:November 14 2025
huggingface.co

Total runs: 52
Run Growth: 52
Growth Rate: 100.00%
Updated:November 15 2025
huggingface.co

Total runs: 46
Run Growth: 46
Growth Rate: 100.00%
Updated:November 30 2025
huggingface.co

Total runs: 42
Run Growth: -5
Growth Rate: -11.90%
Updated:November 18 2025
huggingface.co

Total runs: 37
Run Growth: 37
Growth Rate: 100.00%
Updated:November 14 2025
huggingface.co

Total runs: 36
Run Growth: 5
Growth Rate: 13.89%
Updated:November 14 2025
huggingface.co

Total runs: 32
Run Growth: 3
Growth Rate: 9.38%
Updated:December 06 2025
huggingface.co

Total runs: 24
Run Growth: -29
Growth Rate: -120.83%
Updated:November 26 2025
huggingface.co

Total runs: 22
Run Growth: 5
Growth Rate: 22.73%
Updated:September 24 2025
huggingface.co

Total runs: 16
Run Growth: 3
Growth Rate: 18.75%
Updated:February 02 2026
huggingface.co

Total runs: 15
Run Growth: 6
Growth Rate: 40.00%
Updated:December 19 2025
huggingface.co

Total runs: 14
Run Growth: -2
Growth Rate: -14.29%
Updated:January 20 2026
huggingface.co

Total runs: 12
Run Growth: 6
Growth Rate: 50.00%
Updated:September 25 2025
huggingface.co

Total runs: 12
Run Growth: -1
Growth Rate: -8.33%
Updated:January 07 2026
huggingface.co

Total runs: 10
Run Growth: 0
Growth Rate: 0.00%
Updated:October 28 2025
huggingface.co

Total runs: 10
Run Growth: 2
Growth Rate: 20.00%
Updated:October 12 2025
huggingface.co

Total runs: 8
Run Growth: 2
Growth Rate: 25.00%
Updated:September 27 2025
huggingface.co

Total runs: 7
Run Growth: -36
Growth Rate: -514.29%
Updated:November 04 2025
huggingface.co

Total runs: 6
Run Growth: 0
Growth Rate: 0.00%
Updated:January 17 2026
huggingface.co

Total runs: 5
Run Growth: -136
Growth Rate: -2720.00%
Updated:October 18 2025
huggingface.co

Total runs: 3
Run Growth: 3
Growth Rate: 100.00%
Updated:December 14 2025
huggingface.co

Total runs: 3
Run Growth: 2
Growth Rate: 66.67%
Updated:November 29 2025
huggingface.co

Total runs: 3
Run Growth: -2
Growth Rate: -66.67%
Updated:December 13 2025
huggingface.co

Total runs: 2
Run Growth: -6
Growth Rate: -300.00%
Updated:January 17 2026
huggingface.co

Total runs: 2
Run Growth: -2
Growth Rate: -100.00%
Updated:January 24 2026