Error "FileNotFoundError" while the file exists

Hello,

I’m trying to deploy my first streamlit app to present a datascience project.
i’m new in using it.
My streamlit app works fine when I run it on the local way.

The problem is for the “Exploration des données” section.
Normally, some random image have to appears among the category selected.

But in the error message, it seems that streamlit is looking for an image name like “image_imageid.0_product_productid.0.webp” but the right image file name is like image_imageid._product_productid.webp".

the image “image_1263597046_product_1263597046.webp” exist in the “img_train” librairy.
Working on it for days and can’t understand why this “0” appears.

The problem seems to come from this line code. But I use it for others thing in the app and it works.

filename = f"img_train/image_{row.imageid}_product_{row.imageid}.webp"
                image = Image.open(filename)

Here my code

global code to select ramdom image according the category of images

tabs = st.tabs(list(categories.prdlabelcode.array))

    nb_sample = 3
    for i in range(0, len(categories)):
        with tabs[i]:
            st.markdown(f"<p><strong>Exemples d'annonces de la catégorie {categories.iloc[i].prdlabelcode}</strong></p>", unsafe_allow_html=True)
            category = categories.iloc[i].prdtypecode
            sample = X[y_train.prdtypecode == category].sample(nb_sample)
            cols = st.columns([1]*nb_sample)
            index=0
            for indice, row in sample.iterrows():
            
                filename = f"img_train/image_{row.imageid}_product_{row.imageid}.webp"
                image = Image.open(filename)
                cols[index].image(image, use_column_width=True)
                cols[index].write(f'<p class="titre_annonce">{row.designation[:50]}</p>', unsafe_allow_html=True)
                if str(row.description) != "nan":
                    cols[index].write(row.description[:300])
                index += 1
            category_image = f'categories-{"{:02d}".format(i)}n.webp'
            st.markdown("<p><strong>Nuage de mot et fréquence des mots de la catégorie</strong></p>", unsafe_allow_html=True)    
            st.write("""Pour avoir une idée plus précise du contenu du texte des annonces par catégorie, **nous avons réalisé des nuages de mots et des histogrammes avec les mots les plus fréquents par catégorie.**
            """)
            st.image(category_image)

Thank you.

Because row.imageid is a float and that is how floats are converted to string by default.

>>> f"{float(1263597046)}"
'1263597046.0'

You can simply replace {row.imageid} with {int(row.imageid)}