Update app.py
Browse files15 unmodified lines161718192021222324252627282935 unmodified lines6566676869707172737475767715 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 = 'model_weights2.pth'model_path = '/home/user/app/dysarthria_classifier10.pth'model.load_state_dict(torch.load(model_path, map_location=torch.device('cpu')))# if os.path.exists(model_path):# print(f"Loading saved model {model_path}")# model.load_state_dict(torch.load(model_path))title = "Upload an mp3 file for parkinsons detection! (Thai Language)"35 unmodified linespredicted_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()iface = gr.Interface(fn=predict, inputs="file", outputs="text")iface.launch()15 unmodified lines1617181920212223242526272835 unmodified lines6465666768697071727374757615 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 = 'model_weights2.pth'# 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, map_location=torch.device('cpu')))title = "Upload an mp3 file for parkinsons detection! (Thai Language)"35 unmodified linespredicted_class_id = torch.argmax(logits, dim=-1).item()return predicted_class_idgr.Interface(fn=predict,inputs="file",outputs="text",title=title,description=description,).launch()# iface = gr.Interface(fn=predict, inputs="file", outputs="text")# iface.launch()
app.py+14-15