Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError when trying to run inference #630

Closed
yilewang opened this issue Jan 15, 2022 · 2 comments
Closed

KeyError when trying to run inference #630

yilewang opened this issue Jan 15, 2022 · 2 comments

Comments

@yilewang
Copy link

Hi, I had an error message today when I tried to do inference in all frames of my video.

The error message part is:

Traceback (most recent call last):
  File "C:\Users\Wayne\miniconda3\envs\sleap\Scripts\sleap-track-script.py", line 33, in <module>
    sys.exit(load_entry_point('sleap==1.1.5', 'console_scripts', 'sleap-track')())
  File "C:\Users\Wayne\miniconda3\envs\sleap\lib\site-packages\sleap\nn\inference.py", line 3041, in main
    labels_pr = predictor.predict(provider)
  File "C:\Users\Wayne\miniconda3\envs\sleap\lib\site-packages\sleap\nn\inference.py", line 390, in predict
    self._make_labeled_frames_from_generator(generator, data)
  File "C:\Users\Wayne\miniconda3\envs\sleap\lib\site-packages\sleap\nn\inference.py", line 1207, in _make_labeled_frames_from_generator
    for ex in generator:
  File "C:\Users\Wayne\miniconda3\envs\sleap\lib\site-packages\sleap\nn\inference.py", line 319, in _predict_generator
    for ex in self.pipeline.make_dataset():
  File "C:\Users\Wayne\miniconda3\envs\sleap\lib\site-packages\sleap\nn\data\pipelines.py", line 277, in make_dataset
    ds = self.providers[0].make_dataset()
  File "C:\Users\Wayne\miniconda3\envs\sleap\lib\site-packages\sleap\nn\data\providers.py", line 388, in make_dataset
    self.video.get_frame(self.video.last_frame_idx)
  File "C:\Users\Wayne\miniconda3\envs\sleap\lib\site-packages\sleap\io\video.py", line 1022, in get_frame
    return self.backend.get_frame(idx)
  File "C:\Users\Wayne\miniconda3\envs\sleap\lib\site-packages\sleap\io\video.py", line 478, in get_frame
    raise KeyError(f"Unable to load frame {idx} from {self}.")
KeyError: "Unable to load frame 5042 from MediaVideo(filename='C:/Users/Wayne/Downloads/rat/day_1/1-0.mp4', grayscale=False, bgr=True, dataset='', input_format='channels_last')."

It looks like the error is coming from the get_frame function in video.py... My video format is .mp4, and the total frame is 5043. I have no problem getting frames info in my labeling stage... However, I don't know it kept giving me errors when I tried to do inference. Any idea? Thank you so much!!

@talmo
Copy link
Collaborator

talmo commented Jan 15, 2022

Hi @yilewang,

Have you tried reencoding your video and checking that you get the same error?

Cheers,

Talmo

@yilewang
Copy link
Author

Hi Talmo! Thanks so much for your reply! It is solved now! I guess I will close this issue with this comment~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants