roboflow / supervision

We write your reusable computer vision tools. 💜
https://supervision.roboflow.com
MIT License
22.82k stars 1.71k forks source link

Locale breaking "!" in zero-shot-object-detection-with-grounding-dino.ipynb #57

Closed vsiegel closed 1 year ago

vsiegel commented 1 year ago

Search before asking

Bug

As of 2023-04-06, there is a somewhat obscure problem in

https://github.com/roboflow-ai/notebooks/blob/main/notebooks/zero-shot-object-detection-with-grounding-dino.ipynb

If you go back to load new images after running the demo, you get a locale related exception. System calls require an UTF-8 locale, and it is changed to something else on the way, I do not know where.

The locale changes from UTF-8 at some point, I think after running the demo. After this, calls to the system do not longer work. they fail like this:

!wget -q https://media.roboflow.com/notebooks/examples/dog.jpeg

NotImplementedError                       Traceback (most recent call last)

[<ipython-input-117-bbf546bacccd>](https://localhost:8080/#) in <cell line: 1>()
----> 1 get_ipython().system('wget -q https://media.roboflow.com/notebooks/examples/dog.jpeg')

2 frames

[/usr/local/lib/python3.9/dist-packages/google/colab/_system_commands.py](https://localhost:8080/#) in _run_command(cmd, clear_streamed_output)
    165   locale_encoding = locale.getpreferredencoding()
    166   if locale_encoding != _ENCODING:
--> 167     raise NotImplementedError(
    168         'A UTF-8 locale is required. Got {}'.format(locale_encoding)
    169     )

NotImplementedError: A UTF-8 locale is required. Got ANSI_X3.4-1968

So "!wget ..." does not work. My workaround was replacing "!": python: # Run the command with a specific encoding (UTF-8) def shell(command): print(subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, text=True, encoding="UTF-8"))

After running that in a new cell, this works: %cd {HOME}/data shell("wget ...") works.

I think the problem has no effect when running the notebook cells in order, but it does when goung back to load more example images with wget.

Environment

Colab

Minimal Reproducible Example

Run the notebook up to the demo, then go back to the cell with wget and try to load more example images.

!wget -q https://media.roboflow.com/notebooks/examples/dog.jpeg

NotImplementedError                       Traceback (most recent call last)

[<ipython-input-117-bbf546bacccd>](https://localhost:8080/#) in <cell line: 1>()
----> 1 get_ipython().system('wget -q https://media.roboflow.com/notebooks/examples/dog.jpeg')

2 frames

[/usr/local/lib/python3.9/dist-packages/google/colab/_system_commands.py](https://localhost:8080/#) in _run_command(cmd, clear_streamed_output)
    165   locale_encoding = locale.getpreferredencoding()
    166   if locale_encoding != _ENCODING:
--> 167     raise NotImplementedError(
    168         'A UTF-8 locale is required. Got {}'.format(locale_encoding)
    169     )

NotImplementedError: A UTF-8 locale is required. Got ANSI_X3.4-1968

Additional

No response

Are you willing to submit a PR?

github-actions[bot] commented 1 year ago

Hello there, thank you for opening an Issue ! 🙏🏻 The team was notified and they will get back to you asap.

SkalskiP commented 1 year ago

Hi, @vsiegel 👋🏻! Do you think that error originates in the supervision package?

SkalskiP commented 1 year ago

Hi, @vsiegel do you still experience that problem?

SkalskiP commented 1 year ago

I think that issue is not related to supervision but to Grounding DINO.