From a493c84cd0f97d559b9043f181a28f84c71968d5 Mon Sep 17 00:00:00 2001 From: hukang hwx963878 Date: Thu, 4 Mar 2021 09:27:47 +0800 Subject: [PATCH] petclassification add english language --- .../src/main/cpp/ImageMindSporeNetnative.cpp | 428 +---------------- .../app/src/main/cpp/MindSporeNetnative.cpp | 7 +- .../gallery/classify/CompareSizesByArea.java | 1 - .../gallery/classify/ImageTrackingMobile.java | 1 - .../gallery/classify/TrackingMobile.java | 1 - .../widget/AutoFitTextureView.java | 1 - .../widget/CameraActivity.java | 11 +- .../widget/CameraFragment.java | 1 - .../widget/MainActivity.java | 35 +- .../widget/OnBackgroundImageListener.java | 18 +- .../widget/RecyclerViewAdapter.java | 6 +- .../src/main/res/layout/activity_camera.xml | 5 +- .../app/src/main/res/layout/activity_main.xml | 14 +- .../app/src/main/res/values-en/strings.xml | 437 +++++++++++++++++ .../app/src/main/res/values-zh/strings.xml | 441 +++++++++++++++++ .../app/src/main/res/values/strings.xml | 443 +++++++++++++++++- 16 files changed, 1361 insertions(+), 489 deletions(-) create mode 100644 model_zoo/official/lite/pet_classification/app/src/main/res/values-en/strings.xml create mode 100644 model_zoo/official/lite/pet_classification/app/src/main/res/values-zh/strings.xml diff --git a/model_zoo/official/lite/pet_classification/app/src/main/cpp/ImageMindSporeNetnative.cpp b/model_zoo/official/lite/pet_classification/app/src/main/cpp/ImageMindSporeNetnative.cpp index 4c89c263427..7d8629a2cf9 100644 --- a/model_zoo/official/lite/pet_classification/app/src/main/cpp/ImageMindSporeNetnative.cpp +++ b/model_zoo/official/lite/pet_classification/app/src/main/cpp/ImageMindSporeNetnative.cpp @@ -38,417 +38,6 @@ using mindspore::dataset::LDataType; static const int RET_CATEGORY_SUM = 410; -static const char *labels_name_map[RET_CATEGORY_SUM] = { - "Herd", - "Safari", - "Bangle", - "Cushion", - "Countertop", - "Prom", - "Branch", - "Sports", - "Sky", - "Community", - "Wheel", - "Cola", - "Tuxedo", - "Flowerpot", - "Team", - "Computer", - "Unicycle", - "Brig", - "Aerospace engineering", - "Scuba diving", - "Goggles", - "Fruit", - "Badminton", - "Horse", - "Sunglasses", - "Fun", - "Prairie", - "Poster", - "Flag", - "Speedboat", - "Eyelash", - "Veil", - "Mobile phone", - "Wheelbarrow", - "Saucer", - "Leather", - "Drawer", - "Paper", - "Pier", - "Waterfowl", - "Tights", - "Rickshaw", - "Vegetable", - "Handrail", - "Ice", - "Metal", - "Flower", - "Wing", - "Silverware", - "Event", - "Skyline", - "Money", - "Comics", - "Handbag", - "Porcelain", - "Rodeo", - "Curtain", - "Tile", - "Human mouth", - "Army", - "Menu", - "Boat", - "Snowboarding", - "Cairn terrier", - "Net", - "Pasteles", - "Cup", - "Rugby", - "Pho", - "Cap", - "Human hair", - "Surfing", - "Loveseat", - "Museum", - "Shipwreck", - "Trunk (Tree)", - "Plush", - "Monochrome", - "Volcano", - "Rock", - "Pillow", - "Presentation", - "Nebula", - "Subwoofer", - "Lake", - "Sledding", - "Bangs", - "Tablecloth", - "Necklace", - "Swimwear", - "Standing", - "Jeans", - "Carnival", - "Softball", - "Centrepiece", - "Skateboarder", - "Cake", - "Dragon", - "Aurora", - "Skiing", - "Bathroom", - "Dog", - "Needlework", - "Umbrella", - "Church", - "Fire", - "Piano", - "Denim", - "Bridle", - "Cabinetry", - "Lipstick", - "Ring", - "Television", - "Roller", - "Seal", - "Concert", - "Product", - "News", - "Fast food", - "Horn (Animal)", - "Tattoo", - "Bird", - "Bridegroom", - "Love", - "Helmet", - "Dinosaur", - "Icing", - "Miniature", - "Tire", - "Toy", - "Icicle", - "Jacket", - "Coffee", - "Mosque", - "Rowing", - "Wetsuit", - "Camping", - "Underwater", - "Christmas", - "Gelato", - "Whiteboard", - "Field", - "Ragdoll", - "Construction", - "Lampshade", - "Palace", - "Meal", - "Factory", - "Cage", - "Clipper (Boat)", - "Gymnastics", - "Turtle", - "Human foot", - "Marriage", - "Web page", - "Human beard", - "Fog", - "Wool", - "Cappuccino", - "Lighthouse", - "Lego", - "Sparkler", - "Sari", - "Model", - "Temple", - "Beanie", - "Building", - "Waterfall", - "Penguin", - "Cave", - "Stadium", - "Smile", - "Human hand", - "Park", - "Desk", - "Shetland sheepdog", - "Bar", - "Eating", - "Neon", - "Dalmatian", - "Crocodile", - "Wakeboarding", - "Longboard", - "Road", - "Race", - "Kitchen", - "Odometer", - "Cliff", - "Fiction", - "School", - "Interaction", - "Bullfighting", - "Boxer", - "Gown", - "Aquarium", - "Superhero", - "Pie", - "Asphalt", - "Surfboard", - "Cheeseburger", - "Screenshot", - "Supper", - "Laugh", - "Lunch", - "Party ", - "Glacier", - "Bench", - "Grandparent", - "Sink", - "Pomacentridae", - "Blazer", - "Brick", - "Space", - "Backpacking", - "Stuffed toy", - "Sushi", - "Glitter", - "Bonfire", - "Castle", - "Marathon", - "Pizza", - "Beach", - "Human ear", - "Racing", - "Sitting", - "Iceberg", - "Shelf", - "Vehicle", - "Pop music", - "Playground", - "Clown", - "Car", - "Rein", - "Fur", - "Musician", - "Casino", - "Baby", - "Alcohol", - "Strap", - "Reef", - "Balloon", - "Outerwear", - "Cathedral", - "Competition", - "Joker", - "Blackboard", - "Bunk bed", - "Bear", - "Moon", - "Archery", - "Polo", - "River", - "Fishing", - "Ferris wheel", - "Mortarboard", - "Bracelet", - "Flesh", - "Statue", - "Farm", - "Desert", - "Chain", - "Aircraft", - "Textile", - "Hot dog", - "Knitting", - "Singer", - "Juice", - "Circus", - "Chair", - "Musical instrument", - "Room", - "Crochet", - "Sailboat", - "Newspaper", - "Santa Claus", - "Swamp", - "Skyscraper", - "Skin", - "Rocket", - "Aviation", - "Airliner", - "Garden", - "Ruins", - "Storm", - "Glasses", - "Balance", - "Nail (Body part)", - "Rainbow", - "Soil ", - "Vacation ", - "Moustache", - "Doily", - "Food", - "Bride ", - "Cattle", - "Pocket", - "Infrastructure", - "Train", - "Gerbil", - "Fireworks", - "Pet", - "Dam", - "Crew", - "Couch", - "Bathing", - "Quilting", - "Motorcycle", - "Butterfly", - "Sled", - "Watercolor paint", - "Rafting", - "Monument", - "Lightning", - "Sunset", - "Bumper", - "Shoe", - "Waterskiing", - "Sneakers", - "Tower", - "Insect", - "Pool", - "Placemat", - "Airplane", - "Plant", - "Jungle", - "Armrest", - "Duck", - "Dress", - "Tableware", - "Petal", - "Bus", - "Hanukkah", - "Forest", - "Hat", - "Barn", - "Tubing", - "Snorkeling", - "Cool", - "Cookware and bakeware", - "Cycling", - "Swing (Seat)", - "Muscle", - "Cat", - "Skateboard", - "Star", - "Toe", - "Junk", - "Bicycle", - "Bedroom", - "Person", - "Sand", - "Canyon", - "Tie", - "Twig", - "Sphynx", - "Supervillain", - "Nightclub", - "Ranch", - "Pattern", - "Shorts", - "Himalayan", - "Wall", - "Leggings", - "Windsurfing", - "Deejay", - "Dance", - "Van", - "Bento", - "Sleep", - "Wine", - "Picnic", - "Leisure", - "Dune", - "Crowd", - "Kayak", - "Ballroom", - "Selfie", - "Graduation", - "Frigate", - "Mountain", - "Dude", - "Windshield", - "Skiff", - "Class", - "Scarf", - "Bull", - "Soccer", - "Bag", - "Basset hound", - "Tractor", - "Swimming", - "Running", - "Track", - "Helicopter", - "Pitch", - "Clock", - "Song", - "Jersey", - "Stairs", - "Flap", - "Jewellery", - "Bridge", - "Cuisine", - "Bread", - "Caving", - "Shell", - "Wreath", - "Roof", - "Cookie", - "Canoe"}; static float g_thres_map[RET_CATEGORY_SUM] = { 0.23, 0.03, 0.10, 0.13, 0.03, @@ -548,7 +137,7 @@ char *ImageCreateLocalModelBuffer(JNIEnv *env, jobject modelBuffer) { * @param msOutputs * @return */ -std::string ImageProcessRunnetResult(const int RET_CATEGORY_SUM, const char *const labels_name_map[], +std::string ImageProcessRunnetResult(const int RET_CATEGORY_SUM, std::unordered_map msOutputs) { // Get the branch of the model output. // Use iterators to get map elements. @@ -581,22 +170,18 @@ std::string ImageProcessRunnetResult(const int RET_CATEGORY_SUM, const char *con scores[i] = tmpProb; } - for (int i = 0; i < RET_CATEGORY_SUM; ++i) { - if (scores[i] > 0.5) { - MS_PRINT("MindSpore scores[%d] : [%f]", i, scores[i]); - } - } - // Score for each category. // Converted to text information that needs to be displayed in the APP. std::string categoryScore = ""; for (int i = 0; i < RET_CATEGORY_SUM; ++i) { - categoryScore += labels_name_map[i]; + categoryScore += std::to_string(i); categoryScore += ":"; std::string score_str = std::to_string(scores[i]); categoryScore += score_str; categoryScore += ";"; } + MS_PRINT("categoryScore:%s", categoryScore.c_str()); + return categoryScore; } @@ -788,10 +373,11 @@ Java_com_mindspore_classificationforpet_gallery_classify_ImageTrackingMobile_run msOutputs.insert(std::pair{name, temp_dat}); } - std::string resultStr = ImageProcessRunnetResult(::RET_CATEGORY_SUM, - ::labels_name_map, msOutputs); + std::string resultStr = ImageProcessRunnetResult(::RET_CATEGORY_SUM, msOutputs); + MS_PRINT("resultStr:%s", resultStr.c_str()); const char *resultCharData = resultStr.c_str(); + return (env)->NewStringUTF(resultCharData); } diff --git a/model_zoo/official/lite/pet_classification/app/src/main/cpp/MindSporeNetnative.cpp b/model_zoo/official/lite/pet_classification/app/src/main/cpp/MindSporeNetnative.cpp index 5632d58301e..611856ecc0b 100644 --- a/model_zoo/official/lite/pet_classification/app/src/main/cpp/MindSporeNetnative.cpp +++ b/model_zoo/official/lite/pet_classification/app/src/main/cpp/MindSporeNetnative.cpp @@ -56,7 +56,7 @@ char *CreateLocalModelBuffer(JNIEnv *env, jobject modelBuffer) { * @param msOutputs * @return */ -std::string ProcessRunnetResult(const int RET_CATEGORY_SUM, const char *const labels_name_map[], +std::string ProcessRunnetResult(const int RET_CATEGORY_SUM, std::unordered_map msOutputs) { // Get the branch of the model output. // Use iterators to get map elements. @@ -80,7 +80,7 @@ std::string ProcessRunnetResult(const int RET_CATEGORY_SUM, const char *const la // Score for each category. // Converted to text information that needs to be displayed in the APP. std::string categoryScore = ""; - categoryScore += labels_name_map[maxIndex]; + categoryScore += std::to_string(maxIndex); return categoryScore; } @@ -272,8 +272,7 @@ Java_com_mindspore_classificationforpet_gallery_classify_TrackingMobile_runNet(J msOutputs.insert(std::pair{name, temp_dat}); } - std::string resultStr = ProcessRunnetResult(::RET_PET_DETAILED_SUM, - ::labels_name_pet_detailed_map, msOutputs); + std::string resultStr = ProcessRunnetResult(::RET_PET_DETAILED_SUM, msOutputs); const char *resultCharData = resultStr.c_str(); return (env)->NewStringUTF(resultCharData); diff --git a/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/gallery/classify/CompareSizesByArea.java b/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/gallery/classify/CompareSizesByArea.java index a6c8d0ab866..85511d9b488 100644 --- a/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/gallery/classify/CompareSizesByArea.java +++ b/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/gallery/classify/CompareSizesByArea.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.mindspore.classificationforpet.gallery.classify; import android.util.Size; diff --git a/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/gallery/classify/ImageTrackingMobile.java b/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/gallery/classify/ImageTrackingMobile.java index a65905ca5e2..6fa7a3660e1 100644 --- a/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/gallery/classify/ImageTrackingMobile.java +++ b/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/gallery/classify/ImageTrackingMobile.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.mindspore.classificationforpet.gallery.classify; import android.content.Context; diff --git a/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/gallery/classify/TrackingMobile.java b/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/gallery/classify/TrackingMobile.java index 8c91fe94fc5..81ff9b682bb 100644 --- a/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/gallery/classify/TrackingMobile.java +++ b/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/gallery/classify/TrackingMobile.java @@ -116,7 +116,6 @@ public class TrackingMobile { InputStream is = null; try { is = new FileInputStream(modelPath); -// is = mActivity.getAssets().open(modelPath); byte[] bytes = new byte[is.available()]; is.read(bytes); return ByteBuffer.allocateDirect(bytes.length).put(bytes); diff --git a/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/widget/AutoFitTextureView.java b/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/widget/AutoFitTextureView.java index ee90a9bd66c..45d3f179929 100644 --- a/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/widget/AutoFitTextureView.java +++ b/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/widget/AutoFitTextureView.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.mindspore.classificationforpet.widget; import android.content.Context; diff --git a/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/widget/CameraActivity.java b/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/widget/CameraActivity.java index 7aa59d89e57..9cecf9f2936 100644 --- a/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/widget/CameraActivity.java +++ b/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/widget/CameraActivity.java @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.mindspore.classificationforpet.widget; import android.graphics.Bitmap; import android.os.Bundle; import android.text.TextUtils; import android.util.Log; +import android.view.View; import android.widget.TextView; import androidx.annotation.Nullable; @@ -54,7 +54,6 @@ public class CameraActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - Log.d(TAG, "onCreate"); setContentView(R.layout.activity_camera); filePath = getIntent().getStringExtra("FILEPATH"); @@ -96,7 +95,9 @@ public class CameraActivity extends AppCompatActivity { long startTime = System.currentTimeMillis(); String result = trackingMobile.MindSpore_runnet(bitmap); long endTime = System.currentTimeMillis(); - resultText.setText(TextUtils.isEmpty(result) ? "正在识别..." : result); + String[] IMAGECONTENT = getResources().getStringArray(R.array.image_category_pet); + int nameIndex = Integer.parseInt(result); + resultText.setText(IMAGECONTENT[nameIndex]); Log.d(TAG, "RUNNET CONSUMING:" + (endTime - startTime) + "ms"); Log.d(TAG, "result:" + result); } else { @@ -111,13 +112,15 @@ public class CameraActivity extends AppCompatActivity { long endTime = System.currentTimeMillis(); Log.d(TAG, "RUNNET CONSUMING:" + (endTime - startTime) + "ms"); Log.d(TAG, "result:" + result); + String[] IMAGECONTENT = getResources().getStringArray(R.array.image_category); if (!TextUtils.isEmpty(result)) { String[] resultArray = result.split(";"); for (String singleRecognitionResult : resultArray) { String[] singleResult = singleRecognitionResult.split(":"); + int nameIndex = Integer.parseInt(singleResult[0]); float score = Float.parseFloat(singleResult[1]); if (score > 0.5) { - recognitionObjectBeanList.add(new RecognitionImageBean(singleResult[0], score)); + recognitionObjectBeanList.add(new RecognitionImageBean(IMAGECONTENT[nameIndex], score)); } } Collections.sort(recognitionObjectBeanList, (t1, t2) -> Float.compare(t2.getScore(), t1.getScore())); diff --git a/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/widget/CameraFragment.java b/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/widget/CameraFragment.java index c027e001552..64da7e0902c 100644 --- a/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/widget/CameraFragment.java +++ b/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/widget/CameraFragment.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.mindspore.classificationforpet.widget; import android.annotation.SuppressLint; diff --git a/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/widget/MainActivity.java b/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/widget/MainActivity.java index fb854a53cad..968e3b104b0 100644 --- a/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/widget/MainActivity.java +++ b/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/widget/MainActivity.java @@ -133,21 +133,18 @@ public class MainActivity extends AppCompatActivity implements OnBackgroundImage private void openAppDetails() { AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setMessage("HiMindSpore需要访问 “相机” 和 “外部存储器”,请到 “应用信息 -> 权限” 中授予!"); - builder.setPositiveButton("去手动授权", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - Intent intent = new Intent(); - intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); - intent.addCategory(Intent.CATEGORY_DEFAULT); - intent.setData(Uri.parse("package:" + getPackageName())); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); - intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); - startActivity(intent); - } + builder.setMessage(getString(R.string.app_choose_authority)); + builder.setPositiveButton(getString(R.string.app_choose_authority_manual), (dialog, which) -> { + Intent intent = new Intent(); + intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); + intent.addCategory(Intent.CATEGORY_DEFAULT); + intent.setData(Uri.parse("package:" + getPackageName())); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); + intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); + startActivity(intent); }); - builder.setNegativeButton("取消", null); + builder.setNegativeButton(getString(R.string.app_choose_cancle), null); builder.show(); } @@ -247,8 +244,6 @@ public class MainActivity extends AppCompatActivity implements OnBackgroundImage } catch (FileNotFoundException e) { e.printStackTrace(); } - - } private void initMindspore(Bitmap bitmap) { @@ -265,8 +260,10 @@ public class MainActivity extends AppCompatActivity implements OnBackgroundImage long startTime = System.currentTimeMillis(); String result = trackingMobile.MindSpore_runnet(bitmap); long endTime = System.currentTimeMillis(); + String[] IMAGECONTENT = getResources().getStringArray(R.array.image_category_pet); + int nameIndex = Integer.parseInt(result); progressBar.setVisibility(View.GONE); - textResult.setText(result); + textResult.setText(IMAGECONTENT[nameIndex]); Log.d(TAG, "RUNNET CONSUMING:" + (endTime - startTime) + "ms"); Log.d(TAG, "result:" + result); } else { @@ -289,14 +286,16 @@ public class MainActivity extends AppCompatActivity implements OnBackgroundImage progressBar.setVisibility(View.GONE); Log.d(TAG, "RUNNET CONSUMING:" + (endTime - startTime) + "ms"); Log.d(TAG, "result:" + result); + String[] IMAGECONTENT = getResources().getStringArray(R.array.image_category); if (!TextUtils.isEmpty(result)) { String[] resultArray = result.split(";"); for (String singleRecognitionResult : resultArray) { String[] singleResult = singleRecognitionResult.split(":"); + int nameIndex = Integer.parseInt(singleResult[0]); float score = Float.parseFloat(singleResult[1]); if (score > 0.5) { - recognitionObjectBeanList.add(new RecognitionImageBean(singleResult[0], score)); + recognitionObjectBeanList.add(new RecognitionImageBean(IMAGECONTENT[nameIndex], score)); } } Collections.sort(recognitionObjectBeanList, (t1, t2) -> Float.compare(t2.getScore(), t1.getScore())); diff --git a/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/widget/OnBackgroundImageListener.java b/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/widget/OnBackgroundImageListener.java index a8b416e114e..849ed2dd924 100644 --- a/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/widget/OnBackgroundImageListener.java +++ b/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/widget/OnBackgroundImageListener.java @@ -1,9 +1,21 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.mindspore.classificationforpet.widget; -import android.view.View; - public interface OnBackgroundImageListener { void onBackImageSelected(int position); -// void onImageAdd(View view); } diff --git a/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/widget/RecyclerViewAdapter.java b/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/widget/RecyclerViewAdapter.java index 79f18661fd5..d8fce78924e 100644 --- a/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/widget/RecyclerViewAdapter.java +++ b/model_zoo/official/lite/pet_classification/app/src/main/java/com/mindspore/classificationforpet/widget/RecyclerViewAdapter.java @@ -57,11 +57,7 @@ public class RecyclerViewAdapter extends RecyclerView.Adapter { if (mListener != null) { -// if (IMAGES.length - 1 == position) { -// mListener.onImageAdd(holder.getImageView()); -// } else { - mListener.onBackImageSelected(position); -// } + mListener.onBackImageSelected(position); } }); } diff --git a/model_zoo/official/lite/pet_classification/app/src/main/res/layout/activity_camera.xml b/model_zoo/official/lite/pet_classification/app/src/main/res/layout/activity_camera.xml index 17131c9f180..fc580307f63 100644 --- a/model_zoo/official/lite/pet_classification/app/src/main/res/layout/activity_camera.xml +++ b/model_zoo/official/lite/pet_classification/app/src/main/res/layout/activity_camera.xml @@ -18,7 +18,6 @@ android:background="@android:color/black" tools:context="com.mindspore.classificationforpet.widget.CameraActivity" /> - @@ -47,7 +46,7 @@ android:background="@color/white" android:gravity="center" android:orientation="vertical" - android:text="正在识别..." + android:text="@string/app_result_identifying" android:textColor="@color/black" android:textSize="25sp" /> diff --git a/model_zoo/official/lite/pet_classification/app/src/main/res/layout/activity_main.xml b/model_zoo/official/lite/pet_classification/app/src/main/res/layout/activity_main.xml index 6e45c4b7bb6..7d71eb5a593 100644 --- a/model_zoo/official/lite/pet_classification/app/src/main/res/layout/activity_main.xml +++ b/model_zoo/official/lite/pet_classification/app/src/main/res/layout/activity_main.xml @@ -19,7 +19,7 @@ android:drawablePadding="5dp" android:gravity="center_vertical" android:maxLines="1" - android:text="Pet Classification" + android:text="@string/app_name" android:textColor="#ffffff" android:textSize="20sp" /> @@ -53,7 +53,7 @@ android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:layout_marginTop="20dp" - android:text="Choose an image" + android:text="@string/app_choose_an_image" android:textAllCaps="false" android:textColor="@color/white" android:textSize="20sp" /> @@ -73,7 +73,7 @@ android:background="@color/gray_btn" android:gravity="center" android:onClick="onClickPhoto" - android:text="PHOTO" + android:text="@string/app_photo" android:textAllCaps="false" android:textColor="@color/white" android:textSize="12sp" /> @@ -87,7 +87,7 @@ android:background="@color/gray_btn" android:gravity="center" android:onClick="onClickCamera" - android:text="CAMERA" + android:text="@string/app_camera" android:textAllCaps="false" android:textColor="@color/white" android:textSize="12sp" /> @@ -101,12 +101,10 @@ android:background="@color/gray_btn" android:gravity="center" android:onClick="onClickScene" - android:text="SCAN" + android:text="@string/app_scan" android:textAllCaps="false" android:textColor="@color/white" android:textSize="12sp" /> - - diff --git a/model_zoo/official/lite/pet_classification/app/src/main/res/values-en/strings.xml b/model_zoo/official/lite/pet_classification/app/src/main/res/values-en/strings.xml new file mode 100644 index 00000000000..05aa77be9c0 --- /dev/null +++ b/model_zoo/official/lite/pet_classification/app/src/main/res/values-en/strings.xml @@ -0,0 +1,437 @@ + + + PetClassification + Settings + + This device doesn\'t support Camera2 API. + + The image path you selected is not valid. Please choose again + Sorry, there is no object identified in this picture. Try another picture + + Identifying… + Choose an image + PHOTO + CAMERA + SCAN + Choose a sample + PetClassification needs to access “Camera” and “External Storage”, please use "Application Information -> Permission" to grant authority. + Manually authorize this APP. + Cancel + + Cat + Dog + + + + Herd + Safari + Bangle + Cushion + Countertop + Prom + Branch + Sports + Sky + Community + Wheel + Cola + Tuxedo + Flowerpot + Team + Computer + Unicycle + Brig + Aerospace engineering + Scuba diving + Goggles + Fruit + Badminton + Horse + Sunglasses + Fun + Prairie + Poster + Flag + Speedboat + Eyelash + Veil + Mobile phone + Wheelbarrow + Saucer + Leather + Drawer + Paper + Pier + Waterfowl + Tights + Rickshaw + Vegetable + Handrail + Ice + Metal + Flower + Wing + Silverware + Event + Skyline + Money + Comics + Handbag + Porcelain + Rodeo + Curtain + Tile + Human mouth + Army + Menu + Boat + Snowboarding + Cairn terrier + Net + Pasteles + Cup + Rugby + Pho + Cap + Human hair + Surfing + Loveseat + Museum + Shipwreck + Trunk (Tree) + Plush + Monochrome + Volcano + Rock + Pillow + Presentation + Nebula + Subwoofer + Lake + Sledding + Bangs + Tablecloth + Necklace + Swimwear + Standing + Jeans + Carnival + Softball + Centrepiece + Skateboarder + Cake + Dragon + Aurora + Skiing + Bathroom + Dog + Needlework + Umbrella + Church + Fire + Piano + Denim + Bridle + Cabinetry + Lipstick + Ring + Television + Roller + Seal + Concert + Product + News + Fast food + Horn (Animal) + Tattoo + Bird + Bridegroom + Love + Helmet + Dinosaur + Icing + Miniature + Tire + Toy + Icicle + Jacket + Coffee + Mosque + Rowing + Wetsuit + Camping + Underwater + Christmas + Gelato + Whiteboard + Field + Ragdoll + Construction + Lampshade + Palace + Meal + Factory + Cage + Clipper (Boat) + Gymnastics + Turtle + Human foot + Marriage + Web page + Human beard + Fog + Wool + Cappuccino + Lighthouse + Lego + Sparkler + Sari + Model + Temple + Beanie + Building + Waterfall + Penguin + Cave + Stadium + Smile + Human hand + Park + Desk + Shetland sheepdog + Bar + Eating + Neon + Dalmatian + Crocodile + Wakeboarding + Longboard + Road + Race + Kitchen + Odometer + Cliff + Fiction + School + Interaction + Bullfighting + Boxer + Gown + Aquarium + Superhero + Pie + Asphalt + Surfboard + Cheeseburger + Screenshot + Supper + Laugh + Lunch + Party + Glacier + Bench + Grandparent + Sink + Pomacentridae + Blazer + Brick + Space + Backpacking + Stuffed toy + Sushi + Glitter + Bonfire + Castle + Marathon + Pizza + Beach + Human ear + Racing + Sitting + Iceberg + Shelf + Vehicle + Pop music + Playground + Clown + Car + Rein + Fur + Musician + Casino + Baby + Alcohol + Strap + Reef + Balloon + Outerwear + Cathedral + Competition + Joker + Blackboard + Bunk bed + Bear + Moon + Archery + Polo + River + Fishing + Ferris wheel + Mortarboard + Bracelet + Flesh + Statue + Farm + Desert + Chain + Aircraft + Textile + Hot dog + Knitting + Singer + Juice + Circus + Chair + Musical instrument + Room + Crochet + Sailboat + Newspaper + Santa claus + Swamp + Skyscraper + Skin + Rocket + Aviation + Airliner + Garden + Ruins + Storm + Glasses + Balance + Nail (Body part) + Rainbow + Soil + Vacation + Moustache + Doily + Food + Bride + Cattle + Pocket + Infrastructure + Train + Gerbil + Fireworks + Pet + Dam + Crew + Couch + Bathing + Quilting + Motorcycle + Butterfly + Sled + Watercolor paint + Rafting + Monument + Lightning + Sunset + Bumper + Shoe + Waterskiing + Sneakers + Tower + Insect + Pool + Placemat + Airplane + Plant + Jungle + Armrest + Duck + Dress + Tableware + Petal + Bus + Hanukkah + Forest + Hat + Barn + Tubing + Snorkeling + Cool + Cookware and bakeware + Cycling + Swing (Seat) + Muscle + Cat + Skateboard + Star + Toe + Junk + Bicycle + Bedroom + Person + Sand + Canyon + Tie + Twig + Sphynx + Supervillain + Nightclub + Ranch + Pattern + Shorts + Himalayan + Wall + Leggings + Windsurfing + Deejay + Dance + Van + Bento + Sleep + Wine + Picnic + Leisure + Dune + Crowd + Kayak + Ballroom + Selfie + Graduation + Frigate + Mountain + Dude + Windshield + Skiff + Class + Scarf + Bull + Soccer + Bag + Basset hound + Tractor + Swimming + Running + Track + Helicopter + Pitch + Clock + Song + Jersey + Stairs + Flap + Jewellery + Bridge + Cuisine + Bread + Caving + Shell + Wreath + Roof + Cookie + Canoe + + \ No newline at end of file diff --git a/model_zoo/official/lite/pet_classification/app/src/main/res/values-zh/strings.xml b/model_zoo/official/lite/pet_classification/app/src/main/res/values-zh/strings.xml new file mode 100644 index 00000000000..1fc47435c19 --- /dev/null +++ b/model_zoo/official/lite/pet_classification/app/src/main/res/values-zh/strings.xml @@ -0,0 +1,441 @@ + + + PetClassification + + 设置 + + 此设备不支持Camera2 API. + + 图片路径无效,请换一张图片。 + 抱歉,当前图片没有可识别物体,请更换其他图片试试! + + 正在识别... + 选择一张图片 + 图片 + 相机相机/string> + 预览 + 选择一个案例 + PetClassification需要访问 “相机” 和 “外部存储器”,请到 “应用信息 -> 权限” 中授予! + 去手动授权 + 取消 + + + + + + + + 放牧 + 苹果浏览器 + 手镯 + 坐垫 + 台面 + 舞会 + + 体育 + 天空 + 社区 + + 可乐 + 男士礼服 + 花盆 + 球队 + 电脑 + 独轮车 + 双桅船 + 航空航天工程 + 水肺潜水 + 风镜 + 水果 + 羽毛球 + + 墨镜 + 好玩 + 草原 + 海报 + + 快艇 + 睫毛 + 面纱 + 移动电话 + 独轮车 + + 皮革 + 抽屉 + + 码头 + 水禽 + 紧身衣 + 人力车 + 蔬菜 + 扶手 + + 金属 + + 翅膀 + 银器 + 事件 + 天际线 + + 漫画 + 手提包 + + 竞技者 + 窗帘 + + 人类的嘴巴 + 军队 + 菜单 + + 单板滑雪 + 凯恩狗 + + 粘贴 + 杯子 + 橄榄球 + + + 人的头发 + 冲浪 + 双人沙发 + 博物馆 + 沉船 + + 长毛绒 + 单色 + 火山 + 岩石 + 枕头 + 介绍 + 星云 + 低音炮 + + 雪橇 + 刘海 + 桌布 + 项链 + 游泳衣 + 站立 + 牛仔裤 + 狂欢 + 垒球 + 中心 + 滑板手 + 蛋糕 + + 极光 + 滑雪 + 浴室 + + 针线活 + 雨伞 + 教会 + + 钢琴 + 牛仔布 + + 内阁 + 口红 + + 电视 + 滚筒 + 密封 + 音乐会 + 产品 + 新闻 + 快餐 + 角(动物) + 纹身 + + 新郎 + + 头盔 + 恐龙 + 刨冰 + 微型 + + 玩具 + 冰柱 + 夹克 + 咖啡 + 清真寺 + 划船 + 潜水衣 + 露营 + 水下 + 圣诞 + 格拉托 + 白板 + 领域 + 布偶猫 + 施工 + 灯罩 + + 膳食 + + + 快船(船) + 体操 + + 人脚 + 婚姻 + 网页 + 人胡须 + 多雾路段 + 羊毛 + 卡布奇诺咖啡 + 灯塔 + 乐高 + 火花 + 莎丽 + 模型 + 寺庙 + 豆豆 + 建造 + 瀑布 + 企鹅 + 洞穴 + 体育场 + 微笑 + 人的手 + 公园 + + 设得兰群岛牧羊犬 + 酒吧 + + + 斑点狗 + 鳄鱼 + 滑水 + 长板 + + 种族 + 厨房 + 里程表 + 悬崖 + 小说 + 学校 + 相互作用 + 斗牛 + 义和团 + + 水族馆 + 超级英雄 + 馅饼 + 沥青 + 冲浪板 + 芝士汉堡 + 屏幕截图 + 晚餐 + + 午餐 + 派对 + 冰川 + 长凳 + 祖父母 + 水槽 + 雀鲷科 + 西装外套 + + 空间 + 背包 + 毛绒玩具 + 寿司 + 闪光 + 篝火 + 城堡 + 马拉松 + 比萨 + 海滩 + 人耳 + 赛车 + 坐着 + 冰山 + + 车辆 + 流行音乐 + 操场 + 小丑 + 汽车 + 收紧 + 毛皮 + 音乐家 + 赌场 + 宝宝 + + 背带 + + 气球 + 外套 + 大教堂 + 竞争 + 小丑 + 黑板 + 双层床 + + 月亮 + 射箭 + 马球 + + 钓鱼 + 摩天轮 + 砂浆板 + 手镯 + + 雕像 + 农场 + 沙漠 + + 飞机 + 纺织品 + 热狗 + 针织 + 歌手 + 果汁 + 马戏团 + 椅子 + 乐器 + 房间 + 钩针 + 帆船 + 报纸 + 圣诞老人 + 沼泽 + 摩天大楼 + 皮肤 + 火箭 + 航空 + 客机 + 花园 + 废墟 + 风暴 + 眼镜 + 平衡 + 指甲(身体部位) + 彩虹 + + 假期 + 胡子 + 桌巾 + 餐饮 + 新娘 + + 口袋 + 基础设施 + 培养 + 沙鼠 + 烟花 + 宠物 + + 船员 + 长椅 + 洗澡 + 退出 + 摩托车 + 蝴蝶 + 雪橇 + 水彩颜料 + 漂流 + 纪念碑 + 闪电 + 日落 + 保险杠 + 鞋子 + 滑水 + 球鞋 + + 昆虫 + 游泳池 + 餐垫 + 飞机 + + 丛林 + 扶手 + + 连衣裙 + 餐具 + 花瓣 + 总线 + 光明节 + 森林 + 帽子 + 谷仓 + 管道 + 浮潜 + + 炊具和烤盘 + 循环 + 秋千(座位) + 肌肉 + + 滑板 + + 脚趾 + 垃圾 + 自行车 + 卧室 + + + 峡谷 + 领带 + 枝条 + 加拿大无毛猫 + 超级反派 + 夜店 + 牧场 + 模式 + 短裤 + 喜马拉雅山 + + 绑腿 + 风帆冲浪 + DJ + 舞蹈 + 厢式货车 + 便当 + 睡觉 + 葡萄酒 + 野餐 + 休闲 + 沙丘 + 人群 + 皮艇 + 舞厅 + 自拍 + 毕业 + 护卫舰 + + 男人 + 挡风玻璃 + 小艇 + + 围巾 + 公牛 + 足球 + + 巴吉度猎犬 + 拖拉机 + 游泳的 + 正在运行 + 跟踪 + 直升机 + 沥青 + 时钟 + 歌曲 + 泽西岛 + 楼梯 + 襟翼 + 首饰 + + 美食 + 面包 + 探洞 + 贝壳 + 花圈 + 屋顶 + 曲奇饼 + 独木舟 + + + + \ No newline at end of file diff --git a/model_zoo/official/lite/pet_classification/app/src/main/res/values/strings.xml b/model_zoo/official/lite/pet_classification/app/src/main/res/values/strings.xml index 67ee8c22e94..597396f48f7 100644 --- a/model_zoo/official/lite/pet_classification/app/src/main/res/values/strings.xml +++ b/model_zoo/official/lite/pet_classification/app/src/main/res/values/strings.xml @@ -2,31 +2,438 @@ PetClassification 设置 - This sample needs camera permission. This device doesn\'t support Camera2 API. - 使用的google的camera2demo. - EXAMPLE - Add widget The image path you selected is not valid. Please choose again Sorry, there is no object identified in this picture. Try another picture - TFL Classify - This device doesn\'t support Camera2 API. - GPU does not yet supported quantized models. - Model: - - Quantized_EfficientNet - Float_EfficientNet - Quantized_MobileNet - Float_MobileNet + 正在识别... + Choose an image + PHOTO + CAMERA + SCAN + Choose a sample + PetClassification需要访问 “相机” 和 “外部存储器”,请到 “应用信息 -> 权限” 中授予! + 去手动授权 + 取消 + + + Cat + Dog - Device: - - CPU - GPU - NNAPI + + Herd + Safari + Bangle + Cushion + Countertop + Prom + Branch + Sports + Sky + Community + Wheel + Cola + Tuxedo + Flowerpot + Team + Computer + Unicycle + Brig + Aerospace engineering + Scuba diving + Goggles + Fruit + Badminton + Horse + Sunglasses + Fun + Prairie + Poster + Flag + Speedboat + Eyelash + Veil + Mobile phone + Wheelbarrow + Saucer + Leather + Drawer + Paper + Pier + Waterfowl + Tights + Rickshaw + Vegetable + Handrail + Ice + Metal + Flower + Wing + Silverware + Event + Skyline + Money + Comics + Handbag + Porcelain + Rodeo + Curtain + Tile + Human mouth + Army + Menu + Boat + Snowboarding + Cairn terrier + Net + Pasteles + Cup + Rugby + Pho + Cap + Human hair + Surfing + Loveseat + Museum + Shipwreck + Trunk (Tree) + Plush + Monochrome + Volcano + Rock + Pillow + Presentation + Nebula + Subwoofer + Lake + Sledding + Bangs + Tablecloth + Necklace + Swimwear + Standing + Jeans + Carnival + Softball + Centrepiece + Skateboarder + Cake + Dragon + Aurora + Skiing + Bathroom + Dog + Needlework + Umbrella + Church + Fire + Piano + Denim + Bridle + Cabinetry + Lipstick + Ring + Television + Roller + Seal + Concert + Product + News + Fast food + Horn (Animal) + Tattoo + Bird + Bridegroom + Love + Helmet + Dinosaur + Icing + Miniature + Tire + Toy + Icicle + Jacket + Coffee + Mosque + Rowing + Wetsuit + Camping + Underwater + Christmas + Gelato + Whiteboard + Field + Ragdoll + Construction + Lampshade + Palace + Meal + Factory + Cage + Clipper (Boat) + Gymnastics + Turtle + Human foot + Marriage + Web page + Human beard + Fog + Wool + Cappuccino + Lighthouse + Lego + Sparkler + Sari + Model + Temple + Beanie + Building + Waterfall + Penguin + Cave + Stadium + Smile + Human hand + Park + Desk + Shetland sheepdog + Bar + Eating + Neon + Dalmatian + Crocodile + Wakeboarding + Longboard + Road + Race + Kitchen + Odometer + Cliff + Fiction + School + Interaction + Bullfighting + Boxer + Gown + Aquarium + Superhero + Pie + Asphalt + Surfboard + Cheeseburger + Screenshot + Supper + Laugh + Lunch + Party + Glacier + Bench + Grandparent + Sink + Pomacentridae + Blazer + Brick + Space + Backpacking + Stuffed toy + Sushi + Glitter + Bonfire + Castle + Marathon + Pizza + Beach + Human ear + Racing + Sitting + Iceberg + Shelf + Vehicle + Pop music + Playground + Clown + Car + Rein + Fur + Musician + Casino + Baby + Alcohol + Strap + Reef + Balloon + Outerwear + Cathedral + Competition + Joker + Blackboard + Bunk bed + Bear + Moon + Archery + Polo + River + Fishing + Ferris wheel + Mortarboard + Bracelet + Flesh + Statue + Farm + Desert + Chain + Aircraft + Textile + Hot dog + Knitting + Singer + Juice + Circus + Chair + Musical instrument + Room + Crochet + Sailboat + Newspaper + Santa claus + Swamp + Skyscraper + Skin + Rocket + Aviation + Airliner + Garden + Ruins + Storm + Glasses + Balance + Nail (Body part) + Rainbow + Soil + Vacation + Moustache + Doily + Food + Bride + Cattle + Pocket + Infrastructure + Train + Gerbil + Fireworks + Pet + Dam + Crew + Couch + Bathing + Quilting + Motorcycle + Butterfly + Sled + Watercolor paint + Rafting + Monument + Lightning + Sunset + Bumper + Shoe + Waterskiing + Sneakers + Tower + Insect + Pool + Placemat + Airplane + Plant + Jungle + Armrest + Duck + Dress + Tableware + Petal + Bus + Hanukkah + Forest + Hat + Barn + Tubing + Snorkeling + Cool + Cookware and bakeware + Cycling + Swing (Seat) + Muscle + Cat + Skateboard + Star + Toe + Junk + Bicycle + Bedroom + Person + Sand + Canyon + Tie + Twig + Sphynx + Supervillain + Nightclub + Ranch + Pattern + Shorts + Himalayan + Wall + Leggings + Windsurfing + Deejay + Dance + Van + Bento + Sleep + Wine + Picnic + Leisure + Dune + Crowd + Kayak + Ballroom + Selfie + Graduation + Frigate + Mountain + Dude + Windshield + Skiff + Class + Scarf + Bull + Soccer + Bag + Basset hound + Tractor + Swimming + Running + Track + Helicopter + Pitch + Clock + Song + Jersey + Stairs + Flap + Jewellery + Bridge + Cuisine + Bread + Caving + Shell + Wreath + Roof + Cookie + Canoe + \ No newline at end of file