Update app.py
Browse files15 unmodified lines1617181919202122212224252623242526272835 unmodified lines6465666869707172737467686970717273747677757615 unmodified linesdevice = torch.device("cpu")processor = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-base-960h")model = Wav2Vec2ForSequenceClassification.from_pretrained("facebook/wav2vec2-base-960h", num_labels=2).to(device)# model_path = "dysarthria_classifier12.pth"model_path = "dysarthria_classifier12.pth"# model_path = 'model_weights2.pth'model_path = '/home/user/app/dysarthria_classifier10.pth'model.load_state_dict(torch.load(model_path, map_location=torch.device('cpu')))# model_path = '/home/user/app/dysarthria_classifier10.pth'
# if os.path.exists(model_path):# print(f"Loading saved model {model_path}")# model.load_state_dict(torch.load(model_path))if os.path.exists(model_path): print(f"Loading saved model {model_path}") model.load_state_dict(torch.load(model_path, map_location=torch.device('cpu')))
title = "Upload an mp3 file for parkinsons detection! (Thai Language)"35 unmodified lines predicted_class_id = torch.argmax(logits, dim=-1).item()
return predicted_class_id# gr.Interface(# fn=predict,# inputs="file",# outputs="text",# title=title,# description=description,# ).launch()gr.Interface( fn=predict, inputs="file", outputs="text", title=title, description=description,).launch()
iface = gr.Interface(fn=predict, inputs="file", outputs="text")iface.launch()# iface = gr.Interface(fn=predict, inputs="file", outputs="text")# iface.launch()app.py+14-15