This application allows users to upload images of softball game statistics from GameChanger, extract the player stats using Google Cloud Vision, and then generate a summary of the stats using Google Gemini.
By default, GameChanger provides visibility to individual baseball and softball box scores for specific games, but does not provide any aggregation across multiple games (except for your own team). This application is designed to fill that gap by parsing multiple box scores and generating a summary of the stats.
The application expects screenshots of the GameChanger box scores starting, at minimum, with the header row (LINEUP, AB, R, H, RBI, BB, SO) then including all of the individual player rows and excluding the team summary row. Example screenshots can be found in the examples/ directory. Upload all screenshots at once, and the application will process them all in parallel.
- Python 3.11 or higher
- pip (Python package installer)
- Google Cloud SDK (for deployment to Google Cloud Run)
- A Google Cloud Platform project with the Vision API and Gemini API enabled
- A Gemini API key
The required Python packages are listed in requirements.txt:
- Flask
- google-cloud-vision
- google-generativeai
- werkzeug
-
Clone the repository:
git clone <repository_url> cd <repository_directory>
-
Create a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
-
Set your Gemini API key as an environment variable. Create a
.envfile in the root directory and add the following line, replacingyour_gemini_api_keywith your actual key:GEMINI_API_KEY=your_gemini_api_key -
Run the application:
python main.py
The application will start on
http://0.0.0.0:8080/. Open this address in your web browser to access the application.
-
Make sure you have the Google Cloud SDK installed and configured.
-
Build and deploy the application to Google Cloud Run using the following command:
gcloud run deploy gc-stat-aggregator \ --source . \ --region us-central1 \ --platform managed \ --allow-unauthenticated \ --memory 512Mi \ --cpu 1 \ --set-env-vars GEMINI_API_KEY=your_gemini_api_keyReplace
your_gemini_api_keywith your actual Gemini API key. This command will:- Deploy the application to Google Cloud Run
- Set the region to
us-central1 - Allow unauthenticated access to the application
- Allocate 512MB of memory and 1 CPU to the application
- Set the
GEMINI_API_KEYenvironment variable
After deployment, Google Cloud Run will provide a URL to access the application.
This project is licensed under the Apache 2.0 License.