DEV Community

Ray
Ray

Posted on

11

YOLO V5 running on an Android phone Part 1(train model)

Kia Ora!
Recently in our AI project, we have been working on monitoring river heights using the Yolo algorithm. It sends an alert like a server when the river height exceeds a certain safe range.
Today I am bringing you a share on how to deploy the Yolo algorithm program using an Android phone

Image description

My main development environment is currently an M1 chip MAC, and I often encounter all kinds of bugs on Yolo v8 (but I already have a solution, I'll organize it and update it later), so for today's demo tutorial we're going to start with Yolo v5. I'd like to thank this YouTuber, whose video solved a very large number of problems for me:
https://www.youtube.com/watch?v=zs43IrWTzB0

I won't go over the steps to install Yolo v5, you can easily find their repository on Git Hub.
For labelling and processing the data I used: roboflow
This page is very user-friendly for all versions of Yolo support. There are also many open-source datasets available.

Use the dataset to train:



!python train.py --img 640 ---batch 16 --epochs 10 --data DataSet/data.yaml --weights yolov5s.pt


Enter fullscreen mode Exit fullscreen mode

Validate using the dataset:



!python detect.py --source DataSet/valid/images --weights runs/train/exp/weights/best.pt


Enter fullscreen mode Exit fullscreen mode

After completing the training, we need to export to the tflite format



!python export.py --weights runs/train/exp/weights/best.pt --include tflite


Enter fullscreen mode Exit fullscreen mode

This concludes our training of the model and I can't wait to try it out:



!python detect.py --source 0 --weights runs/train/exp/weights/best.pt


Enter fullscreen mode Exit fullscreen mode

Image description
This way we have our own model, and of course we are able to achieve better performance through various manipulations of the dataset during the training process.

Billboard image

The fastest way to detect downtimes

Join Vercel, CrowdStrike, and thousands of other teams that trust Checkly to streamline monitoring.

Get started now

Top comments (0)

Sentry mobile image

Improving mobile performance, from slow screens to app start time

Based on our experience working with thousands of mobile developer teams, we developed a mobile monitoring maturity curve.

Read more

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay