While you were out shopping or cleaning up around the house, have you ever wondered what an item is worth? Estimating the value of items can be tricky, often requiring expert knowledge or time-consuming research. What if you could get a quick, AI-powered appraisal with just a picture?
That’s the idea behind AI Appraiser, a small project I recently built using the Google Gen AI SDK. Whether you’re assessing the value of a beloved collectible, figuring out a fair price for secondhand goods, or simply curious about the worth of everyday objects, AI Appraiser offers a user-friendly way to get AI-powered insights.
From curiosity to code
The project started with a question: could I leverage the power of Gemini’s multimodal capabilities and its integrated search to build a practical tool?
I was particularly interested in exploring Gemini’s grounding with Google Search capabilities. This feature seemed perfect for fetching up-to-date pricing information directly from the web, which is crucial for accurate item valuation. By grounding the AI’s analysis in real-time search results, I aimed to build an app that provides more reliable and informed estimates.
To bring AI Appraiser from a concept to reality, I focused on the user experience. Putting myself in the shoes of someone wanting to quickly check the value of an item, I thought, “Okay, what’s the first thing I’d naturally do?” The answer was: show the app the item. That’s why I started by focusing on the image upload feature, really trying to make it feel as smooth and effortless as possible. Drag and drop, click to upload — I wanted it to feel completely natural, like you were just showing the app what you had.
But even with a smooth image uploader, I knew that relying on pictures alone would be limiting, as photos don’t always tell the whole story. Think about those subtle details that can swing an item’s value wildly — the pristine condition of a vintage collectible, the telltale model number on a piece of tech, or those unique markings that authenticate a piece of art. To bridge this gap, I knew I needed to give users a way to add their own insights. That’s why I made sure to include an optional text description box.
Integrating with the Google Gen AI SDK is the heart of the application. All of the key pieces are documented in the Getting Started notebook:
- Passing in multimodal image data (the image and optional description)
- Enabling Grounding with Search to improve the valuation quality
- Enabling controlled generation to ensure the response format is consistent
With Gemini’s grounded search, you can think of the application as a research assistant that can instantly scour countless sources across the web, pulling in pricing data, market trends, and comparable listings.
Beyond that, I didn’t want AI Appraiser to just spit out a valuation and leave you guessing. It wanted it to show you Gemini’s reasoning, laying out the key factors it considered and providing direct links to the sources it used. This way, you’re not just getting a number; you’re getting a glimpse into the AI’s thought process, and you can judge for yourself whether the estimate makes sense.
Architecture: Keeping it Simple and Serverless
For this project, I wanted to keep the architecture straightforward and leverage serverless technologies for ease of deployment and scalability. Here’s the basic setup:
- Frontend: Built with HTML, Tailwind CSS, and HTMX. HTMX is a great little library that allows for dynamic UI updates without writing complex JavaScript, perfect for a project like this. Tailwind CSS helped with rapid styling, and plain HTML provided the structure.
- Backend: A FastAPI application in Python. FastAPI is excellent for building APIs quickly and efficiently. It handles image uploads, interacts with Google Cloud Storage (optionally), and calls the Gemini API.
- Gemini API: The star of the show! Gemini handles the heavy lifting of image analysis, search, and valuation.
Here’s a simplified diagram:
Key features in action
Image Upload and Preview
The frontend provides a drag-and-drop interface for image uploads. It uses the Dropzone file input component from the Flowbite CSS library. HTMX handles the asynchronous upload to the backend, and the image is immediately displayed for preview.
<input
id="image_file"
name="image_file"
type="file"
class="hidden"
hx-post="/upload-image"
hx-target="#image-preview"
hx-encoding="multipart/form-data"
/>
AI-Powered valuation with Gemini
The backend uses the Gemini API, specifically leveraging its grounding with Google Search capability. As highlighted in the documentation, this feature allows Gemini to augment its responses with real-time information from Google Search. The prompt instructs Gemini to act as a professional appraiser, using search to find comparable items and provide a reasoned valuation.
valuation_prompt = f"""You are a professional appraiser, adept at determining the value of items based on their description and market data.
Here is additional information provided by the user: {description}.
Your task is to estimate the item's fair market value
... prompt continues ..."
"""
google_search_tool = Tool(google_search=GoogleSearch())
config_with_search = GenerateContentConfig(tools=[google_search_tool])
response_with_search = client.models.generate_content(
model=MODEL_ID,
contents=[
Part.from_uri(file_uri=image_uri, mime_type=guess_type(image_uri)[0]),
valuation_prompt,
],
config=config_with_search,
)
Structured output and display
The Gemini API response is parsed, and now the estimated value, reasoning, and source URLs conform to a consistent data structure using controlled generation. HTMX then handles updating the results section dynamically.
class ValuationResponse(BaseModel):
estimated_value: float
currency: str
reasoning: str
search_urls: list[str]
# ...
config_for_parsing = GenerateContentConfig(
response_mime_type="application/json",
response_schema=ValuationResponse
)
Deployment to Cloud Run
Deploying AI Appraiser is very straightforward with Cloud Run. The Dockerfile is included in the repository, and deployment is as simple as running:
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"
Cloud Run handles containerization, deployment, scaling, and infrastructure management, allowing you to focus on the application code.
Try it out and contribute!
AI Appraiser is a fun little project that demonstrates the power of combining Gemini with Google Cloud. It’s not meant for professional appraisals, but it can be a handy tool for getting a quick estimate or just satisfying your curiosity.
The code is available on GitHub: https://github.com/kweinmeister/ai-appraiser
Feel free to clone the repository, deploy it to your own Google Cloud project, and experiment with it. Contributions and feedback are welcome! What other creative applications can we build with Gemini and Google Cloud? Let’s continue the conversation on LinkedIn, X, and Bluesky.
Top comments (0)