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)
-
Link to GitHub repo: GitHub - m-moriss/Data_challenge_RAKUTEN
-
Link to the deployed app: https://m-moriss-data-challenge-rakuten-streamlit-appw-jnw49c.streamlit.app/
Thank you.