AQIVisualizer is a command-line Python application that fetches the Air Quality Index (AQI) data for a specified city and generates a landscape image that artistically represents the current air quality conditions. The tool uses environmental data APIs and OpenAI's image generation capabilities to overlay the AQI value on the image in a hyper-realistic style.
For example:
- Fetch real-time AQI data for any specified city.
- Generate a hyper-realistic image of the city's landmark with an AQI representation.
- Customize the text overlay on the generated image.
- Command-line arguments for easy customization.
- Save the final image to a specified path.
Before you begin, ensure you have met the following requirements:
- Python 3.6 or higher installed on your machine.
- An active internet connection to fetch data from APIs and generate images.
- API keys for OpenAI and AQICN services.
The project is organized into the following modules under ./src
:
aqi_api.py
: Handles the fetching of AQI data from the environmental data API.image_generator.py
: Manages the generation of images and the addition of text overlays.cli.py
: Contains the command-line interface logic for accepting user inputs.utils.py
: Provides utility functions such as logging setup.main.py
: Serves as the entry point to the application, orchestrating the flow between modules
To install AQIVisualizer, follow these steps:
-
Clone the repository or download the source code to your local machine.
-
Navigate to the project directory.
-
Install the required Python dependencies:
pip install -r requirements.txt
-
Set up your API keys as environment variables:
export OPEN_AI_TOKEN=<your_openai_token> export AQICN_TOKEN=<your_aqicn_token>
Replace
<your_openai_token>
and<your_aqicn_token>
with your actual OpenAI and AQICN API keys, respectively.Get your AQI Token from here.
To use AQIVisualizer, you can run the script with optional command-line arguments. Here's how you can execute the script:
python src/main.py --city "City Name" --text "Custom Text Overlay" --output "path/to/save/image"
Example: