Actually I’m not deploying to cloud, Just trying it in the local machine. The package Torch is already installed in the system. But when I run streamlit, it raises the module not found error. I even included a requirements.txt file with my directory.
import streamlit as st
import glob
import pandas as pd
from utils.AudioUtils import AudioUtils
from utils.build_model import CNN14_mod
import torch
aud_util = AudioUtils()
model = CNN14_mod()
model.load_state_dict(torch.load("Fold0_0.7930.pth"))
evals = pd.read_csv("eval.csv")
model.eval()
model.cuda()
Labels = ['Baby','Conversation','Doorbell','Rain','Overflow','Object Falling','Cooker']
folder_name = st.selectbox("Category",Labels)
wav_files = glob.glob(f"Test/{folder_name}/*.wav")
def pipeline(filename,folder_name,start,dur):
#read audio file to tensor using torchaudio function
audio = aud_util.read_audio(filename=filename,foldername=folder_name,offset=start,duration=dur)
audio = aud_util.rechannel(audio)
audio = aud_util.resample(audio)
audio = aud_util.pad_audio(audio)
#converted to melspectrogram
audio = aud_util.melspectro(audio)
if wav_files is not None:
filename = st.selectbox("select the audio file plz",wav_files)
e = evals[evals.foldername==folder_name]
e = e[e.filename == filename]
start,dur = e.start_time,e.duration
pre_btn = st.button("Preprocess")
The image below is the output of streamlit run of above code