Skip to content

is this the correct HF inference code for this model? #6

@sleepingcat4

Description

@sleepingcat4

this is the code I used for inference for SONICS model:

from sonics import HFAudioClassifier
model = HFAudioClassifier.from_pretrained("awsaf49/sonics-spectttra-gamma-5s")

audio_file = "audio2.mp3"; import torchaudio 
waveform, sr = torchaudio.load(audio_file)

predictions = model(waveform)

import torch

probs = torch.sigmoid(predictions)
print("Probabilities:", probs)

pred_class = torch.argmax(predictions, dim=0) # or torch.argmax(probs, dim=0)
print("Predicted class index:", pred_class.item())

@awsaf49 is this the correct way of performing inference?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions