Modifications to code for separating swing video
- Imported files are not saved to a location
This means can’t pass ‘path’ when creating the Dataset. So that line is removed from the __init__
In theory the video could then be loaded with cap = cv2.VideoCapture(self)
but this doesn’t work as openCV requires a file. So a get around for this is create a temp file https://discuss.streamlit.io/t/how-to-access-uploaded-video-in-streamlit-by-open-cv/5831/4
= st.file_uploader("Upload file")
f = tempfile.NamedTemporaryFile(delete=False)
tfile
tfile.write(f.read())= cv.VideoCapture(tfile.name) vf
For the same reason the image files are not saved as a file
- Video load issue
If the video is loaded a second time ret, img = cv2.VideoCapture
there are problems receieving the video i.e. ret=False
.
A get around used was to copy the imported file
= copy.copy( uploaded_files ) uploaded_filesCOPY
- Using on a CPU instead of a GPU
The code needed modifying slightly to allow it to work using a CPU. Although it does have the following line, a few more changes were needed
= torch.device('cuda' if torch.cuda.is_available() else 'cpu') device
Adding a description in the loads
'mobilenet_v2.pth.tar',map_location=torch.device('cpu')) torch.load(
Removing the cdu() part at end of e.g. variables
2*self.lstm_layers, batch_size, self.lstm_hidden).cuda()
Variable(torch.zeros(# to
2*self.lstm_layers, batch_size, self.lstm_hidden) Variable(torch.zeros(