st.image() 使用方式
相關使用方式請參考Streamlit官方網站
streamlit website: link.
st.image(image, caption=None, width=None, use_column_width=None, clamp=False, channels="RGB", output_format="auto")
在image這個參數的圖供上,因個人是直接使用Streamlit提供的Website相關設定,並未使用網站或github來做測試。最近在使用st.image()顯示圖片時,發現
若圖片沒放在local目錄的下,直接提供絕對路徑,會無法讀取到圖片,必須提供相對路徑。
例:
主程式是放在
D:\\test\\streamlit\\main\\abc.py
若以:
st.image('D:\\test\\streamlit\\pic\\abc.png')
會出現空的圖, 因為st.image()找不到圖片。
須以
st.image('../pic/abc.png')
才可以顯示想要的圖片
目前只找到這樣的解決方式,若有更好的方式,還請提供一起進步,謝謝!