Read in data/image files from (private) GitHub repo to use in app

I may be being obtuse here, but I have googled a lot and can’t seem to find the answer!

When opening an app locally, you can easily read in data/image files from your project folder on your computer. However, when this project is in a (private) GitHub repo, I can’t link to them internally as I would on a computer. How do I read in these data/image files when they are stored in GitHub to then use in my Streamlit Cloud app?

You can read CSV files in by simply using the URL, but this can’t be the case when the repo is private

Are you familiar with relative paths?

Consider the following folder structure

.
├── README.md
├──📁 data
│   └── image.png
└── streamlit_app.py

Then in streamlit_app.py, you can reference image.png with

import streamlit as st

st.image("./data/image.png")
2 Likes

yep that works when I do it locally but not when it’s in GitHub for some reason - I’ll try again though as may not have used the ‘.’ and see if it’s the solution - thanks!

ok this all works - thank you! :slight_smile:

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.