DEV Community

Navas Herbert
Navas Herbert

Posted on

Build an AI Instagram Caption Generator for Car Enthusiasts Using OpenAI and Streamlit πŸš—πŸ”₯

If you post car content on Instagram, you know the pain of writing fresh captions every time. I built an AI-powered caption generator that helps you auto-generate captions, hashtags, and even TikTok sound ideas β€” just from a car photo.

In this article, I’ll show you how I built it using:

  • 🧠 OpenAI GPT-4 Vision
  • πŸ–ΌοΈ Image analysis
  • 🌐 Streamlit app interface
  • πŸ› οΈ My personal caption history as training context

πŸ”§ What We'll Build

Image description


πŸš€ Tech Stack


πŸ“ Project Structure

car-caption-generator-ai/
β”œβ”€β”€ app.py                     # Streamlit app logic
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ vision.py              # GPT-4 Vision logic
β”‚   β”œβ”€β”€ captions.py            # Captions and hashtags generator
β”‚   └── prompts.py             # Stores the prompt template
β”œβ”€β”€ requirements.txt           # Dependencies
└── README.md
Enter fullscreen mode Exit fullscreen mode

Setup Instructions

1 .Clone the repo:

git clone https://github.com/Navashub/caption_generator_ai.git
cd car-caption-generator-ai
Enter fullscreen mode Exit fullscreen mode

2.Create and activate a virtual environment:

python -m venv myvenv
source myvenv/bin/activate  # Windows: myvenv\Scripts\activate
Enter fullscreen mode Exit fullscreen mode

3.Install dependencies:

pip install -r requirements.txt
Enter fullscreen mode Exit fullscreen mode

4.Add your OpenAI API key in a .env file

OPENAI_API_KEY=""
Enter fullscreen mode Exit fullscreen mode

5.Run the app:

streamlit run app.py
Enter fullscreen mode Exit fullscreen mode

🧠 How It Works

1.The app uses GPT-4 Vision to describe your uploaded car image.
2.That description is passed into a prompt template (along with your past captions).
3.The model returns:
- An Instagram caption
- Hashtags
- TikTok sound vibes

Here’s a sample output for an Audi RS5:

"Brutal beauty in carbon black. The RS5 doesn’t speak β€” it growls. Welcome to the autobahn attitude. πŸ’¨πŸ”₯
#RS5Power #FavouriteFourRings #AudiLife"
Enter fullscreen mode Exit fullscreen mode

Top comments (0)