Metadata-Version: 2.4
Name: autovqa
Version: 0.1.0
Summary: A Python library for automated visual question answering data generation.
License: MIT License
         
         Copyright (c) 2025 AutoVQA
         
         Permission is hereby granted, free of charge, to any person obtaining a copy
         of this software and associated documentation files (the "Software"), to deal
         in the Software without restriction, including without limitation the rights
         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         copies of the Software, and to permit persons to whom the Software is
         furnished to do so, subject to the following conditions:
         
         The above copyright notice and this permission notice shall be included in all
         copies or substantial portions of the Software.
         
         THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         SOFTWARE.
License-File: LICENSE
Requires-Python: >=3.9
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Provides-Extra: dev
Requires-Dist: aiohttp
Requires-Dist: appdirs (==1.4.4)
Requires-Dist: black (==25.11.0) ; extra == "dev"
Requires-Dist: flake8 (==7.3.0) ; extra == "dev"
Requires-Dist: gdown
Requires-Dist: google-genai
Requires-Dist: isort (==7.0.0) ; extra == "dev"
Requires-Dist: loguru (>=0.7.3)
Requires-Dist: mypy (==1.18.2) ; extra == "dev"
Requires-Dist: numpy (==2.0.2)
Requires-Dist: openai
Requires-Dist: opencv-python (==4.12.0.88)
Requires-Dist: pandas (==2.3.3)
Requires-Dist: pillow (==12.0.0)
Requires-Dist: pre-commit (==4.5.0) ; extra == "dev"
Requires-Dist: pydantic
Requires-Dist: pytest (==9.0.1) ; extra == "dev"
Requires-Dist: pytest-cov (==7.0.0) ; extra == "dev"
Requires-Dist: python-dotenv
Requires-Dist: requests (==2.32.5)
Requires-Dist: tomli
Requires-Dist: tqdm (==4.67.1)
Description-Content-Type: text/markdown

# AutoVQA

A Python library for automated visual question answering data generation.

[![Paper](https://img.shields.io/badge/arXiv-2603.09689-b31b1b.svg)](https://arxiv.org/abs/2603.09689)
[![Dataset](https://img.shields.io/badge/Kaggle-Dataset-20BEFF.svg)](https://www.kaggle.com/datasets/nguynrichard/auto-vivqa)

---

## Installation

```bash
pip install autovqa
```

For development installation:

```bash
git clone https://github.com/Ddyln/AutoVQA.git
cd AutoVQA
pip install -e ".[dev]"
```

## Quick Start

```python
import json
from autovqa.evaluate import run_evaluate
from autovqa import eda_pipeline, filter_pipeline, balancer_pipeline

# Step 1: Evaluate your augmented VQA data (scores image + text quality)
run_evaluate(limit_samples=-1, max_retries=3)

# Step 2: Load the evaluated data
with open("evaluated_vqa.json", "r", encoding="utf-8") as f:
    data = json.load(f)

# Step 3: Run EDA pipeline
df = eda_pipeline(data, output_dir="./reports", generate_report=True)

# Step 4: Filter low-quality records
df = filter_pipeline(df, threshold=0.5)

# Step 5: Balance the dataset
df = balancer_pipeline(df)

# Save results
df.to_csv("output.csv", index=False)
```

## Pipeline Overview

```
Collect ──► Augment ──► Evaluate ──► EDA ──► Filter ──► Balance
```

| Step | Module | Output |
|------|--------|--------|
| 1 | `collect` | Raw images + text JSON |
| 2 | `augment` | `augmented_vqa.json` — new QA pairs |
| 3 | `evaluate` | `evaluated_vqa.json` — QA + scores |
| 4 | `eda` | Cleaned DataFrame + Excel reports |
| 5 | `filter` | Quality-filtered DataFrame |
| 6 | `balance` | `balanced_data.csv` |

## Features

### Collect
Download VQA datasets and images from various sources.

```python
from autovqa.collect import download_default_data

download_default_data(output="./data")
```

### Preprocess
Image preprocessing pipeline for VQA tasks (resize, denoise, color correction, sharpening).

```python
from autovqa.preprocess.main import preprocess_image, run_pipeline

# Single image
processed = preprocess_image("image.jpg", target_size=(480, 640))

# Batch processing
run_pipeline(input_folder="./raw_images", output_folder="./processed_images")
```

### Augment
Generate VQA question-answer pairs using LLMs (e.g., Gemini).

```python
from autovqa.augment.client import AugmentClient

client = AugmentClient(service_name="google")
results = client.run_pipeline(
    image_folder_dir="./images",
    output_json_path="./augmented_vqa.json"
)
```

### Evaluate
Score each QA pair and its image across multiple dimensions using Gemini. You can use either a Google API key via `GOOGLE_API_KEY` or Google Cloud / Vertex AI credentials.

```python
from autovqa.evaluate import run_evaluate

# Evaluate all records (supports resuming from checkpoints)
run_evaluate(limit_samples=-1, max_retries=3)
```

Scores produced per record:
- **`eip_`** — Image quality (clarity, occlusion, object density, scene clutter, etc.)
- **`idp_`** — Image diversity (scene type, main object, cultural context, demographics)
- **`etp_`** — Text quality (grammar, unambiguity, QA structure, syntactic complexity)
- **`vqac_`** — VQA correlation (question↔image, answer↔image, reasoning depth)

### EDA (Exploratory Data Analysis)
Analyze evaluated VQA data with cleaning, feature extraction, and report generation.

```python
from autovqa import eda_pipeline

df = eda_pipeline(
    data=data,
    output_dir="./reports",
    generate_report=True,
    aggregation_type="median"
)
```

### Filter
Filter data based on quality labels and thresholds.

```python
from autovqa import filter_pipeline

df_filtered = filter_pipeline(df, threshold=0.5, show_stats=True)
```

### Balance
Balance class distributions in your dataset.

```python
from autovqa import balancer_pipeline

df_balanced = balancer_pipeline(df_filtered, output_path="./balanced.csv")
```

## Data Format

AutoVQA expects JSON data in the following format for the EDA/Filter/Balance pipeline (output of the Evaluate step):

```json
[
    {
        "question": "What is in the image?",
        "answers": ["Answer 1", "Answer 2", "Answer 3", "Answer 4", "Answer 5"],
        "image_link": "http://images.cocodataset.org/...",
        "image_name": "000000001.jpg",
        "index": 1,
        "image_quality_evaluation": { "...": "..." },
        "image_diversity_evaluation": { "...": "..." },
        "text_quality_evaluation": { "...": "..." },
        "correlation_evaluation": { "...": "..." }
    }
]
```

## Documentation

See the [Getting Started Notebook](docs/getting_started.ipynb) for detailed usage examples, or the [Example Notebook](docs/example.ipynb) for a minimal end-to-end run.

## Development
For more details on setting up a development environment, please refer to the [Development Guide](DEV.md).

## Contributing

Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Citation

If you use AutoVQA in your research, please cite:

```bibtex
@misc{tuong2026autoviVQA,
  title  = {AutoViVQA: A Large-Scale Automatically Constructed Dataset for Vietnamese Visual Question Answering},
  author = {Nguyen Anh Tuong, Phan Ba Duc, Nguyen Trung Quoc, Tran Dac Thinh, Dang Duy Lan, Nguyen Quoc Thinh, Tung Le},
  year   = {2026},
  eprint = {2603.09689},
  archivePrefix = {arXiv},
  primaryClass  = {cs.CV},
  url    = {https://arxiv.org/abs/2603.09689}
}
```

