Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipyplot.plot_class_tabs not showing images #48

Open
segalinc opened this issue Sep 16, 2022 · 23 comments
Open

ipyplot.plot_class_tabs not showing images #48

segalinc opened this issue Sep 16, 2022 · 23 comments
Labels
bug Something isn't working jupyter

Comments

@segalinc
Copy link

Hi there,
I am using ipyplot.plot_class_tabs where the images is a pd.Series of local paths
when running the line, it doesn't show the images, only the icon of the image as it's not able to load them. the paths are already relative paths in a folder in the same directory of the notebook I am running
Images are all jpg format

Am I missing something?

I also tried using the absolute path but still same issue
Thank you for the help

@karolzak
Copy link
Owner

Hi @segalinc
Could you share a code snippet of how you're running it and preferably a sample of strings that you're using as your local paths? Also what notebooks environment you're running it in? (e.g.: Jupyter, Google Colab, etc.)

@segalinc
Copy link
Author

segalinc commented Sep 19, 2022

I am using jupyter notebook
here is the line I am calling
ipyplot.plot_class_tabs(df.path, df.feature_code, custom_texts = df.feature_value.astype(float).round(4), show_url=False, tabs_order=cols)
where df.path is a dataframe columns with strings like data/image_name.jpg and data is in the same folder as the notebook I am running

I used the same command line where df.path was an url instead and it worked fine

I also tired to have a column with the loaded pil images too but it doesn't work

force_b64=True takes forever to run and than crashes

@karolzak
Copy link
Owner

Since you mentioned it works fine when you try running ipyplot directly with string URLs I would bet that there's something funky happening when you pass your column (pandas series object) as an input. Maybe the data type is something else than string? Please try running the following lines an let me know what is the output:

print(df.path.dtype)
print(type(df.path.values[0]))
print(type(df.path[0]))

I'm trying to recreate your scenario but I'm failing to get any errors. I have the same setup as you with data folder with images located in the same dir as my notebook and I run something like this with success:
image

Please provide the following info for me to try recreate your issue:

  • Which version of ipyplot, python and pandas are you using?

@segalinc
Copy link
Author

Hi thank you again for helping. this are the info you requested

ipyplot==1.1.1
python==3.7.12
pandas==1.3.5

print(df.path.dtype) --> object
print(type(df.path.values[0])) --> <class 'str'>
print(type(df.path[0])) --> <class 'str'>

@karolzak
Copy link
Owner

Thanks for providing additional info.
I'm trying to recreate this issue but it doesn't show up in any of my test environments...

I assume simply running ipyplot.plot_images(df.path) doesn't work either?

@segalinc
Copy link
Author

No it doesn't

@karolzak
Copy link
Owner

Are there any special characters in the image paths? Such as space, &, $, %?
Could you please share few actual strings from df.path?

@segalinc
Copy link
Author

No, here are some examples
0 img/60027106_1672795_141993.jpg
1 img/60027106_1672795_100199.jpg
2 img/60027106_1672795_15606.jpg

@karolzak
Copy link
Owner

Just to be absolutely sure - if you run bellow code it displays images correctly?

images = ["img/60027106_1672795_141993.jpg", "img/60027106_1672795_100199.jpg", "img/60027106_1672795_15606.jpg"]
ipyplot.plot_images(images)

@segalinc
Copy link
Author

no, that doesn't work either

@karolzak
Copy link
Owner

And img directory is located in the same directory as the .ipynb notebook file you're running your code from?
At which directory level is your jupyter server running?

@segalinc
Copy link
Author

yes it is.
it runs internally in our infrastructure. I also tried using absolute paths but same issue.
tried also reading the images in PIL and expose them directly but seems like it has issue loading them too

@karolzak
Copy link
Owner

That's very odd.. There's a known issue with not displaying images from directories outside of Jupyter server scope but I'm not convinced if that's the case here. You can check this thread to find out if it's relevant at all for your case.

And as for PIL, does this work for you?

from PIL import Image
images = ["img/60027106_1672795_141993.jpg", "img/60027106_1672795_100199.jpg", "img/60027106_1672795_15606.jpg"]
ipyplot.plot_images([Image.open(path) for path in images])

@segalinc
Copy link
Author

that's exactly what I tried and it doesn't work.
I also already checked that issue before opening this one
Using force_b64 takes forever to run and than it doesn't even show anything afterall, very odd

@karolzak
Copy link
Owner

What's the error message when you try to open images with PIL?

@segalinc
Copy link
Author

the is no error message at all,
when I run the cell, it seems running then the kernel look like had completed the execution but the cell still shows the * as it is still working on it and no output, same with the path and force_b64

@karolzak
Copy link
Owner

That's super weird. As much as I'd like to help you, I'm afraid I'm out of ideas at this point..

@segalinc
Copy link
Author

I appreciated you bared with me so far. I might ask some of my peers if they have any issue as well using the tool
should we leave this open ?

@karolzak
Copy link
Owner

Yes, let's leave this issue open for now, thanks.
If you will get to the bottom of this at any point, please loop back and drop a msg here for others.
Good luck!

@karolzak karolzak added bug Something isn't working jupyter labels Sep 20, 2022
@segalinc
Copy link
Author

segalinc commented Sep 20, 2022

it seems that even passing the numpy version of the images doesn't work as I saw you can also pass arrays
I can open and show the images in the notebook with Image.open(local_path) though so this is a bit weird

@karolzak
Copy link
Owner

Wait, Image.open() works for you but when you do this: ipyplot.plot_images([Image.open(local_path)]) it doesn't work? Is that correct?
That is extremely weird and I have zero explanation for such behavior

@segalinc
Copy link
Author

ipyplot.plot_images([Image.open(local_path)]) this works
this works too ipyplot.plot_images([Image.open(i) for i in df.path.iloc[:10]])
all the others, list of path, df column with paths, df columns with loaded images don't work, I also see that bc of the use of Image the RAM goes up quite a bit like is loading all the images in

@GonyRosenman
Copy link

i have the same issue, when i try to load a list of strings, i get empty image symbols.
when i load the images and insert a list of images to the function - it works fine.
the problem is that i have many images and i wanted to leverage on the random selection of images from max_imgs_per_tab, loading all the images results in ram overload

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working jupyter
Projects
None yet
Development

No branches or pull requests

3 participants