Closed c1scott closed 1 year ago
👋 Hello @c1scott, thank you for leaving an issue on Roboflow Notebooks.
If you are filing a bug report, please be as detailed as possible. This will help us more easily diagnose and resolve the problem you are facing. To learn more about contributing, check out our Contributing Guidelines.
If you require support with custom code that is not part of Roboflow Notebooks, please reach out on the Roboflow Forum or on the GitHub Discussions page associated with this repository.
Do you have more questions about Roboflow that we haven't responded to yet? Feel free to ask them on the Roboflow Discuss forum. Our developer advocates and community team actively respond to questions there.
To ask questions about Notebooks, head over to the GitHub Discussions section of this repository.
Hi @c1scott 👋🏻 Let me take a look.
@capjamesg could you take a look at this notebook? I did some initial investigation. It looks like new_image
in this line:
new_image = load_image(input_file)
It is a PyTorch tensor, but you pass it to plot_image
. plot_image
can only take Numpy arrays.
@c1scott Thank you for the report! I have filed a PR to fix the notebook.
In any case, you can use this code to show the image:
%matplotlib inline
sv.plot_image(image=cv2.imread(input_file), size=(8, 8))
This will open the image with cv2
and display it using supervision
.
This issue was fixed in PR #157 so I am closing this issue.
Search before asking
Notebook name
Dinov2-classification https://github.com/roboflow/notebooks/blob/main/notebooks/dinov2-classification.ipynb
Bug
Running input_file = "MIT-Indoor-Scene-Recognition-5/test/elevator/elevator_google_0053_jpg.rf.41487c3b9c1690a5de26ee0218452627.jpg"
new_image = load_image(input_file)
%matplotlib inline sv.plot_image(image=new_image, size=(16, 16))
with torch.no_grad(): embedding = dinov2_vits14(new_image.to(device))
i got
error Traceback (most recent call last) in <cell line: 6>()
4
5 get_ipython().run_line_magic('matplotlib', 'inline')
----> 6 sv.plot_image(image=new_image, size=(16, 16))
7
8 with torch.no_grad():
/usr/local/lib/python3.10/dist-packages/supervision/utils/notebook.py in plot_image(image, size, cmap) 33 plt.imshow(image, cmap=cmap) 34 else: ---> 35 plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB)) 36 37 plt.axis("off")
error: OpenCV(4.7.0) :-1: error: (-5:Bad argument) in function 'cvtColor'
Environment
Google Colab, GPU T4 runtime
Minimal Reproducible Example
run all the cells (authorize roboflow when prompted), when you get to the last runnable cell
input_file = "MIT-Indoor-Scene-Recognition-5/test/elevator/elevator_google_0053_jpg.rf.41487c3b9c1690a5de26ee0218452627.jpg"
new_image = load_image(input_file)
%matplotlib inline sv.plot_image(image=new_image, size=(16, 16))
with torch.no_grad(): embedding = dinov2_vits14(new_image.to(device))
Additional
No response
Are you willing to submit a PR?