HarmonyOS & Ascend

Cat and Dog Recognition with MindSpore

A complete deep-learning experiment that runs from training all the way onto a phone: transfer learning for cat-and-dog binary classification with MindSpore and MobileNetV2, followed by conversion to MindSpore Lite format and deployment to an Android device for on-device inference.

Project Overview

The project starts from the Kaggle cats-and-dogs dataset, moves through data cleaning and splitting, MobileNetV2 transfer-learning training and model conversion, and finally ships the .ms model inside an Android app that classifies gallery photos directly on the phone. The whole chain runs locally and relies on no cloud inference service.

About This Project

What it sets out to do

Carry a trained model all the way onto a phone, covering the full chain from data preparation to on-device inference.

How it works

A MobileNetV2 classifier is trained with MindSpore on a PC and exported to the MindIR intermediate format, then converted into a .ms model with the MindSpore Lite Converter, and finally pushed over ADB for the Android app to load.

What it uses

MindSpore 2.0 and MindSpore Lite Converter 2.0; MobileNetV2 as the model; Kaggle Cats vs Dogs (PetImages) as the dataset; opencv-python, matplotlib and Pillow among the dependencies.

Scope and limits

This is a course experiment meant to build understanding of transfer learning and on-device deployment. Recognition covers cat-versus-dog binary classification and does not extend to finer breed distinctions.

Five steps from data to phone

Each step has clear inputs and outputs, so the pipeline can be reproduced in order.

Cleaning and splitting

Corrupted and anomalous images are filtered out, then the set is divided into training and validation portions so dirty data does not drag training down.

Transfer-learning training

A pretrained MobileNetV2 is loaded with its backbone weights frozen and only the classification head is trained, which converges quickly on a small dataset.

Model conversion

The training output is exported to MindIR and then converted by the MindSpore Lite Converter into the .ms format the device can load.

Deployment to the phone

The model and its supporting assets are pushed over ADB into the Android app, and inference then runs entirely on the phone.

Reviewing results

Gallery photos are classified directly on the phone, and the outcomes are checked against the loss and accuracy curves recorded during training.

What this experiment is

A deep-learning course experiment focused on connecting training to deployment, with no ambition to push classification accuracy to its limit.

Back to projects