Skip to content

PicToPoem is an AI-powered web application that analyzes your uploaded images and recommends a fitting passage from a literary work.

Notifications You must be signed in to change notification settings

JYS1025/PicToPoem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PicToPoem - Poetry from a Picture

About the Project

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.

Key Features

  • 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

Tech Stack

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

Installation and Setup

Prerequisites

  • Python 3.8 or higher
  • Google Gemini AI API Key

Installation Steps

1. Clone the repository

git clone <repository-url>
cd PicToPoem

2. Create and activate virtual environment

python -m venv venv

# Windows
venv\Scripts\activate

# macOS/Linux
source venv/bin/activate

3. Install dependencies

pip install -r requirements.txt

4. Configure environment variables

Create a .env file in the project root:

GEMINI_API_KEY=your_google_gemini_api_key_here

To obtain a Google Gemini AI API Key:

  1. Visit Google AI Studio
  2. Sign in with your Google account
  3. Click "Create API Key"
  4. Copy the generated key to your .env file

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.py

7. Access the application

Navigate to http://localhost:5000 in your web browser.

Usage

  1. Upload Image - Select an image file using the upload button (supports JPG, PNG, GIF)
  2. Generate Quote - Click "Generate Quote" to initiate AI analysis
  3. View Results - Review the recommended literary quote, source information, and curator commentary
  4. Save Story Image - Download an Instagram Story-formatted image with the quote overlay

Project Structure

PicToPoem/
├── backend/
│   ├── app.py
│   └── Gyeong-gi_Regular.ttf
├── frontend/
│   ├── index.html
│   ├── style.css
│   └── script.js
├── venv/
├── requirements.txt
├── .env
├── .gitignore
└── README.md

API Endpoints

POST /api/generate

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"
}

POST /api/create-story

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

Security

  • Store API keys in .env file only
  • Never commit .env to version control
  • The .env file is excluded via .gitignore
  • Protect API keys from public exposure

About

PicToPoem is an AI-powered web application that analyzes your uploaded images and recommends a fitting passage from a literary work.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published