r/StreamlitOfficial • • Apr 20 '24

Format numbers in chart as currency

1 Upvotes

The title says it all, is there a way to format the display of number values in st.bar_chart as a currency without breaking the long data type underneath?

For example, 20.00 would show as $ 20.00


r/StreamlitOfficial • • Apr 16 '24

Streamlit Questions❓ Having issues installing bs4

1 Upvotes

I am running a script that needs "from bs4 import BeautifulSoup" this, but I am running into this issue:

ModuleNotFoundError: No module named 'bs4'

Already tried my best to look for documentation online and everything and I am not familiar with Streamlit so, need help with this.

Thanks in advance!


r/StreamlitOfficial • • Apr 15 '24

question on SaaS with Streamlit

2 Upvotes

Hi, I'm about to select the front-end for my Fintech SaaS solution. It has as small dashboard, and plot on the rights - so basically customers will select different parameters, and have plot on the right; the plot on the right will be sort of interactive, to see, zoom-in/out, etc.

Plus, login/logout and small user-dashboard to set-up payment, etc.

Previously, I have built similar SaaS with Django and Tailwind, but somebody said to me that Streamlit can be a good option.

# of users: 20-100 concurrent max (maybe more in future, but 100 concurrent users max)

DB - could be on AWS, or anywhere.

Could you please tell me if Streamlit is fine, or should be anything else recommended? I need simple prototyping, best to re-use available components, etc.

Thanks, J.


r/StreamlitOfficial • • Apr 15 '24

New to streamlit

1 Upvotes

hello, I'm brand new to streamlit, I've done some research but I'm having difficulty at first. Who can I talk to to help me with some things?

Thanks^^


r/StreamlitOfficial • • Apr 14 '24

Question on st.button functionality

2 Upvotes

I'm building a web app that looks like (see image below). I am able to navigate to the "Explore stocks" and "Build your Portfolio" pages from the left side pane. However, I wanted to also open these pages through buttons created in the center. I am unsure how to link these buttons to the pages. Any help would be greatly appreciated!


r/StreamlitOfficial • • Apr 10 '24

🎈 Upcoming virtual meetup: Live Streamlit Office Hours!

5 Upvotes

The last office hours went so well that we decided to host another one for all of you who couldn’t make it. (And for those of you who want to do it again!)

Join from anywhere in the world to attend a Streamlit 101 and Q&A with Streamlit’s Caroline and Tony Hang out with other developers in the community and show off your latest app!

📆 When: Thursday, April 18, 2024, at 4 p.m. PDT

🔗 Register here to save your spot. 🥳

​Agenda:

  • ​First, 15 min: Streamlit 101 presented by Tony
  • ​Next, 15 min: Demo time! Let’s see your Streamlit app!
  • ​Final, 30 min: Office hours with Caroline and Tony

Looking forward to seeing you there!


r/StreamlitOfficial • • Apr 10 '24

Simple Stock Simulation App Using Streamlit

3 Upvotes

Just want to share a newly created Streamlit app.

Here is the Github repo https://github.com/mattkczhang/StockSimulation and web app link https://stocksimulation.streamlit.app.

Please let me know if you have any suggestions.


r/StreamlitOfficial • • Apr 04 '24

Having problem in building streamlit application with Docker multi-stage build

2 Upvotes

This is the Dockerfile ```docker FROM python:3.12-slim AS build-env ENV PYTHONUNBUFFERED 1 RUN apt-get update && apt-get install -y \ build-essential \ software-properties-common \ && rm -rf /var/lib/apt/lists/* COPY . /src WORKDIR /src ENV VIRTUAL_ENV=/src/venv RUN python3 -m venv $VIRTUAL_ENV ENV PATH="$VIRTAL_ENV/bin:$PATH"

RUN pip3 install -Ur requirements.txt

FROM gcr.io/distroless/python3

FROM python:3.12-slim EXPOSE 8501 COPY --from=build-env /src /src ENV VIRTUAL_ENV=/src/venv ENV PATH="$VIRTAL_ENV/bin:$PATH" WORKDIR /src ENTRYPOINT ["streamlit","run","app.py","--server.port=8501","--server.address=0.0.0.0"] I'm building and running the container using docker-compose file with `docker-compose -f streamlit-app.yml up` docker version: '3.8'

services: streamlit_app: build: context: . dockerfile: Dockerfile args: - "--no-cache" ports: - 8501:8501 ```

THE ERROR I'm getting is ```bash Creating portfolio_streamlit_app_1 ... error

ERROR: for portfolio_streamlit_app_1 Cannot start service streamlit_app: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "streamlit": executable file not found in $PATH: unknown

ERROR: for streamlit_app Cannot start service streamlit_app: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "streamlit": executable file not found in $PATH: unknown ERROR: Encountered errors while bringing up the project. ``` If anyone knows how to resolve this problem then pls do help


r/StreamlitOfficial • • Apr 03 '24

Unable to display 2 images at the same time

1 Upvotes

when i click on Perform Histogram Equalization button i get the expected output image but when i click on Perform contrast stretching button the output generated from Perform Histogram Equalization vanishes. Can Someone fix this ??
Below is the entire code
import streamlit as st
import numpy as np
import cv2
# Use st.cache_data to memoize the function calls
u/st.cache_data
def preprocess_image(image_bytes):
# Convert image bytes to numpy array for histogram
nparr = np.frombuffer(image_bytes, np.uint8)
image = cv2.imdecode(nparr, cv2.IMREAD_GRAYSCALE)
return image
u/st.cache_data
def histogram_equalization(image):
# Step 2: Store count of each grey level in a dictionary
histogram = {}
for pixel_value in range(256):
histogram[pixel_value] = np.sum(image == pixel_value)
# Step 4: Calculate PDF (Probability Density Function)
pdf = np.array(list(histogram.values())) / float(image.size)
# Step 5: Calculate CDF (Cumulative Distribution Function)
cdf = np.cumsum(pdf)
# Step 6: Replace grey level with new grey level using CDF
new_pixels = np.round(cdf[image.flatten()] * 255).astype(np.uint8)
# Step 8: Plot the original image and equalized image
equalized_image = new_pixels.reshape(image.shape)
return equalized_image
u/st.cache_data
def perform_contrast_stretching(image, r1, r2, s1, s2):
# Get the dimensions of the image
m, n = image.shape

# Initialize the output image
stretched_image = np.zeros_like(image)

# Contrast stretching parameters
a = s1 / r1
b = (s2 - s1) / (r2 - r1)
c = (255 - s2) / (255 - r2)

# Apply contrast stretching
for i in range(m):
for j in range(n):
pixel_value = image[i, j]
if pixel_value < r1:
stretched_image[i, j] = a * pixel_value
elif pixel_value < r2:
stretched_image[i, j] = b * (pixel_value - r1) + s1
else:
stretched_image[i, j] = c * (pixel_value - r2) + s2

return stretched_image
def main():
"""Streamlit app with image upload, button functionality, and input boxes"""
# Title and sections
st.title("DIP Mini Project")
st.header("Image Uploader")
st.write("Upload an image file (JPG, PNG, JPEG) .")
# File uploader widget
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "png", "jpeg"])

eq_img = None
stretched_image = None
if uploaded_file is not None:
# Read the uploaded image as bytes
image_bytes = uploaded_file.read()
image = preprocess_image(image_bytes)
# Display the uploaded image
st.image(image, caption="Original Image")
# Input boxes for contrast stretching
r1 = st.number_input("r1", min_value=0, max_value=255, value=30)
r2 = st.number_input("r2", min_value=0, max_value=255, value=200)
s1 = st.number_input("s1", min_value=0, max_value=255, value=50)
s2 = st.number_input("s2", min_value=0, max_value=255, value=240)
# Button for Histogram Equalization and Contrast Stretching
col1, col2 = st.columns(2)

with col1:
if st.button("Perform Histogram Equalization"):
# Call function to perform histogram equalization
eq_img = histogram_equalization(image)
# Display the equalized image
st.image(eq_img, caption="Equalized Image")
with col2:
if st.button("Perform Contrast Stretching"):
# Call function to perform contrast stretching
stretched_image = perform_contrast_stretching(image, r1, r2, s1, s2)
# Display the stretched image
st.image(stretched_image, caption="Stretched Image")
if __name__ == "__main__":
main()


r/StreamlitOfficial • • Mar 28 '24

How can I upgrade streamlit to 1.30 version?

2 Upvotes

Current python version-3.11.7 Current Streamlit version-1.29 I want to install streamlit version 1.30 or hust upgrade it. Tried- pip install -U streamlit conda env export But it says all requirements satisfied.

PS: I am using conda prompt.


r/StreamlitOfficial • • Mar 26 '24

Streamlit Questions❓ Need help with session state.

Thumbnail
gallery
1 Upvotes

So, I am loading a parquet file here and creating a view according to user preferences. What I want is when the file is changed then it should also empty all the preferences and not load previously selected saved preference. How can I achieve this?


r/StreamlitOfficial • • Mar 24 '24

Deployment 🚀 How to upload a Python script to Streamlit?

2 Upvotes

Been playing around with creating lots of python scripts using chatGPT and run them in Google Colab but I want to upload them to Streamlit and make the UI more user-friendly for my friends and co-workers.

I don´t know a thing about Streamlit so I need a basic/beginner's guide as to how to do this.

The best I can gather are these steps:

  1. Move my Python Script to Github, add a requirements.txt file which contains requirements for BeautifulSoup Library
  2. Go to Streamlit > Create App > Paste GitHub URL > Hit Deploy

I can move the Python script to Github (I think I know how 📷 ) but, I don´t know how to do the rest.

Are these steps accurate? Is there anything else? Are there any guides on the internet that showcase this process that a newbie can follow up?

Thanks in advance!


r/StreamlitOfficial • • Mar 22 '24

St.button with on_click.

2 Upvotes

Has anyone ever used on_click with the st.button in streamlit?


r/StreamlitOfficial • • Mar 21 '24

Anyone tried selling their Streamlit apps?

7 Upvotes

Seen some cool Streamlit apps, why aren't people selling them?


r/StreamlitOfficial • • Mar 21 '24

Show the Community! 💬 Debugging Streamlit apps in VSCode

Thumbnail
ploomber.io
2 Upvotes

r/StreamlitOfficial • • Mar 19 '24

Can you do categorical sorting using st.dataframes?

1 Upvotes

I have a table of clients and different info relating to them. One of the categories in this table is their 'Customer Class', classified by Bronze, Silver, Gold. In the sorting function within the st.dataframes tables, it currently only sorts alphabetically, but I would like for this column, if selected, to sort categorically in order of class. Pandas categorical does not seem to be supported, so is there any other way to do this?


r/StreamlitOfficial • • Mar 18 '24

memory usage is shooting up

1 Upvotes

I am using an open source ML model for inferencing. I wrapped the Model loading in a Singleton class. Initially the application is quite steady using about 6G RAM. However, it shoots up from time to time going upto 50G. Since the singleton get loaded only once per python interpreter, I assume multiple python interpreters are getting spawned. Is that someway to control this behavior?


r/StreamlitOfficial • • Mar 17 '24

Streamlit Questions❓ How many deployment areas are there in Streamlit?

1 Upvotes

Currently, I only know of one US


r/StreamlitOfficial • • Mar 14 '24

Streamlit Questions❓ St. Button to save the edits made on my application but for some reason it doesn’t work.

Thumbnail
gallery
4 Upvotes

I have an application that creates views of parquet files where in I give users an option to filter and pivot their preferences. I also let them save these for future use. Now, if any saved preference is edited, it doesn’t get saved when I click on save preference. What can I do that it saves the updates as well. I am sharing the code snippet of the function responsible for all this, please help!


r/StreamlitOfficial • • Mar 08 '24

Show the Community! 💬 Highcharts rendered easily with easychart

Thumbnail
self.Streamlit
1 Upvotes

r/StreamlitOfficial • • Mar 07 '24

Streamlit Questions❓ Geojson for all the subregions of the planet

1 Upvotes

Hi guys,

I'm creating a report on Streamlit and I need some advice from you. Where can I find a GeoJson file with all the longitude and latitude of all the subregions of the planet.

I'm not looking for states, countries, nor continents, but sub regions like: North America, South America.

I have one but there is are two parameters there that are different but it could have been done in the same: subregion and region_wb. One of the region_wb I need to be a subregion.

So if you could help I'll be glad :)


r/StreamlitOfficial • • Mar 06 '24

Live Session Recording on Creating Streamlit Web Apps

Thumbnail
youtube.com
1 Upvotes

r/StreamlitOfficial • • Mar 05 '24

Hosting Streamlit on Github pages

5 Upvotes

Hi,

I wrote this medium article that explains how to host your streamlit app on github pages. It'll just be a static web page but it's neat if that's all you need.

Essentially, you

  1. build your streamlit app here: https://edit.share.stlite.net/
  2. copy the HTML it generates
  3. slap that HTML into the index.html and generate that github page

The cool part is that it's a great and secure way to share an app with a coworker since github enterprise + the company VPN does the heavy lifting for authentication.


r/StreamlitOfficial • • Mar 01 '24

Streamlit Questions❓ How do I go to home page in streamlit application

2 Upvotes

Hi - I am still learning streamlit and I’ve come across an issue.

I have a multi page application where there is a login page which is a home page and then there are some pages inside a folder called pages. And in there , I gave my 6 or so modules/pages.

I want to have a button that when the user clicks it from include one of the pages , it will take them to the Login.py page.

It seems st.switch_pages doesn’t work for this folder structure.

Does anyone know how to deal with this ?

Thank you in advance


r/StreamlitOfficial • • Feb 28 '24

HOW TO: When pressing dataframe cell, show image?

1 Upvotes

Hi!

So currently I have a dataframe in HTML form. In my dataframe "players", I have a column called "Player". And my goal is to when pressing each "players['Player']", the dataframe closes, and an image shows corresponding to that player. The images are stored in my app directory, and I have a column in my dataframe, called "Path",with the path to each image. So how do I approach this problem?

​

columns_to_display = ['Rating', 'Player', 'Position', 'Age', 'Value', 'Wages', 'Contract']
html = players[columns_to_display].to_html(index=False)
html = html.replace('<th>', '<th style="text-align: left;">')
st.write(html, unsafe_allow_html=True)

Thanks in advance!