When putting data into the Watson Visual Recognition Collection, you have to implement the code one by one except for writing the code, which is troublesome. This time, I implemented the code that can train multiple images at once with Java code.
Please refer to the following URL for the installation method. http://qiita.com/hiesiea/items/54e49dabfb5606edb54d#2-jdk%E3%81%AE%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB 2. Install eclipse Install eclipse from the following URL. http://www.eclipse.org/downloads/
Please refer to the following URL for the installation method. http://qiita.com/hiesiea/items/54e49dabfb5606edb54d#3-eclipse%E3%81%AE%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB 3. Create Maven project Create "New"-> "Project"-> "Maven Project" of eclipse.
Create a Visual Recognition service on Bluemix. Log in to Bluemix from the URL below and create a "Catalog"-> "Watson"-> "Visual Recognition" service. https://console.bluemix.net/
After creating the Visual Recognition service, check {api_key} from "Service Credentials"-> "Credentials-1" and make a note of it.
2. When the collection is created, the screen below will be displayed. Make a note of the "collection_id". Also, make sure that "status" is "Available".
Run AddToCollection.java.
Modify the code in AddToCollectionThread.java. Change the {api_key} in the code for this class to the api_key you noted earlier.
Place the image to be uploaded. For images, create a "trainImage" folder directly under the project, create a "image ID name" folder in the "trainImage" folder, and place the image in the "image ID name" folder. This image ID is used to sort by person, so place the same person in the folder with the same image ID name.
PROJECTNAME
|-trainImage
|-IMGID_NAME
|-IMG
|-IMG
For example, the images of "m010469.jpg " and "m010462.jpg " are stored in the folder with the image ID name "female" as shown below.
PROJECTNAME
|-trainMetafile
|-IMGID_NAME
|-IMGID_NAME.json
For example, store the json file named "female.json" in the folder with the image ID name "female" as shown below.
Please refer to the code below when creating a Metafile.
Metafile entry example(femaleA.json)
{"name":"Woman A","img_name":"femaleA","img_url":"https://model.foto.ne.jp/free/product_info.php/cPath/24_252_256/products_id/300378"}
Put the following in the argument and implement. 「./trainImage」
The execution result is as follows.
Check if the training data has been added to the Collection.
Access the following URL, enter the api_key and collection_id that you entered when you implemented AddToCollection.java in "Parameters"-> "api_key" and "collection_id", and click "try it out!". https://watson-api-explorer.mybluemix.net/apis/visual-recognition-v3#!/visual45recognition/get_v3_collections_collection_id_images!
Display the list of images registered in the collection, and if the images registered in "images" of the collection are registered, the training is complete.
Recommended Posts