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

f = st.file_uploader("Upload file")
tfile = tempfile.NamedTemporaryFile(delete=False)
tfile.write(f.read())
vf = cv.VideoCapture(tfile.name)

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

uploaded_filesCOPY = copy.copy( uploaded_files )

- 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

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

Adding a description in the loads

torch.load('mobilenet_v2.pth.tar',map_location=torch.device('cpu'))

Removing the cdu() part at end of e.g. variables

Variable(torch.zeros(2*self.lstm_layers, batch_size, self.lstm_hidden).cuda()
# to     
Variable(torch.zeros(2*self.lstm_layers, batch_size, self.lstm_hidden)