Creating an AI Agent that curates images for ML datasets (Google All Things Agentic Hackathon)
DEV Community

Creating an AI Agent that curates images for ML datasets (Google All Things Agentic Hackathon)

The last months I have been working on an app that is like Pokemon GO but for real dogs: a person takes a photo of a dog, the app recognizes the breed and adds it to a dog collection, you can get achievements and participate on seasonal challenges, among other fun stuff. The app's name is Todogs and it's available on Android and iOS A big challenge was to make the app work in real time, with no delays, and without needing internet connection to perform the recognition, so for that I needed to train my own Machine Learning model, for what I used Tensorflow (And TFLite to run it), I trained a model with 117 breeds and worked like a charm!. Now, in order to train an image model like this you need a big enough dataset for the model accuracy to be good enough for a product, I found some images repositories that I used, needing around 150 images for each one of the 117 breeds. The thing is, even in these repositories there are some mistakes, some breeds with wrong tags, some images are too dark, or multiple dogs show in them, etc. Also, now that I want the model to include more breeds and improve itself, I have to search on the internet for more dog images (The more data the better). The problem is the manual process is exhausting, these are the steps: - I go to internet and search for a breed, let's say Chow chow. - Pick a lot of images and save them, it's cool that there are some repos out there with folders of dogs, so that saves me some time, for other dogs I have to pick the images myself. - Filter those images one by one, check that they are not studio photos (the real users world is messier), that dogs are not cropped, that no multiple dogs are in the photo, anything that could confuse the model. - Move the photos to my dataset to re-train. Also, another thing I want to do is use the same photos generated on the app as new data to re-train the model, but there are lots of low-precision and not adequate photos, applying the process above is just unsustainable, I'd need a full time person for that. Enter Google All Things Agentic Hackathon I got a link to this Hackathon from a friend, the hackathon is about learning to create AI agents with the Google services and platforms (Cloud Run, Antigravity SDK, VertexAI, Gemini, etc) and create a project using those tools so solve a problem you have. Right away came to my mind "Wait, I could create an agent for my problem!", so I started digging on it and started building a solution that is going to save me a lot of headaches. I wrote this article as part of my submission to the All Things Agentic Hackathon. The project I started was an AI agent to do the whole process described above in minutes instead of weeks, it works like this: I open the agent, write "Give me 100 Husky images" and it goes to a repository with photos of many dogs, then it picks Husky and goes image by image. Then it starts throwing images away. First the cheap checks in Python: anything too small, anything that won't even open, and near-duplicates caught with perceptual hashing (so the same photo at two sizes gets spotted, not just byte-identical files). Then the expensive one: Gemini looks at every surviving image and answers the questions I used to answer by hand. Is there actually a dog? Is it the breed I asked for? Is there only one? Is it sharp enough? And the weird one: does it look like a photo a phone would take, or like a studio shot? Studio photos are beautiful and useless to me, because my users are outside with bad lighting and a dog that won't sit still. The part I'm most proud of is that the agent refuses to guess. If I ask for a breed that isn't in the corpus, it stops and tells me instead of handing me the closest thing it found. If a request is genuinely ambiguous, it asks me which one I meant instead of picking. That sounds like a small thing, but a wrong breed match poisons a training set silently - nothing downstream ever catches it, the model just gets a little worse and you find out months later. At the end it saves the good photos on my Google Drive. With this project I achieved several things: - Learned Agents from zero to a production product deployed on Cloud Run. - Created a tool that's going to be very useful and will save tons of time for a project that I was already working on. - Got to participate in the hackathon with possibility of earning a prize. Stack used: - Google ADK - Google GenAI SDK - Gemini 3.5 Flash - Vertex AI - Cloud Run - Cloud Storage - Secret Manager - Google Drive API - Python 3.12 - Pillow - ImageHash Challenges: - I had to learn in record time, the hackathon had a deadline. - Each inspected image is one Gemini call, so it's the part that scales with the dataset. I keep it down by shrinking images before sending them, using low media resolution, and only inspecting the images a request actually needs. - Because I was totally new, I had to learn a big part of the stack from zero, this delayed me and sometimes made me go back because I did something wrong. What's next: - Plug the agent to my own Firebase Firestore for the photos generated by the users, so my model can learn from it's own mistakes. - Crazy idea: Scrapping the web so I don't need to get the images together at all or depend on repositories. So it seems a Hackathon I didn't know some weeks ago helped me to solve one of my biggest challenges. Top comments (0)

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.