AI-powered space image education tool that identifies celestial objects using GPT-4 Vision and NASA data
Live Demo β’ Features β’ Quick Start β’ Documentation
- About
- Features
- Live Demo
- Quick Start
- Installation
- Usage
- Tech Stack
- API Reference
- Project Structure
- Contributing
- License
SpaceExplainer AI is an intelligent web application that helps users identify and learn about celestial objects in space images. By combining OpenAI's GPT-4 Vision model with NASA's Image Library, it provides comprehensive educational content about astronomical phenomena.
Key Capabilities:
- π€ AI-powered image analysis with confidence indicators
- π Real-time NASA Image Library search
- π Educational facts and learning resources
- π¨ Detection of artistic/synthetic images
- π± Fully responsive design
| Feature | Description |
|---|---|
| π€ AI Image Analysis | Powered by OpenAI GPT-4 Vision to identify celestial objects and phenomena with confidence scoring |
| π NASA Integration | Searches NASA's Image Library for relevant official images and context |
| π Educational Facts | Quick facts about object type, visibility, distance, and viewing season |
| π Learn More | Direct links to Wikipedia, YouTube, and educational resources |
| π¨ Art Detection | Identifies artistic, AI-generated, or synthetic images to prevent false identifications |
| π Copy Analysis | Easy copy-to-clipboard functionality for analysis text |
| π Smart Caching | Optimized performance with intelligent caching (1-hour TTL) |
| π± Responsive Design | Works seamlessly on desktop and mobile devices |
| π Environment Variables | Support for .env file configuration |
Coming Soon! Deploy your own instance following the Deployment Instructions.
-
Clone & Install
git clone https://github.com/yourusername/spaceexplainer-ai.git cd spaceexplainer-ai pip install -r requirements.txt -
Configure Environment
cp .env.example .env # Edit .env and add your OPENAI_API_KEY -
Run
streamlit run app.py
That's it! The app will open at http://localhost:8501
- Python 3.8 or higher
- OpenAI API Key (Get one here)
- Git (for cloning)
git clone https://github.com/yourusername/spaceexplainer-ai.git
cd spaceexplainer-aipython -m venv venv
# On Windows
venv\Scripts\activate
# On macOS/Linux
source venv/bin/activate# For development (flexible versions)
pip install -r requirements.txt
# For production (exact versions)
pip install -r requirements_frozen.txt# Copy the example file
cp .env.example .env
# Edit .env and add your API key
# OPENAI_API_KEY=sk-your-actual-key-herestreamlit run app.pyThe application will automatically open in your default browser at http://localhost:8501
-
Enter API Key (or load from
.env)- The app automatically loads
OPENAI_API_KEYfrom.envfile - You can override it in the sidebar if needed
- The app automatically loads
-
Upload Image
- Click "Choose an image file"
- Select a JPG, JPEG, or PNG space image
- Supported formats: JPG, JPEG, PNG
-
Analyze
- Click "Analyze with AI" button
- Wait for AI analysis (typically 5-10 seconds)
-
Explore Results
- Review AI analysis with confidence indicators
- Browse NASA Image Library results
- Access educational resources
# The app handles this automatically, but here's what happens:
1. User uploads "crab_nebula.jpg"
2. Image is converted to base64 and resized if needed
3. GPT-4 Vision analyzes the image
4. Confidence level is determined (High/Medium/Low)
5. NASA Image Library is searched for "Crab Nebula"
6. Results are displayed with educational context# For AI-generated or artistic images:
1. AI detects artistic/synthetic nature
2. Confidence level set to "Low"
3. Warning message displayed
4. NASA search uses "nebula art" or "space art" instead
5. Shows appropriate artistic space images- Image Quality: Higher resolution images (up to 2000px width) provide better analysis
- Supported Formats: JPG, JPEG, PNG
- Image Size: Large images are automatically resized to optimize API calls
- Caching: Results are cached for 1 hour to improve performance
- API Costs: Monitor your OpenAI usage on the OpenAI Dashboard
| Component | Technology | Version | Purpose |
|---|---|---|---|
| Frontend | Streamlit | β₯1.28.0 | Web application framework |
| AI Model | OpenAI GPT-4 Vision | Latest | Image analysis and identification |
| Data Source | NASA Image Library API | Public | Official space images |
| Image Processing | Pillow (PIL) | β₯10.1.0 | Image manipulation and conversion |
| HTTP Client | Requests | β₯2.31.0 | API communication |
| Environment | python-dotenv | β₯1.0.0 | Environment variable management |
| Language | Python | 3.8+ | Core programming language |
Searches NASA's Image Library for relevant space images.
Parameters:
search_term(str): Search query (e.g., "Crab Nebula")
Returns:
List[Dict]: List of image results with title, description, image_url, nasa_id, nasa_url
Example:
results = search_nasa_images("Crab Nebula")
# Returns: [{"title": "...", "description": "...", ...}, ...]Extracts the main celestial object name from AI analysis.
Parameters:
ai_response(str): Full AI analysis text
Returns:
str | None: Clean object name (e.g., "Crab Nebula") or None
Example:
object_name = extract_object_name(ai_response)
# Returns: "Crab Nebula"Determines confidence level of AI analysis.
Parameters:
ai_response(str): Full AI analysis text
Returns:
str: "high", "medium", or "low"
Example:
confidence = extract_confidence_level(ai_response)
# Returns: "high" | "medium" | "low"Converts uploaded image to base64 format for OpenAI API.
Parameters:
uploaded_file: Streamlit uploaded file object
Returns:
str: Base64 data URI string
Example:
base64_image = image_to_base64(uploaded_file)
# Returns: "data:image/jpeg;base64,..."spaceexplainer-ai/
βββ app.py # Main Streamlit application
βββ requirements.txt # Python dependencies (flexible versions)
βββ requirements_frozen.txt # Python dependencies (exact versions)
βββ .env.example # Environment variables template
βββ .gitignore # Git ignore file
βββ README.md # This file
βββ LICENSE # MIT License (to be added)
app.py: Main application file containing all Streamlit UI and logicrequirements.txt: Flexible dependency versions for developmentrequirements_frozen.txt: Exact dependency versions for production.env.example: Template for environment variables.gitignore: Excludes sensitive files and build artifacts
-
Push to GitHub
git add . git commit -m "Initial commit" git push origin main
-
Deploy on Streamlit Cloud
- Visit share.streamlit.io
- Sign in with GitHub
- Click "New app"
- Select your repository
- Set main file path:
app.py - Click "Deploy"
-
Configure Secrets
- Go to app settings β Secrets
- Add:
OPENAI_API_KEY=your-key-here - Save and redeploy
For production deployment, set these environment variables:
export OPENAI_API_KEY=sk-your-key-hereOr use Streamlit Cloud's secrets management (recommended).
We welcome contributions! Here's how you can help:
-
Fork the Repository
git clone https://github.com/yourusername/spaceexplainer-ai.git
-
Create a Feature Branch
git checkout -b feature/AmazingFeature
-
Make Your Changes
- Follow PEP 8 style guidelines
- Add docstrings to new functions
- Update README if needed
-
Commit Your Changes
git commit -m 'Add some AmazingFeature' -
Push to Branch
git push origin feature/AmazingFeature
-
Open a Pull Request
- Describe your changes
- Reference any related issues
- Wait for review
# Install development dependencies
pip install -r requirements.txt
# Run the app
streamlit run app.py
# Clear cache if needed
# Use sidebar button or: st.cache_data.clear()This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2026 Pawan Konwar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
AI Accuracy Notice: While AI analysis is powerful, it may not always be 100% accurate. Always verify important information with official sources. This tool is for educational purposes only.
API Costs: This app uses OpenAI's API which incurs costs. Monitor your usage on the OpenAI Dashboard.
Image Authenticity: The app includes confidence indicators to help identify artistic or synthetic images. However, users should exercise judgment when interpreting results.
- OpenAI for GPT-4 Vision API
- NASA for Image Library API and educational resources
- Streamlit for the amazing framework
- All contributors and space enthusiasts who make this project possible
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: [Your Email] (optional)
Made with β€οΈ for Space Enthusiasts π
β Star this repo if you find it helpful!