Hi @jimlou
https://course.fast.ai/setup/colab
script doesn’t install OpenCV4.
Here’s what worked for me:
In your python notebook where you setup runtime environment (git clone & mv swift folder to /content), also execute:
!/bin/bash SwiftCV/install/install_cv4.sh
This will compile and install OpenCV4. This is not fast and will take time.
Faster alternative is to download pre-compiled OpenCV4:
!curl -sL https://github.com/vvmnnnkv/opencv-colab/raw/master/opencv4.tar.gz | tar zxf - -C / && ldconfig /opt/opencv-4.1.0/lib/ && ln -s /opt/opencv-4.1.0/lib/pkgconfig/opencv4.pc /usr/lib/pkgconfig/opencv4.pc
After that, open or restart (not reset!) Swift notebook and it should be able to %install
SwiftCV.
I guess you know that Python & Swift runtimes type should be same (CPU/GPU) otherwise you’ll be using different VM’s and file changes from Python runtime won’t affect Swift runtime.
In Swift notebook, if all packages in %install
cell compile but there’s import error in the end, restart (not reset :)) runtime and try running it again - it will skip build step as it’s already done and will import the final package just fine (this is probably swift-jupyter bug).
Sorry, I was wrong, @jeremy already made the fix Just installing opencv4 is enough for both opencv notebooks to work!
I think https://course.fast.ai/setup/colab
could be improved to download opencv4 binaries pre-compiled for colab (compiling from source each time would be annoying). But I couldn’t find that colab
script on github to make PR. @jeremy if you think this can be useful, please put colab
script somewhere to update.
There’re lots of timings in those notebooks, you could try substituting swiftcv with your library and compare, it would be interesting!