backscrub
backscrub copied to clipboard
model could not be loaded
I got everything build and installed , but get an error message that the models/segm_full_v679.tflite could not be opened.
Any idea?
me@Darkvik:/usr/local/bin$ v4l2-ctl --list-devices v4l2loopback (platform:v4l2loopback-002): /dev/video2
Integrated Camera: Integrated C (usb-0000:00:14.0-8): /dev/video0 /dev/video1
me@Darkvik:/usr/local/bin$ backscrub -d -d -c /dev/video0 -v /dev/video2 backscrub version heads/main-0-g9b22962 (c) 2021 by [email protected] & contributors https://github.com/floe/backscrub debug: 2 ccam: /dev/video0 vcam: /dev/video2 width: 640 height: 480 flip_h: no flip_v: no threads:2 back: (none) model: models/segm_full_v679.tflite
vid_format->type = 2 vid_format->fmt.pix.width = 640 vid_format->fmt.pix.height = 480 vid_format->fmt.pix.pixelformat = 1448695129 vid_format->fmt.pix.sizeimage = 614400 vid_format->fmt.pix.field = 1 vid_format->fmt.pix.bytesperline= 1280 vid_format->fmt.pix.colorspace = 8
ERROR: Could not open 'models/segm_full_v679.tflite'. error: unable to load model from file: 'models/segm_full_v679.tflite'. Error: Could not create mask context
me@Darkvik:/usr/local/bin$ ls -l /usr/local/share/backscrub/models/segm_full_v679.tflite -rw-r--r-- 1 root root 407248 aug 20 14:34 /usr/local/share/backscrub/models/segm_full_v679.tflite
Mmh, try giving the full path to backscrub (... -m /usr/local/share/backscrub/models/segm_full_v679.tflite).
Maybe we should try to put our models as resources to /usr/share/backscrub/models following the FHS … People could still override that path by giving a full path name, but paths without a / could be taken to reference that resource directory.
Given that a cmake make install will put everything in CMAKE_INSTALL_PREFIX (typically /usr/local), and this should 'just work' as the OP expected (rule of least surprise), I think this comes down to a search order for models (or backgrounds?):
- Check for a local file with the exact provided path (current behaviour), if not found:
- Look under
CMAKE_INSTALL_PREFIX(compiled in) by appendingshare/backscrub/models/<provided path>). - Deduce binary location at runtime, and look relative to that (resolve
$BIN_FOLDER/../share/backscrub/models/<provided path>)
Finally, we might choose to search XDG standard locations (https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) including user directories (so personal models go in eg: ~/.local/share/backscrub/models) ahead of defaults.
ACK, with the small note that this search apart from step 1 is only done for paths without a / in them.
OK, first cut of this (built atop the live-backgrounds branch for now) is in my tree here: https://github.com/phlash/backscrub/tree/path-resolver. Take a look at resolve_path just above main.
I chose to resolve both models and backgrounds, although there is no installer support for backgrounds as yet. The configuration dump now shows resolved paths (so the poor user has a clue!) We may also want to write out test paths at debug level.
If you're running it from the build directory (following the setup instructions from the readme), I recommend simply creating a symlink to the models directory:
ln -s ../models ./models