Generate memes using Google Gemini models!
This project provides two ways to generate memes:
- Streamlit App: An interactive web UI.
- API + CLI: A REST API and a command-line interface.
-
Clone the repository (if needed):
git clone https://github.com/AditHash/meme-generator.git cd meme-generator
-
Install dependencies (preferably in a virtual environment):
pip install -r requirements.txt
If you don't have a
requirements.txt
, install manually:pip install streamlit google-generativeai python-dotenv flask
-
Set up your environment variables:
- Create a
.env
file in the project directory. - Add your Google Gemini API key:
GEMINI_API_KEY=your_api_key_here
- Create a
streamlit run streamlit_app.py
- Open the provided local URL in your browser.
- Enter your
GEMINI_API_KEY
in the sidebar (or set it in.env
). - Enter a meme idea and generate/download your meme.
- Logs and debug output are available in an expander at the bottom.
python api.py
- The Flask server will start at
http://127.0.0.1:5001
. - Make POST requests to
/generate
with a JSON body:{ "prompt": "generate a cat meme" }
- The response will be an image file.
python main.py
- You will be prompted to enter a meme idea in the terminal.
- The meme will be generated and saved (if you enable saving in the code).
- API Key: You can get your Gemini API key from Google AI Studio.
- Models: You can change the text and image model names in the UI or API as needed.
- Requirements: Python 3.8+ recommended.
streamlit_app.py
— Streamlit web app (no separate backend needed)api.py
— Flask REST API servermain.py
— Meme generation logic and CLI.env
— Store your API key here (not committed to git)README.md
— This file
MIT License (or specify your own)