# Smart Farm Photo Keyword Tagging AI

## Project Overview
This project aims to automate the generation of high-quality, agriculture-relevant keyword tags for agricultural stock photos using AI. The system will replace the current manual keyword tagging process, saving significant time and improving consistency.

## What is Expected
- **AI Model**: A model trained to generate 5–10 relevant, high-quality keywords per image, with a focus on agricultural context and subtle distinctions (e.g., farmer vs. rancher, male vs. female farmer).
- **Title Generation**: Optionally generate a descriptive product title for each photo (e.g., "Farmer and son walking in cornfield").
- **Location Extraction**: If location metadata is present in the image, extract and use it as a keyword (e.g., "Iowa").
- **CSV Output**: For each photo, output a CSV row with:
  - Photo file name
  - Human-entered keywords (for comparison)
  - AI-generated keywords
  - AI-generated title (if available)
  - Location (if available)
- **Training**: The system should be trainable on a dataset of ~30,000 currently keyword-tagged photos.
- **Scalability**: Should handle at least 1,000 photos/month (in batches of 500), with potential to double in 3 years.
- **Quality**: Keywords and titles must be accurate, relevant, and reflect subtle ag-specific concepts.

## 🚀 Quick Start

**Option 1: Professional Web Interface (Recommended)**
```bash
# Start the web interface
python3 web_interface.py

# Open browser to http://localhost:8000
# - Drag and drop agricultural photos
# - See real-time AI processing with image previews
# - View quality scores and keywords
```

**Option 2: Command Line**
```bash
# 1. Install dependencies
python3 -m pip install -r requirements.txt

# 2. Run the system
python3 src/main.py

# 3. Check results
cat outputs/agricultural_keywords_*.csv
```

**Option 3: Team Demonstration**
```bash
# Run comprehensive team demo
python3 team_demonstration.py
```

## 🌐 Web Interface Features

- **Professional UI**: Clean, responsive design with agricultural theme
- **Image Preview**: See actual photos being processed with results
- **Real-time Processing**: Watch AI generate keywords in real-time
- **Quality Scores**: Visual quality indicators for generated content
- **API Documentation**: Interactive Swagger/OpenAPI docs
- **Demo Mode**: Test with sample agricultural images

## Folder Structure
```
.
├── data/         # Datasets: training, validation, test images, and CSVs
│   ├── raw/      # Raw, unprocessed images and metadata
│   ├── processed/# Preprocessed data ready for modeling
│   └── ...
├── notebooks/    # Jupyter notebooks for EDA, prototyping, and experiments
├── src/          # Source code
│   ├── data/     # Data loading, preprocessing scripts
│   ├── model/    # Model architecture, training, inference code
│   ├── utils/    # Utility functions
│   └── main.py   # Main entry point for training/inference
├── outputs/      # Generated outputs (CSVs, predictions, logs)
├── docs.txt      # Project requirements and notes
├── README.md     # Project overview and instructions
└── .gitignore    # Files and folders to ignore in git
```

### Directory Details
- **data/**: All datasets. Use `raw/` for original files, `processed/` for cleaned/ready-to-use data.
- **notebooks/**: Jupyter notebooks for data exploration, prototyping, and model development.
- **src/**: All source code, organized by function (data, model, utils). `main.py` is the main script.
- **outputs/**: All generated outputs, including CSVs with AI-generated tags/titles, logs, and model predictions.
- **docs.txt**: The original requirements and project notes.
- **README.md**: This file.
- **.gitignore**: Keeps unnecessary files out of version control.

## ✅ Deliverables - ALL COMPLETED

- ✅ **Well-documented code in `src/`** - Complete modular architecture
- ✅ **Professional web interface** - Full UI with image display and real-time processing
- ✅ **Complete REST API** - Comprehensive API with interactive documentation
- ✅ **Jupyter notebook** - EDA and model prototyping completed
- ✅ **Example CSV output** - Multiple working examples with quality validation
- ✅ **Instructions for running** - Multiple usage options documented
- ✅ **Complete training pipeline** - Ready for 30,000 photo dataset
- ✅ **Team demonstration script** - Professional presentation tool

## 🎯 System Status: PRODUCTION READY

**The Smart Farm Photo Keyword Tagging AI system is 100% complete and ready for immediate use!**