This application estimates the value of an item from an image. It leverages Google's Gemini model with integrated Grounding with Google Search capabilities to improve the accuracy of valuations.
This application is intended for informational purposes only and should not substitute for professional appraisals.
- AI-powered valuation: Get instant value estimates for your items using images and descriptions.
- Grounded search: Leverages Google's Gemini model with integrated search for recent pricing.
- Image upload: Supports GIF, PNG, and JPG images with a user-friendly interface.
- Optional Cloud Storage: Store images securely in Google Cloud Storage.
The AI Appraiser application follows a client-server architecture:
- Frontend (index.html): The client-side interface built with HTML, Tailwind CSS, and HTMX. It handles user interactions, image uploads, and displays valuation results.
- Backend (main.py): A FastAPI server that handles API requests. It interacts with Google Cloud Storage (optional) and the Gemini API for image processing and valuation.
- Gemini API: A powerful language model from Google that performs the core valuation logic, utilizing its built-in search tool for market data.
- Python 3.9+ with
pip
- A Google Cloud project with billing enabled. and
Vertex AI
andCloud Storage
APIs enabled - Set up Application Default Credentials (ADC) for your Google Cloud project. You can do this by running
gcloud auth application-default login
in your terminal. - (Optional) If storing images in Google Cloud Storage, configure a Google Cloud service account with the necessary permissions (
storage.objects.create
andstorage.objects.get
). You can find instructions on creating and managing service accounts in the Google Cloud documentation.
-
Clone the repository:
git clone https://github.com/kweinmeister/ai-appraiser cd ai-appraiser
-
Install dependencies:
pip install -r requirements.txt
-
Set environment variables:
The application uses several environment variables for configuration. You can set them directly in your terminal or use a
.env
file. See the Environment Variables section for details. At a minimum, you need to setGOOGLE_CLOUD_PROJECT
. If you want to use image upload to GCS, you also need to setCLOUD_STORAGE_BUCKET_NAME
. -
Run the application using Uvicorn:
uvicorn main:app --host 0.0.0.0 --port 8080
The application will be accessible at
http://localhost:8080
.
You can easily deploy this application to Google Cloud Run:
gcloud run deploy ai-appraiser \
--source . \
--region $LOCATION \
--allow-unauthenticated \
--set-env-vars="GOOGLE_CLOUD_PROJECT=$GOOGLE_CLOUD_PROJECT,STORAGE_BUCKET=$STORAGE_BUCKET,MODEL_ID=$MODEL_ID"
Replace $GOOGLE_CLOUD_PROJECT
, $LOCATION
, $STORAGE_BUCKET
, and $MODEL_ID
with your actual values. This command will build the container image, push it to Container Registry, and deploy it to Cloud Run.
To run the tests, use pytest:
pytest
The tests cover the core functionality of the application, including image upload, data URL generation, and valuation logic. They use mocking to simulate interactions with external services like Google Cloud Storage and the Gemini API.
GOOGLE_CLOUD_PROJECT
: (Required) Your Google Cloud project ID.LOCATION
: (Optional) The Google Cloud region to use. Defaults tous-central1
.MODEL_ID
: (Optional) The ID of the Gemini model to use. Defaults togemini-2.0-flash-001
.STORAGE_BUCKET
: (Optional) The name of your Google Cloud Storage bucket for image uploads. If not set, image uploads to GCS will be skipped.