[Bug]: small-object-detection-with-sahi notebook fails to run in Colab

Open
#2,938 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
56/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
google-cloud, jupyter-notebook, python

Research direction

Start with docs/notebooks/small-object-detection-with-sahi.ipynb and review the install, image download, tiling, API key, restart, and NMS cells against the reported Colab environment. The issue gives concrete failures and suggested fixes, though some version behavior is unconfirmed. Re-run the notebook in Colab and confirm it completes with valid before-and-after images and the corrected instructions.

Written by the indexing model from the issue text.

Description

bug
Search before asking
  • I have searched the issues and discussions and found no similar bug report.
Bug

While fixing the tile-size printout in this notebook (PR #2937), I ran it end to end in Google
Colab and hit several problems that stop it from running as written. I have not changed any of
them in the PR, so the maintainers can decide how to handle them.

Notebook: docs/notebooks/small-object-detection-with-sahi.ipynb
Environment: Google Colab (Python 3.13), supervision 0.30.9

The notebook's install asks for inference and supervision with no version number. In Colab
today, pip looks at supervision 0.31.6 first, then installs 0.30.9. I assume this is a version
limit from inference, but I have not confirmed it.

1. Install cell leaves Colab unable to restart

The install cell also installs jupyter_compare_view. After "Restart session", Colab reported
"restart failed" and the runtime log ended with:

AttributeError: type object 'TermColors' has no attribute 'Green'

The traceback is in google/colab/_shell_customizations.py. The install log shows
jupyter_compare_view pulling in ipython>=9.15.0 and ipykernel>=7.3.0. I believe that
causes the crash, but this is inferred from the log, not confirmed on a clean runtime.
Removing the package and its import gets past the install and restart. The two cells that call
compare(...) then need another way to show the before and after images.

2. Sample image download fails

The notebook requests a 2560px-wide Wikimedia thumbnail. Wikimedia now returns:

ERROR 400: Use thumbnail sizes listed on https://w.wiki/GHai

With the original file URL and a -U "Mozilla/5.0" user agent, the first retry returned
429 Too Many Requests and a later one succeeded.

3. tile_image helper raises TypeError on supervision 0.30.9

The notebook's tile_image helper calls
sv.InferenceSlicer._generate_offset(..., overlap_ratio_wh=None, ...). On 0.30.9 this fails with:

TypeError: InferenceSlicer._generate_offset() got an unexpected keyword argument 'overlap_ratio_wh'

Removing that argument fixes it. On the develop branch (0.32.0.dev), inference_slicer.py has
no overlap_ratio_wh anywhere. The later cells that call
sv.InferenceSlicer(..., overlap_ratio_wh=None, ...) pass the same argument. I have not run
those cells, so I can't say whether they fail on 0.30.9.

4. API key instruction is ambiguous

The notebook says to retrieve your API key. Roboflow's page lists a Publishable key and a
Private key. Using the Publishable key returns 403 Forbidden, and the error does not say which
key is needed. The notebook should say to use the Private key and store it in Colab Secrets.

5. No restart note, and a wording mismatch

After the install cell, Colab prints:

WARNING: The following packages were previously imported in this runtime:
  [PIL,_distutils_hack,numpy,packaging,psutil,pydevd_plugins]
You must restart the runtime in order to use newly installed versions.

The notebook does not tell the reader to restart. Also, the text above the NMS cell says the
overlap ratio is (0.2, 0.2), but the code uses (0.15, 0.15).

Happy to open a follow-up PR for any of these if that helps.

Environment
  • Supervision:
  • Python:
  • OS:
Minimal Reproducible Example

No response

Are you willing to submit a PR?
  • Yes I'd like to help by submitting a PR!
Dominant language
Python
Stars
51.6k
Forks
5k
Avg merge
1d 17h
Merged PRs (30d)
191

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from roboflow/supervision

All issues in roboflow/supervision

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.