This time, I tried the one that detects and identifies Coin as Gif at the beginning. What to prepare --About 100 data (Jpeg photos)
For machine learning ・ Image Classification ・ Sound Classification ・ Action Classification ・ Object Detection However, this time we will implement Object Detection, that is, detect objects.
Since Object Detection refers to detecting an object, it is necessary to judge "what is in the image". Therefore, "photograph" and "position information" are required. Take photos in advance and store them in folders. (Folder name = classification name) This time, we want to detect and identify coins, so we need a folder of 500 yen to 1 yen and the location information of each image. → Click here to find out more about Object Detection. Training Object Discovery Model in Create ML
--Collect data. (Take the photo you want to detect) --Classify the data collected using IBM Cloud Annotations (hereinafter referred to as IBMCA), specify the location information, and create a dataset. --Create Model by putting the file created by IBM CA in Create ML --Try Test on Create ML --Try it in an Apple sample
As for the photos, I prepared about 100 photos showing Coin this time.
Photo ・ Photos from various angles ・ Around 30 sheets are available for each of the three patterns of large, medium, and small sizes. ・ The background is unified and white
Object Detection requires not only photos but also JSON files (because location information is required), so this time I used IBM Cloud Annotations account (free). Created. How to make it is as follows.
· Click Continue IBM Cloud
・ Click on a new project
・ Click localization
・ Enter the file name, and when the project starts, you will be able to D & D the photo, so enter it.
・ Drag to object (coin this time) and enclose it ・ Label name can be entered on the right side.
-The Label name once described can be selected from the down list on the upper left, so it is efficient to attach a Label to the Coin
・ After attaching Label to all photos, export from File so that it can be used in Create ML.
・ Success if this file is generated
-Check if there is a JSON file in the folder
Once the dataset is created, right click on Xcode and launch Create ML
Select object Detection and D & D the folder of the dataset file you created earlier. It seems that it is not good if the number of repetitions of learning training (I think) is large, but even if it is extremely small, the accuracy will not be obtained, so if it is sweet, try raising it a little and adjusting it. (I tried 300, 600, 1000 this time, but it didn't change.)
After learning, test it, and if there is no problem, take out the Model. (Can be taken out by D & D)
After that, download and open RecognizingObjectsInLiveCapture provided by Apple.
D & D the Model created by Create ML here
The code originally reads a model called Object Detector and is it a croissant or banana? Because there is something to detect and identify
guard let modelURL = Bundle.main.url(forResource: "ObjectDetector", withExtension: "mlmodelc")
To
guard let modelURL = Bundle.main.url(forResource: "coindetection", withExtension: "mlmodelc")
Implemented by rewriting to the model name generated this time
Is it generally successful? You can do everything from dataset to implementation in about 2 hours, so give it a try!
I used a sample this time, but since it's a big deal, I would like to challenge to make it with Swift UI in the future! In addition, I would like to take on the challenge of creating and implementing data sets related to machine learning, so if you are interested, please check this out as well!
Twitter https://twitter.com/oka_yuuji note https://note.com/oka_yuuji
I'm also a high school faculty member, but I love learning skills and researching! If you have a technical request or research, please contact us by DM below. https://twitter.com/oka_yuuji
Recommended Posts