B-SOiD V2.0 web browser first running step
Error:IndexError: list index out of range
IndexError: list index out of range
Traceback:
File "/home/user/anaconda3/envs/bsoid_v2/lib/python3.8/site-packages/streamlit/script_runner.py", line 332, in _run_script
exec(code, module.__dict__)
File "/home/user/B-SOID/bsoid_app.py", line 42, in <module>
processor.compile_data()
File "/home/user/B-SOID/bsoid_app/data_preprocess.py", line 88, in compile_data
file0_df = pd.read_csv(data_files[0], low_memory=False)
Problem Analysis:
At first I found the answer in the community: (taken from the community answer)
"This is a bug/misfeature that we worked on correcting in later versions of Streamlit since it was confusing to people. If you want to use Streamlit 0.70 per your requirements.txt file, then add the line of code I posted above.
However, if you upgrade Streamlit to the newest version (0.73.1 as of this post), your app will work as-is (I tested this scenario locally as well)."
The answer in the community was from 2021, so I just updated it to the latest (didn't find version 0.73.1) and then a new problem appeared
"PackageNotInstalledError: Package is not installed in prefix."
So I searched for some more ANSWERS, except for the ones where the COMMENTS all say STILL ERROR, and found a way to update conda in the base environment and download a new version of streamlit using pip: (taken from the community answers)
1)I met the same problem in my window1 10. pls change the env to base, because the package "conda" only can be updated in base. regards
2)When a package is installed via pip in a conda env, and updated via conda, it results in the same error message shown. In this case, use
pip install package_name --upgrade
This solved my problem.
I didn't bother updating conda as it had already been updated, so I downloaded it directly using pip
Then streamlit downloaded the latest version 1.71.0 and uninstalled the original 0.71.0.
However, the method of updating the latest version didn't work, but even the import error was directly reported, and the caching from streamlit could not be successfully imported, so after uninstalling this version and installing the original version, the command to import the streamlit function still reported an error
ImportError: cannot import name 'caching' from 'streamlit'
(/home/user/anaconda3/envs/bsoid_v2/lib/python3.8/site-packages/streamlit/__init__.py)
So I deleted the environment and reinstalled it with yaml, and went back to the beginning.
Then we ruled out the package problem and went back to the code. The error I showed here was out of index for data_files[0], which means it was empty, i.e. pandas didn't read the csv file at all.
In the end it turned out that it wasn't a package conflict issue, it wasn't a version issue, there was nothing wrong with the code or the environment, what was wrong was the step-by-step video placed on the official website.
Problem Analysis:
In the official website, the images show that the B-SOID Project folder is used to create session 1, session 2 and output folders, but in the demonstration video for the generate video snippets step, he puts the created session 1 and session 2 in the 041919 This is equivalent to having my video.mp4 and .csv files in a subfolder of 041919. And in the step "Select the pose estimate root directory containing 1 or more xxx.csv containing sub-directories". folder, i.e. the folder above the folder where video.mp4 and .csv are located.
So, having followed the video instructions down the line, then you just need to select to the subfolder where the video.mp4 and .csv are located.
Error 2:Error: ffprobe error (see stderr output for detail)
Error: ffprobe error (see stderr output for detail)
Traceback:
File "/home/user/anaconda3/envs/bsoid_v2/lib/python3.8/site-packages/streamlit/script_runner.py", line 332, in _run_script
exec(code, module.__dict__)
File "/home/user/B-SOID/bsoid_app.py", line 71, in <module>
creator.main()
File "/home/user/B-SOID/bsoid_app/video_creator.py", line 268, in main
self.setup()
File "/home/user/B-SOID/bsoid_app/video_creator.py", line 115, in setup
probe = ffmpeg.probe(os.path.join(self.vid_dir, self.vid_file))
File "/home/user/anaconda3/envs/bsoid_v2/lib/python3.8/site-packages/ffmpeg/_probe.py", line 23, in probe
raise Error('ffprobe', out, err)
Error Location:
Generate video clips for interpretation before cutting frames:
Problem Analysis:
There are two reasons for this error:
Problem 1:
One is not selecting the correct required file (as shown above), note that the first column selects your test csv or other format, and the second column selects the .mp4/.avi file itself.
Problem 2:
If you're using Ubuntu and you're following the correct format exactly, then the problem is the ffmpeg package.
First debug from the code, and at the end there are only three lines of code left.
import ffmpeg
import os
vid_dir = '/home/user/B-SOID/B-SOiD/Session 1'
vid_file = 'trial1_video.mp4'
file_path = os.path.join(vid_dir, vid_file)
ffmpeg.probe(file_path)
Then there is only one possible reason for the problem with the ffmpeg package, i.e. the version of the package
I found the author's answer to the question about ffmpeg in the community, namely that the question is called with both ffmpeg and ffmpeg-python under the statement "import ffmpeg", but it is ffmpeg-python that needs to be called.
Solutions:
Uninstall ffmpeg
pip uninstall ffmpeg
Installing ffmpeg-python
pip install ffmpeg-python
Error 3:IndexError: list index out of range
Error code:
IndexError: list index out of range
Traceback:
File "/home/user/anaconda3/envs/bsoid_v2/lib/python3.8/site-packages/streamlit/script_runner.py", line 332, in _run_script
exec(code, module.__dict__)
File "/home/user/B-SOID/bsoid_app.py", line 71, in <module>
creator.main()
File "/home/user/B-SOID/bsoid_app/video_creator.py", line 273, in main
self.create_videos()
File "/home/user/B-SOID/bsoid_app/video_creator.py", line 214, in create_videos
create_labeled_vid(fs_labels[0], int(self.min_frames), int(self.number_examples), int(self.out_fps),
File "/home/user/B-SOID/bsoid_app/bsoid_utilities/videoprocessing.py", line 28, in create_labeled_vid
frame = cv2.imread(os.path.join(frame_dir, images[0]))
Error location: End of extract frames, after predict labels
Solutions:
Select 'No' to cut and store frames, then 'Yes' for image processing
Error 4: Cutting video keeps on "creating gifts from mp4s" for a long time (picture below)
Solutions:
If you are using an .mp4 file, find the .py file with fourcc on it and find the line for fourcc (as shown below)
# fourcc = cv2.VideoWriter_fourcc('H', '2', '6', '4')
fourcc = cv2.VideoWriter_fourcc(*'avc1')
frame = cv2.imread(os.path.join(frame_dir, images[0]))
Just change the contents of the brackets (*'avc1') to (*'mp4v')!