Open silvio-barbotto opened 1 year ago
@silvio-barbotto @erdogant Did you find a solution to the problem? I am also stuck as well.
pathnames = cl.import_data("/content/drive/MyDrive/Colab Notebooks/Cassava/data/test/cbsd")
img = cl.imread(X[0], dim=(128,128), colorscale=1, flatten=False)
This the error I get
KeyError Traceback (most recent call last)
KeyError: 0
Thanks for notifying! I created a few fixes and the examples work on my machine. Can you check whether this also works for you? This example works on my machine.
update to the latest version:
pip install -U clustimage
Dear @erdogant, I have tried have it and the error is still the same. I have included an example of the code I am using below and the output I get from running pathnames. The output is the same when running from Colab or on my PC.
!pip install -U clustimage // import numpy as np import os import matplotlib.pyplot as plt from clustimage import Clustimage
cl = Clustimage()
pathnames = cl.import_data("D:\Python\DSA\DSA_2023\Computer Vision\cassava_leaves_dsa_512\test\cbsd")
img = cl.imread(pathnames[0], dim=(128,128), colorscale=1, flatten=False)
KeyError Traceback (most recent call last)
KeyError: 0 clustmage.docx
Why is there an attached docx?
The underneath works. I can not check it without having the images. What kind of images are you using?
import numpy as np
import os
import matplotlib.pyplot as plt
from clustimage import Clustimage
#Initialise
cl = Clustimage()
#Load example dataset
# pathnames = cl.import_data("D:\Python\DSA\DSA_2023\Computer Vision\cassava_leaves_dsa_512\test\cbsd")
pathnames = cl.import_example('flowers')
img = cl.imread(pathnames[0], dim=(128,128), colorscale=1, flatten=False)
Hi @erdogant, The word document was so that you can see the output from running pathnames using the path to the directory with the images as shown below. The images I am using are jpg images and the path included leads to a folder with all the images inside.
please copy paste the output from the docx here. Use formatting for pathnames:
r”d:\python\etc
or
d://python//etc
@erdogant I am using windows 11 and this is the output when I load
pathnames = cl.import_data("D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd")
and run
pathnames
{'img': array([[125, 161, 144, ..., 114, 101, 125], [ 66, 92, 107, ..., 51, 131, 105], [115, 129, 131, ..., 60, 85, 83], ..., [ 91, 108, 129, ..., 58, 77, 98], [ 31, 24, 31, ..., 183, 194, 197], [124, 160, 136, ..., 98, 122, 144]], dtype=uint8), 'feat': None, 'xycoord': None, 'pathnames': array(['D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1616821573094.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1616821669327.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1616833319262.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1616833345793.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1616834021933.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1616834460941.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1616854309992.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617091703959.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617091921011.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617092466328.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617092862352.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617093193877.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617093398717.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617093492751.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617095290124.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617095301237.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617095341121.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617095407410.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617095442473.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617095444792.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617095587454.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617095670929.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617095752573.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617097100289.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617097441032.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617097495870.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617098592790.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617098799092.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617099222286.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617099373115.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617099615929.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617099943864.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617103454176.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617103455280.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617103771254.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617103812795.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617103815345.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617103843642.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617103910154.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617104212307.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617104240376.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617104407574.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617104528003.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617104564325.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617104566099.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617104585951.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617104914370.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617104923875.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617104992961.jpg', 'D://Python//DSA//DSA_2023//Computer Vision//cassava_leaves_dsa_512//test//cbsd\1617105550338.jpg'], dtype='<U96'), 'labels': None, 'url': None, 'filenames': array(['1616821573094.jpg', '1616821669327.jpg', '1616833319262.jpg', '1616833345793.jpg', '1616834021933.jpg', '1616834460941.jpg', '1616854309992.jpg', '1617091703959.jpg', '1617091921011.jpg', '1617092466328.jpg', '1617092862352.jpg', '1617093193877.jpg', '1617093398717.jpg', '1617093492751.jpg', '1617095290124.jpg', '1617095301237.jpg', '1617095341121.jpg', '1617095407410.jpg', '1617095442473.jpg', '1617095444792.jpg', '1617095587454.jpg', '1617095670929.jpg', '1617095752573.jpg', '1617097100289.jpg', '1617097441032.jpg', '1617097495870.jpg', '1617098592790.jpg', '1617098799092.jpg', '1617099222286.jpg', '1617099373115.jpg', '1617099615929.jpg', '1617099943864.jpg', '1617103454176.jpg', '1617103455280.jpg', '1617103771254.jpg', '1617103812795.jpg', '1617103815345.jpg', '1617103843642.jpg', '1617103910154.jpg', '1617104212307.jpg', '1617104240376.jpg', '1617104407574.jpg', '1617104528003.jpg', '1617104564325.jpg', '1617104566099.jpg', '1617104585951.jpg', '1617104914370.jpg', '1617104923875.jpg', '1617104992961.jpg', '1617105550338.jpg'], dtype='<U17')}
Hi! Thank you for your work! I really love to use your library but I'm stuck to the beginnig, I don't want bother you but can you give me some advise? I'm trying to cluster jpg images from a Google Drive folder, I've read the documentations and the blog but I can't make it right
Here is the snippet from Coolab
` !pip install -U clustimage
from google.colab import drive from clustimage import Clustimage
drive.mount('/content/drive', force_remount=True)
cl = Clustimage(method='pca')
X = cl.import_data('/content/drive/MyDrive/images/immagini/1')
Xfeat = cl.extract_feat(X) ... `
It import the data but throws on feat extraction: ValueError: zero-size array to reduction operation minimum which has no identity
Best regards, Silvio