Unable to run lesson3-head-pose.ipynb, OSerror in data bunch .label_from_func(get_ctr)

I tried to run head-pose notebook https://github.com/fastai/course-v3/blob/master/nbs/dl1/lesson3-head-pose.ipynb but I’m getting OS error:
OSError: /home/jupyter/.fastai/data/biwi_head_posepose.txt not found
upon running data = (PointsItemList.from_folder(path) .split_by_valid_func(lambda o: o.parent.name=='13') .label_from_func(get_ctr) .transform(get_transforms(), tfm_y=True, size=(120,160)) .databunch().normalize(imagenet_stats) )
The error is in line .label_from_func(get_ctr) & traces back to ctr = np.genfromtxt(img2txt_name(f), skip_header=3). I read this https://forums.fast.ai/t/issue-creating-a-dataset-in-head-pose-notebook/30718 thread also but no help.

I just ran into this problem last night. In short:

  • update fastai,
  • update the course notebook,
  • delete all .obj files in the headpose data directory after untaring them,

and you should be good to go.


I think I spent about 4 hours trying to debug this at first, I tried to document that as a debugging notebook here.

First I had to find out what data was creating .../data/biwi_head_posepose.txt. ← img2text_name cuts off the last 7 characters of a path and adds 'pose.txt' onto the end. It’s expecting a ..._rgb.jpg within a directory. You can check that running img2text_name on the Path: .../data/biwi_head_pose/07.obj' will return the exact line that triggered your OSError.

Unfortunately, either my fastai wasn’t updated (I updated fastai, but I don’t think I updated pytorch, the method is now:

conda install -c pytorch -c fastai fastai

I also editted either or both img2text_name and get_ctr before discovering the actual cause of the error, in trying to narrow down the exact point where it occurred. This resulted in leap-frogging between one error and another, diving into the docs for PointsImageList and the datablock API in general.

I wondered if the notebook code wasn’t out-of-date with the rest of the library, so I tried to apply the datablock construction from the examples, from an earlier classifier project, and from Hiromis’ notes on the lesson.

An issue with debugging is it’s difficult not to get tangled up as you’re uncovering and playing with multiple new moving pieces as you’re moving toward a changing and vaguely-defined goal. So I packed it up for the night, gave it a fresh start by ensuring everything was updated and making another copy of the original notebook … and it all worked.

Looks like it was just those .obj files – and on second thought, I’m not even sure they’d cause an error with a properly updated library :wink: .


Versions: fastai 1.0.39; pytorch 1.0.0