PicToPoem is an AI-powered web application that analyzes uploaded images and recommends fitting passages from literary works. The application utilizes Google Gemini AI to analyze the mood and sentiment of images, then finds suitable quotes from real literary works with professional curator commentary.
- Image analysis for mood, color palette, and emotional tone
- Literary passage recommendations matched to image characteristics
- Professional curator commentary explaining the selection
- Instagram Story-style image generation with literary passages
- Responsive design for mobile and desktop devices
Backend
- Flask - Python web framework
- Google Gemini AI - Image analysis and text generation
- Pillow (PIL) - Image processing
- python-dotenv - Environment variable management
Frontend
- HTML5 - Page structure
- CSS3 - Styling and responsive design
- JavaScript (ES6+) - Client-side interactions
- Python 3.8 or higher
- Google Gemini AI API Key
1. Clone the repository
git clone <repository-url>
cd PicToPoem2. Create and activate virtual environment
python -m venv venv
# Windows
venv\Scripts\activate
# macOS/Linux
source venv/bin/activate3. Install dependencies
pip install -r requirements.txt4. Configure environment variables
Create a .env file in the project root:
GEMINI_API_KEY=your_google_gemini_api_key_hereTo obtain a Google Gemini AI API Key:
- Visit Google AI Studio
- Sign in with your Google account
- Click "Create API Key"
- Copy the generated key to your
.envfile
5. Prepare font files
Add a Korean font file to the backend directory:
- Required:
Gyeong-gi_Regular.ttf - Alternative fonts can be used with corresponding source code modifications
6. Run the application
cd backend
python app.py7. Access the application
Navigate to http://localhost:5000 in your web browser.
- Upload Image - Select an image file using the upload button (supports JPG, PNG, GIF)
- Generate Quote - Click "Generate Quote" to initiate AI analysis
- View Results - Review the recommended literary quote, source information, and curator commentary
- Save Story Image - Download an Instagram Story-formatted image with the quote overlay
PicToPoem/
├── backend/
│ ├── app.py
│ └── Gyeong-gi_Regular.ttf
├── frontend/
│ ├── index.html
│ ├── style.css
│ └── script.js
├── venv/
├── requirements.txt
├── .env
├── .gitignore
└── README.md
Analyzes an image and returns a literary recommendation.
Request
- Content-Type:
multipart/form-data - Body:
image(image file)
Response
{
"quote": "Literary passage text",
"source": {
"title": "Work title",
"author": "Author name"
},
"commentary": "Curator commentary"
}Generates a story image with quote overlay.
Request
- Content-Type:
multipart/form-data - Body:
image(original image file)quote(passage text)author(author name)title(work title)
Response
- Content-Type:
image/png - Body: Generated story image
- Store API keys in
.envfile only - Never commit
.envto version control - The
.envfile is excluded via.gitignore - Protect API keys from public exposure