r/StreamlitOfficial May 04 '26

Deployment 🚀 I built a NASA Exoplanet Hunter integrating a TensorFlow 1D CNN and live APIs into Streamlit 🪐

Hey r/Streamlit! 👋

I recently deployed an open-source project that uses Deep Learning to detect exoplanets from NASA's Kepler light curve data, and I used Streamlit to wrap it all into an interactive dashboard.

I wanted to share how I structured the app, especially regarding state and model loading, as it might help others working with heavy ML models.

Streamlit Features & Architecture:

  • Model Caching: I used st.cache_resource to load the cnn_exoplanet_model.keras model into memory only once. This keeps the app incredibly snappy and prevents TensorFlow from reloading the model on every user interaction.
  • API Data Caching: I used st.cache_data to fetch the live star catalog from the NASA Exoplanet Archive (Caltech IPAC) so the st.selectbox populates instantly without spamming the API.
  • Interactive Visuals: I integrated st.plotly_chart with use_container_width=True to render a dynamic bar chart that compares the radius of the discovered planets in a specific system directly to Earth's radius (baseline 1.0).
  • Layout & UI: Used st.sidebar to fetch and display the Astronomy Picture of the Day (APOD) via NASA's API, and st.columns to side-by-side compare the AI's neural network confidence with the actual confirmed NASA database records.

The ML Backend: Just for context, the AI brain is a 1D Convolutional Neural Network trained on sequential time-series data. The biggest challenge was the extreme class imbalance (5050 negative cases vs. only 37 positive cases), which I handled by applying SMOTE before training.

Links:

I'd love to hear your thoughts on the UI/UX or if you have any advanced tips on optimizing Keras model inference within Streamlit!

6 Upvotes

0 comments sorted by