| @@ -1,5 +1,4 @@ | |||
| apply plugin: 'com.android.application' | |||
| android { | |||
| compileSdkVersion 30 | |||
| buildToolsVersion "30.0.1" | |||
| @@ -8,8 +7,8 @@ android { | |||
| applicationId "com.mindspore.himindspore" | |||
| minSdkVersion 21 | |||
| targetSdkVersion 30 | |||
| versionCode 5 | |||
| versionName "1.1.3" | |||
| versionCode 6 | |||
| versionName "1.1.4" | |||
| testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | |||
| javaCompileOptions { | |||
| @@ -51,7 +50,7 @@ android { | |||
| dependencies { | |||
| implementation fileTree(dir: "libs", include: ["*.jar"]) | |||
| implementation 'androidx.appcompat:appcompat:1.2.0' | |||
| implementation 'androidx.appcompat:appcompat:1.3.0-alpha02' | |||
| implementation 'androidx.constraintlayout:constraintlayout:2.0.4' | |||
| implementation 'androidx.cardview:cardview:1.0.0' | |||
| androidTestImplementation 'androidx.test.ext:junit:1.1.2' | |||
| @@ -18,4 +18,14 @@ | |||
| # If you keep the line number information, uncomment this to | |||
| # hide the original source file name. | |||
| #-renamesourcefileattribute SourceFile | |||
| #-renamesourcefileattribute SourceFile | |||
| -keep class cn.sharesdk.**{*;} | |||
| -keep class com.sina.**{*;} | |||
| -keep class **.R$* {*;} | |||
| -keep class **.R{*;} | |||
| -keep class com.mob.**{*;} | |||
| -keep class m.framework.**{*;} | |||
| -dontwarn cn.sharesdk.** | |||
| -dontwarn com.sina.** | |||
| -dontwarn com.mob.** | |||
| -dontwarn **.R$* | |||
| @@ -17,7 +17,6 @@ package com.mindspore.himindspore; | |||
| import android.Manifest; | |||
| import android.app.ProgressDialog; | |||
| import android.content.DialogInterface; | |||
| import android.content.Intent; | |||
| import android.content.pm.PackageInfo; | |||
| import android.content.pm.PackageManager; | |||
| @@ -62,8 +61,9 @@ public class SplashActivity extends BaseActivity<MainPresenter> implements MainC | |||
| private TextView versionText; | |||
| private static final String CODE_URL = "https://gitee.com/mindspore/mindspore/tree/master/model_zoo/official/lite"; | |||
| private static final String HELP_URL = "https://github.com/mindspore-ai/mindspore/issues"; | |||
| private static final String HELP_URL = "https://gitee.com/mindspore/mindspore/issues/new?issue%5Bassignee_id%5D=0&issue%5Bmilestone_id%5D=0"; | |||
| private static final String STAR_URL = "https://gitee.com/mindspore/mindspore"; | |||
| private static final String APK_URL = "https://download.mindspore.cn/model_zoo/official/lite/apk/mindmain.html"; | |||
| @Override | |||
| @@ -85,7 +85,7 @@ public class SplashActivity extends BaseActivity<MainPresenter> implements MainC | |||
| PackageManager packageManager = this.getPackageManager(); | |||
| PackageInfo packageInfo = packageManager.getPackageInfo(this.getPackageName(), 0); | |||
| now_version = packageInfo.versionCode; | |||
| versionText.setText("Version: " + packageInfo.versionName); | |||
| versionText.setText(getString(R.string.title_version) + packageInfo.versionName); | |||
| } catch (PackageManager.NameNotFoundException e) { | |||
| e.printStackTrace(); | |||
| } | |||
| @@ -134,21 +134,18 @@ public class SplashActivity extends BaseActivity<MainPresenter> implements MainC | |||
| 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(getResources().getString(R.string.app_need_permission)); | |||
| builder.setPositiveButton(getResources().getString(R.string.app_permission_by_hand), (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(getResources().getString(R.string.cancel), null); | |||
| builder.show(); | |||
| } | |||
| @@ -238,6 +235,16 @@ public class SplashActivity extends BaseActivity<MainPresenter> implements MainC | |||
| openBrowser(STAR_URL); | |||
| } | |||
| public void onClickShare(View view) { | |||
| Intent share_intent = new Intent(); | |||
| share_intent.setAction(Intent.ACTION_SEND); | |||
| share_intent.setType("text/plain"); | |||
| share_intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.title_share)); | |||
| share_intent.putExtra(Intent.EXTRA_TEXT, getString(R.string.title_share_commend) + APK_URL); | |||
| share_intent = Intent.createChooser(share_intent, getString(R.string.title_share)); | |||
| startActivity(share_intent); | |||
| } | |||
| public void openBrowser(String url) { | |||
| Intent intent = new Intent(); | |||
| intent.setAction("android.intent.action.VIEW"); | |||
| @@ -262,55 +269,40 @@ public class SplashActivity extends BaseActivity<MainPresenter> implements MainC | |||
| } | |||
| AlertDialog.Builder builder = new AlertDialog.Builder(this); | |||
| builder.setIcon(android.R.drawable.ic_dialog_info); | |||
| builder.setTitle("下载完成"); | |||
| builder.setMessage("是否安装"); | |||
| builder.setTitle(getResources().getString(R.string.app_download_success)); | |||
| builder.setMessage(getResources().getString(R.string.app_need_install)); | |||
| builder.setCancelable(false); | |||
| builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { | |||
| @Override | |||
| public void onClick(DialogInterface dialog, int which) { | |||
| Intent intent = new Intent(Intent.ACTION_VIEW); | |||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | |||
| intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | |||
| Uri contentUri = FileProvider.getUriForFile(SplashActivity.this, "com.mindspore.himindspore.fileprovider", | |||
| new File(getApkPath(), "HiMindSpore.apk")); | |||
| intent.setDataAndType(contentUri, "application/vnd.android.package-archive"); | |||
| } else { | |||
| intent.setDataAndType(Uri.fromFile(new File(getApkPath(), "HiMindSpore.apk")), "application/vnd.android.package-archive"); | |||
| intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |||
| } | |||
| startActivity(intent); | |||
| builder.setPositiveButton(getResources().getString(R.string.confirm), (dialog, which) -> { | |||
| Intent intent = new Intent(Intent.ACTION_VIEW); | |||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | |||
| intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | |||
| Uri contentUri = FileProvider.getUriForFile(SplashActivity.this, "com.mindspore.himindspore.fileprovider", | |||
| new File(getApkPath(), "HiMindSpore.apk")); | |||
| intent.setDataAndType(contentUri, "application/vnd.android.package-archive"); | |||
| } else { | |||
| intent.setDataAndType(Uri.fromFile(new File(getApkPath(), "HiMindSpore.apk")), "application/vnd.android.package-archive"); | |||
| intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |||
| } | |||
| startActivity(intent); | |||
| }); | |||
| builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { | |||
| @Override | |||
| public void onClick(DialogInterface dialog, int which) { | |||
| } | |||
| builder.setNegativeButton(getResources().getString(R.string.cancel), (dialog, which) -> { | |||
| }); | |||
| builder.create().show(); | |||
| } | |||
| public void showUpdate(final UpdateInfoBean updateInfo) { | |||
| if (now_version == updateInfo.getVersionCode()) { | |||
| // Toast.makeText(this, "已经是最新版本", Toast.LENGTH_SHORT).show(); | |||
| Log.d(TAG + "版本号是", "onResponse: " + now_version); | |||
| } else { | |||
| if (now_version != updateInfo.getVersionCode()) { | |||
| AlertDialog.Builder builder = new AlertDialog.Builder(this); | |||
| builder.setIcon(android.R.drawable.ic_dialog_info); | |||
| builder.setTitle("请升级新版本" + updateInfo.getVersionName()); | |||
| builder.setTitle(getResources().getString(R.string.app_update_lastest) + updateInfo.getVersionName()); | |||
| builder.setMessage(updateInfo.getMessage()); | |||
| builder.setCancelable(false); | |||
| builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { | |||
| @Override | |||
| public void onClick(DialogInterface dialog, int which) { | |||
| Log.e(TAG, String.valueOf(Environment.MEDIA_MOUNTED)); | |||
| downFile(); | |||
| } | |||
| builder.setPositiveButton(getResources().getString(R.string.confirm), (dialog, which) -> { | |||
| Log.e(TAG, String.valueOf(Environment.MEDIA_MOUNTED)); | |||
| downFile(); | |||
| }); | |||
| builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { | |||
| @Override | |||
| public void onClick(DialogInterface dialog, int which) { | |||
| } | |||
| builder.setNegativeButton(getResources().getString(R.string.cancel), (dialog, which) -> { | |||
| }); | |||
| builder.create().show(); | |||
| } | |||
| @@ -319,8 +311,8 @@ public class SplashActivity extends BaseActivity<MainPresenter> implements MainC | |||
| public void downFile() { | |||
| progressDialog = new ProgressDialog(this); | |||
| progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); | |||
| progressDialog.setTitle("正在下载"); | |||
| progressDialog.setMessage("请稍候..."); | |||
| progressDialog.setTitle(getResources().getString(R.string.app_is_loading)); | |||
| progressDialog.setMessage(getResources().getString(R.string.app_wait)); | |||
| progressDialog.setProgressNumberFormat("%1d Mb/%2d Mb"); | |||
| progressDialog.setProgress(0); | |||
| progressDialog.show(); | |||
| @@ -332,7 +324,7 @@ public class SplashActivity extends BaseActivity<MainPresenter> implements MainC | |||
| @Override | |||
| public void onDownLoadFail(Throwable throwable) { | |||
| Toast.makeText(SplashActivity.this, "下载失败", Toast.LENGTH_LONG).show(); | |||
| Toast.makeText(SplashActivity.this, getResources().getString(R.string.app_load_fail), Toast.LENGTH_LONG).show(); | |||
| } | |||
| @Override | |||
| @@ -358,7 +350,6 @@ public class SplashActivity extends BaseActivity<MainPresenter> implements MainC | |||
| directoryPath = getFilesDir() + File.separator + "apk"; | |||
| } | |||
| File file = new File(directoryPath); | |||
| Log.e("测试路径", directoryPath); | |||
| if (!file.exists()) { | |||
| file.mkdirs(); | |||
| } | |||
| @@ -366,5 +357,4 @@ public class SplashActivity extends BaseActivity<MainPresenter> implements MainC | |||
| } | |||
| } | |||
| @@ -22,6 +22,10 @@ import com.alibaba.android.arouter.launcher.ARouter; | |||
| public class MyApplication extends Application { | |||
| private static final String appKey = "31f0c1ffe8168"; | |||
| private static final String appSecret = "83e393ced2b9f31771fcb81e1b7a049a"; | |||
| @Override | |||
| public void onCreate() { | |||
| super.onCreate(); | |||
| @@ -7,13 +7,22 @@ | |||
| android:background="@color/colorPrimary" | |||
| tools:context=".SplashActivity"> | |||
| <ImageView | |||
| android:id="@+id/shareImg" | |||
| android:layout_width="25dp" | |||
| android:layout_height="25dp" | |||
| android:layout_margin="20dp" | |||
| android:onClick="onClickShare" | |||
| android:src="@drawable/share" | |||
| app:layout_constraintEnd_toEndOf="parent" | |||
| app:layout_constraintTop_toTopOf="parent" /> | |||
| <TextView | |||
| android:id="@+id/title" | |||
| android:layout_width="0dp" | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginTop="68dp" | |||
| android:drawablePadding="20dp" | |||
| android:layout_marginTop="50dp" | |||
| android:drawableTop="@drawable/logo" | |||
| android:gravity="center_horizontal" | |||
| android:maxLines="1" | |||
| android:text="@string/app_name" | |||
| @@ -22,214 +31,13 @@ | |||
| app:layout_constraintEnd_toEndOf="parent" | |||
| app:layout_constraintHorizontal_bias="0.0" | |||
| app:layout_constraintStart_toStartOf="parent" | |||
| app:layout_constraintTop_toTopOf="parent" | |||
| android:drawableTop="@drawable/logo" | |||
| /> | |||
| <Button | |||
| android:id="@+id/btn_image" | |||
| android:layout_width="0dp" | |||
| android:layout_height="48dp" | |||
| android:layout_marginStart="20dp" | |||
| android:layout_marginTop="30dp" | |||
| android:background="@color/gray_btn" | |||
| android:drawableStart="@drawable/btn_image" | |||
| android:drawablePadding="5dp" | |||
| android:gravity="left|center_vertical" | |||
| android:onClick="onClickImage" | |||
| android:paddingStart="4dp" | |||
| android:text="@string/title_image" | |||
| android:textAllCaps="false" | |||
| android:textSize="12sp" | |||
| app:layout_constraintStart_toStartOf="parent" | |||
| app:layout_constraintTop_toBottomOf="@+id/title" | |||
| app:layout_constraintWidth_percent="0.43" | |||
| tools:ignore="RtlHardcoded,RtlSymmetry" /> | |||
| <Button | |||
| android:id="@+id/btn_image_garbage" | |||
| android:layout_width="0dp" | |||
| android:layout_height="48dp" | |||
| android:layout_marginEnd="20dp" | |||
| android:background="@color/gray_btn" | |||
| android:drawableStart="@drawable/btn_other" | |||
| android:drawablePadding="5dp" | |||
| android:gravity="left|center_vertical" | |||
| android:onClick="onClickGarbage" | |||
| android:paddingLeft="4dp" | |||
| android:text="@string/title_image_garbage" | |||
| android:textAllCaps="false" | |||
| android:textSize="12sp" | |||
| app:layout_constraintBottom_toBottomOf="@+id/btn_image" | |||
| app:layout_constraintEnd_toEndOf="parent" | |||
| app:layout_constraintWidth_percent="0.43" /> | |||
| <Button | |||
| android:id="@+id/btn_object" | |||
| android:layout_width="0dp" | |||
| android:layout_height="48dp" | |||
| android:layout_marginTop="16dp" | |||
| android:background="@color/gray_btn" | |||
| android:drawableStart="@drawable/btn_text" | |||
| android:drawablePadding="5dp" | |||
| android:gravity="left|center_vertical" | |||
| android:onClick="onClickPhotoDetection" | |||
| android:paddingLeft="4dp" | |||
| android:text="@string/title_object" | |||
| android:textAllCaps="false" | |||
| android:textSize="12sp" | |||
| app:layout_constraintStart_toStartOf="@+id/btn_image" | |||
| app:layout_constraintTop_toBottomOf="@+id/btn_image" | |||
| app:layout_constraintWidth_percent="0.43" /> | |||
| <Button | |||
| android:id="@+id/btn_object_camera" | |||
| android:layout_width="0dp" | |||
| android:layout_height="48dp" | |||
| android:background="@color/gray_btn" | |||
| android:drawableStart="@drawable/btn_object" | |||
| android:drawablePadding="5dp" | |||
| android:gravity="left|center_vertical" | |||
| android:onClick="onClickCameraDetection" | |||
| android:paddingLeft="4dp" | |||
| android:text="@string/title_object_camera" | |||
| android:textAllCaps="false" | |||
| android:textSize="12sp" | |||
| app:layout_constraintBottom_toBottomOf="@+id/btn_object" | |||
| app:layout_constraintEnd_toEndOf="@+id/btn_image_garbage" | |||
| app:layout_constraintWidth_percent="0.43" /> | |||
| <Button | |||
| android:id="@+id/btn_posenet" | |||
| android:layout_width="0dp" | |||
| android:layout_height="48dp" | |||
| android:layout_marginTop="16dp" | |||
| android:background="@color/gray_btn" | |||
| android:drawableStart="@drawable/btn_audio" | |||
| android:drawablePadding="5dp" | |||
| android:gravity="left|center_vertical" | |||
| android:onClick="onClickPoseNet" | |||
| android:paddingLeft="4dp" | |||
| android:text="@string/title_pose_net" | |||
| android:textAllCaps="false" | |||
| android:textSize="12sp" | |||
| app:layout_constraintStart_toStartOf="@+id/btn_object" | |||
| app:layout_constraintTop_toBottomOf="@+id/btn_object" | |||
| app:layout_constraintWidth_percent="0.43" /> | |||
| <Button | |||
| android:id="@+id/btn_style_transfer" | |||
| android:layout_width="0dp" | |||
| android:layout_height="48dp" | |||
| android:background="@color/gray_btn" | |||
| android:drawableStart="@drawable/btn_commend" | |||
| android:drawablePadding="5dp" | |||
| android:gravity="left|center_vertical" | |||
| android:onClick="onClickStyleTransfer" | |||
| android:paddingLeft="4dp" | |||
| android:text="@string/title_style_transfer" | |||
| android:textAllCaps="false" | |||
| android:textSize="12sp" | |||
| app:layout_constraintBottom_toBottomOf="@+id/btn_posenet" | |||
| app:layout_constraintEnd_toEndOf="@+id/btn_image_garbage" | |||
| app:layout_constraintWidth_percent="0.43" /> | |||
| <Button | |||
| android:layout_marginTop="16dp" | |||
| android:id="@+id/btn_segmentation" | |||
| android:layout_width="0dp" | |||
| android:layout_height="48dp" | |||
| android:background="@color/gray_btn" | |||
| android:drawableStart="@drawable/btn_image" | |||
| android:drawablePadding="5dp" | |||
| android:gravity="left|center_vertical" | |||
| android:onClick="onClickSegmentation" | |||
| android:paddingLeft="4dp" | |||
| android:text="@string/title_segmentation" | |||
| android:textAllCaps="false" | |||
| android:textSize="12sp" | |||
| app:layout_constraintStart_toStartOf="@+id/btn_posenet" | |||
| app:layout_constraintTop_toBottomOf="@+id/btn_posenet" | |||
| app:layout_constraintWidth_percent="0.43" /> | |||
| <Button | |||
| android:id="@+id/btn_scene" | |||
| android:layout_width="0dp" | |||
| android:layout_height="48dp" | |||
| android:background="@color/gray_btn" | |||
| android:drawableStart="@drawable/btn_code" | |||
| android:drawablePadding="5dp" | |||
| android:gravity="left|center_vertical" | |||
| android:onClick="onClickSceneDetection" | |||
| android:paddingLeft="4dp" | |||
| android:text="@string/title_scene" | |||
| android:textAllCaps="false" | |||
| android:textSize="12sp" | |||
| app:layout_constraintBottom_toBottomOf="@+id/btn_segmentation" | |||
| app:layout_constraintEnd_toEndOf="@+id/btn_image_garbage" | |||
| app:layout_constraintWidth_percent="0.43" /> | |||
| <Button | |||
| android:layout_marginTop="16dp" | |||
| android:id="@+id/btn_source" | |||
| android:layout_width="0dp" | |||
| android:layout_height="48dp" | |||
| android:background="@color/gray_light_btn" | |||
| android:drawableStart="@drawable/btn_code" | |||
| android:drawablePadding="8dp" | |||
| android:gravity="left|center_vertical" | |||
| android:onClick="onClickSouceCode" | |||
| android:paddingStart="10dp" | |||
| android:text="@string/title_source" | |||
| android:textAllCaps="false" | |||
| android:textSize="12sp" | |||
| app:layout_constraintStart_toStartOf="@+id/btn_segmentation" | |||
| app:layout_constraintTop_toBottomOf="@+id/btn_segmentation" | |||
| app:layout_constraintWidth_percent="0.28" /> | |||
| <Button | |||
| android:layout_marginStart="10dp" | |||
| android:id="@+id/btn_star" | |||
| android:layout_width="0dp" | |||
| android:layout_height="48dp" | |||
| android:background="@color/gray_light_btn" | |||
| android:drawableStart="@drawable/btn_commend" | |||
| android:drawablePadding="8dp" | |||
| android:gravity="left|center_vertical" | |||
| android:onClick="onClickStar" | |||
| android:paddingStart="10dp" | |||
| android:text="@string/title_star" | |||
| android:textAllCaps="false" | |||
| android:textSize="12sp" | |||
| app:layout_constraintEnd_toEndOf="@+id/btn_scene" | |||
| app:layout_constraintBottom_toBottomOf="@+id/btn_source" | |||
| app:layout_constraintWidth_percent="0.28" /> | |||
| <Button | |||
| android:id="@+id/btn_help" | |||
| android:layout_width="0dp" | |||
| android:layout_height="48dp" | |||
| android:layout_marginTop="16dp" | |||
| android:background="@color/gray_light_btn" | |||
| android:drawableStart="@drawable/btn_help" | |||
| android:drawablePadding="8dp" | |||
| android:gravity="left|center_vertical" | |||
| android:onClick="onClickHelp" | |||
| android:paddingStart="10dp" | |||
| android:text="@string/title_help" | |||
| android:textAllCaps="false" | |||
| android:textSize="12sp" | |||
| app:layout_constraintStart_toEndOf="@+id/btn_source" | |||
| app:layout_constraintBottom_toBottomOf="@+id/btn_source" | |||
| app:layout_constraintEnd_toStartOf="@+id/btn_star" | |||
| app:layout_constraintWidth_percent="0.28" /> | |||
| app:layout_constraintTop_toTopOf="parent" /> | |||
| <TextView | |||
| android:id="@+id/tv_vision" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginBottom="30dp" | |||
| android:layout_marginBottom="20dp" | |||
| android:textColor="@color/white" | |||
| android:textSize="20sp" | |||
| app:layout_constraintBottom_toBottomOf="parent" | |||
| @@ -237,4 +45,220 @@ | |||
| app:layout_constraintStart_toStartOf="parent" | |||
| tools:text="Version 1.0.0" /> | |||
| <ScrollView | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| app:layout_constraintBottom_toTopOf="@+id/tv_vision" | |||
| app:layout_constraintTop_toBottomOf="@+id/title"> | |||
| <androidx.constraintlayout.widget.ConstraintLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="match_parent" | |||
| android:layout_marginTop="30dp" | |||
| android:layout_marginBottom="30dp" | |||
| android:orientation="vertical"> | |||
| <Button | |||
| android:id="@+id/btn_object" | |||
| android:layout_width="0dp" | |||
| android:layout_height="48dp" | |||
| android:layout_marginStart="20dp" | |||
| android:layout_marginTop="16dp" | |||
| android:background="@color/gray_btn" | |||
| android:drawableStart="@drawable/btn_text" | |||
| android:drawablePadding="5dp" | |||
| android:gravity="left|center_vertical" | |||
| android:onClick="onClickPhotoDetection" | |||
| android:paddingLeft="4dp" | |||
| android:text="@string/title_object" | |||
| android:textAllCaps="false" | |||
| android:textSize="12sp" | |||
| app:layout_constraintStart_toStartOf="parent" | |||
| app:layout_constraintWidth_percent="0.43" /> | |||
| <Button | |||
| android:layout_marginEnd="20dp" | |||
| android:id="@+id/btn_object_camera" | |||
| android:layout_width="0dp" | |||
| android:layout_height="48dp" | |||
| android:background="@color/gray_btn" | |||
| android:drawableStart="@drawable/btn_object" | |||
| android:drawablePadding="5dp" | |||
| android:gravity="left|center_vertical" | |||
| android:onClick="onClickCameraDetection" | |||
| android:paddingLeft="4dp" | |||
| android:text="@string/title_object_camera" | |||
| android:textAllCaps="false" | |||
| android:textSize="12sp" | |||
| app:layout_constraintBottom_toBottomOf="@+id/btn_object" | |||
| app:layout_constraintEnd_toEndOf="parent" | |||
| app:layout_constraintWidth_percent="0.43" /> | |||
| <Button | |||
| android:id="@+id/btn_posenet" | |||
| android:layout_width="0dp" | |||
| android:layout_height="48dp" | |||
| android:layout_marginTop="16dp" | |||
| android:background="@color/gray_btn" | |||
| android:drawableStart="@drawable/btn_audio" | |||
| android:drawablePadding="5dp" | |||
| android:gravity="left|center_vertical" | |||
| android:onClick="onClickPoseNet" | |||
| android:paddingLeft="4dp" | |||
| android:text="@string/title_pose_net" | |||
| android:textAllCaps="false" | |||
| android:textSize="12sp" | |||
| app:layout_constraintStart_toStartOf="@+id/btn_object" | |||
| app:layout_constraintTop_toBottomOf="@+id/btn_object" | |||
| app:layout_constraintWidth_percent="0.43" /> | |||
| <Button | |||
| android:id="@+id/btn_style_transfer" | |||
| android:layout_width="0dp" | |||
| android:layout_height="48dp" | |||
| android:background="@color/gray_btn" | |||
| android:drawableStart="@drawable/btn_commend" | |||
| android:drawablePadding="5dp" | |||
| android:gravity="left|center_vertical" | |||
| android:onClick="onClickStyleTransfer" | |||
| android:paddingLeft="4dp" | |||
| android:text="@string/title_style_transfer" | |||
| android:textAllCaps="false" | |||
| android:textSize="12sp" | |||
| app:layout_constraintBottom_toBottomOf="@+id/btn_posenet" | |||
| app:layout_constraintEnd_toEndOf="@+id/btn_object_camera" | |||
| app:layout_constraintWidth_percent="0.43" /> | |||
| <Button | |||
| android:id="@+id/btn_segmentation" | |||
| android:layout_width="0dp" | |||
| android:layout_height="48dp" | |||
| android:layout_marginTop="16dp" | |||
| android:background="@color/gray_btn" | |||
| android:drawableStart="@drawable/btn_image" | |||
| android:drawablePadding="5dp" | |||
| android:gravity="left|center_vertical" | |||
| android:onClick="onClickSegmentation" | |||
| android:paddingLeft="4dp" | |||
| android:text="@string/title_segmentation" | |||
| android:textAllCaps="false" | |||
| android:textSize="12sp" | |||
| app:layout_constraintStart_toStartOf="@+id/btn_posenet" | |||
| app:layout_constraintTop_toBottomOf="@+id/btn_posenet" | |||
| app:layout_constraintWidth_percent="0.43" /> | |||
| <Button | |||
| android:id="@+id/btn_image" | |||
| android:layout_width="0dp" | |||
| android:layout_height="48dp" | |||
| android:layout_marginTop="30dp" | |||
| android:background="@color/gray_btn" | |||
| android:drawableStart="@drawable/btn_image" | |||
| android:drawablePadding="5dp" | |||
| android:gravity="left|center_vertical" | |||
| android:onClick="onClickImage" | |||
| android:paddingStart="4dp" | |||
| android:text="@string/title_image" | |||
| android:textAllCaps="false" | |||
| android:textSize="12sp" | |||
| app:layout_constraintBottom_toBottomOf="@+id/btn_segmentation" | |||
| app:layout_constraintEnd_toEndOf="@+id/btn_style_transfer" | |||
| app:layout_constraintWidth_percent="0.43" /> | |||
| <Button | |||
| android:id="@+id/btn_image_garbage" | |||
| android:layout_width="0dp" | |||
| android:layout_height="48dp" | |||
| android:layout_marginTop="16dp" | |||
| android:background="@color/gray_btn" | |||
| android:drawableStart="@drawable/btn_other" | |||
| android:drawablePadding="5dp" | |||
| android:gravity="left|center_vertical" | |||
| android:onClick="onClickGarbage" | |||
| android:paddingLeft="4dp" | |||
| android:text="@string/title_image_garbage" | |||
| android:textAllCaps="false" | |||
| android:textSize="12sp" | |||
| app:layout_constraintStart_toStartOf="@+id/btn_segmentation" | |||
| app:layout_constraintTop_toBottomOf="@+id/btn_segmentation" | |||
| app:layout_constraintWidth_percent="0.43" /> | |||
| <Button | |||
| android:id="@+id/btn_scene" | |||
| android:layout_width="0dp" | |||
| android:layout_height="48dp" | |||
| android:background="@color/gray_btn" | |||
| android:drawableStart="@drawable/btn_code" | |||
| android:drawablePadding="5dp" | |||
| android:gravity="left|center_vertical" | |||
| android:onClick="onClickSceneDetection" | |||
| android:paddingLeft="4dp" | |||
| android:text="@string/title_scene" | |||
| android:textAllCaps="false" | |||
| android:textSize="12sp" | |||
| app:layout_constraintBottom_toBottomOf="@+id/btn_image_garbage" | |||
| app:layout_constraintEnd_toEndOf="@+id/btn_image" | |||
| app:layout_constraintWidth_percent="0.43" /> | |||
| <Button | |||
| android:id="@+id/btn_source" | |||
| android:layout_width="0dp" | |||
| android:layout_height="48dp" | |||
| android:layout_marginTop="16dp" | |||
| android:background="@color/gray_light_btn" | |||
| android:drawableStart="@drawable/btn_code" | |||
| android:drawablePadding="8dp" | |||
| android:gravity="left|center_vertical" | |||
| android:onClick="onClickSouceCode" | |||
| android:paddingStart="10dp" | |||
| android:text="@string/title_source" | |||
| android:textAllCaps="false" | |||
| android:textSize="12sp" | |||
| app:layout_constraintStart_toStartOf="@+id/btn_image_garbage" | |||
| app:layout_constraintTop_toBottomOf="@+id/btn_image_garbage" | |||
| app:layout_constraintWidth_percent="0.28" /> | |||
| <Button | |||
| android:id="@+id/btn_star" | |||
| android:layout_width="0dp" | |||
| android:layout_height="48dp" | |||
| android:layout_marginStart="10dp" | |||
| android:background="@color/gray_light_btn" | |||
| android:drawableStart="@drawable/btn_commend" | |||
| android:drawablePadding="8dp" | |||
| android:gravity="left|center_vertical" | |||
| android:onClick="onClickStar" | |||
| android:paddingStart="10dp" | |||
| android:text="@string/title_star" | |||
| android:textAllCaps="false" | |||
| android:textSize="12sp" | |||
| app:layout_constraintBottom_toBottomOf="@+id/btn_source" | |||
| app:layout_constraintEnd_toEndOf="@+id/btn_scene" | |||
| app:layout_constraintWidth_percent="0.28" /> | |||
| <Button | |||
| android:id="@+id/btn_help" | |||
| android:layout_width="0dp" | |||
| android:layout_height="48dp" | |||
| android:layout_marginTop="16dp" | |||
| android:background="@color/gray_light_btn" | |||
| android:drawableStart="@drawable/btn_help" | |||
| android:drawablePadding="8dp" | |||
| android:gravity="left|center_vertical" | |||
| android:onClick="onClickHelp" | |||
| android:paddingStart="10dp" | |||
| android:text="@string/title_help" | |||
| android:textAllCaps="false" | |||
| android:textSize="12sp" | |||
| app:layout_constraintBottom_toBottomOf="@+id/btn_source" | |||
| app:layout_constraintEnd_toStartOf="@+id/btn_star" | |||
| app:layout_constraintStart_toEndOf="@+id/btn_source" | |||
| app:layout_constraintWidth_percent="0.28" /> | |||
| </androidx.constraintlayout.widget.ConstraintLayout> | |||
| </ScrollView> | |||
| </androidx.constraintlayout.widget.ConstraintLayout> | |||
| @@ -0,0 +1,30 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <resources> | |||
| <string name="app_name">MindSpore</string> | |||
| <string name="app_need_permission">"MindSpore needs to access the "camera" and "external storage", please go to "application information -> permissions" to grant!"</string> | |||
| <string name="app_permission_by_hand"> "Go to manual authorization"</string> | |||
| <string name="cancel">"Cancel"</string> | |||
| <string name="confirm">"OK"</string> | |||
| <string name="app_download_success"> "download complete"</string> | |||
| <string name="app_need_install"> "Whether to install"</string> | |||
| <string name="app_is_loading"> "downloading"</string> | |||
| <string name="app_wait">"Please wait..."</string> | |||
| <string name="app_load_fail"> "download failed"</string> | |||
| <string name="app_update_lastest"> "Please upgrade to a new version"</string> | |||
| <string name="title_image">Image Classification</string> | |||
| <string name="title_image_garbage">Garbage Classification</string> | |||
| <string name="title_object">Photo Detection</string> | |||
| <string name="title_object_camera">Camera Detection</string> | |||
| <string name="title_pose_net">PoseNet</string> | |||
| <string name="title_style_transfer">Style Transfer</string> | |||
| <string name="title_segmentation">Image Segmentation</string> | |||
| <string name="title_source">Code</string> | |||
| <string name="title_scene">Scene Detection</string> | |||
| <string name="title_help">FeedBack</string> | |||
| <string name="title_star">Star</string> | |||
| <string name="title_version">"Version: "</string> | |||
| <string name="title_share">Share</string> | |||
| <string name="title_share_commend">MindSpore APP:A one-stop collaborative learning, demonstration, and experience platform for beginners\t</string> | |||
| </resources> | |||
| @@ -0,0 +1,28 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <resources> | |||
| <string name="app_name">MindSpore</string> | |||
| <string name="app_need_permission">"MindSpore需要访问 “相机" 和 “外部存储器",请到 “应用信息 -> 权限" 中授予!"</string> | |||
| <string name="app_permission_by_hand">"去手动授权"</string> | |||
| <string name="cancel">"取消"</string> | |||
| <string name="confirm">"确定"</string> | |||
| <string name="app_download_success">"下载完成"</string> | |||
| <string name="app_need_install">"是否安装"</string> | |||
| <string name="app_is_loading">"正在下载"</string> | |||
| <string name="app_wait">"请稍候..."</string> | |||
| <string name="app_load_fail">"下载失败"</string> | |||
| <string name="app_update_lastest">"请升级新版本"</string> | |||
| <string name="title_image">图像分类</string> | |||
| <string name="title_image_garbage">垃圾分类</string> | |||
| <string name="title_object">照片检测</string> | |||
| <string name="title_object_camera">视频检测</string> | |||
| <string name="title_pose_net"> 骨骼检测</string> | |||
| <string name="title_style_transfer">风格迁移</string> | |||
| <string name="title_segmentation">图像分割</string> | |||
| <string name="title_source">代码</string> | |||
| <string name="title_scene">场景检测</string> | |||
| <string name="title_help">反馈</string> | |||
| <string name="title_star">打星</string> | |||
| <string name="title_version">版本号: </string> | |||
| <string name="title_share">分享</string> | |||
| <string name="title_share_commend">MindSpore APP:初学者的一站式协同学习、演示、体验平台\t</string> | |||
| </resources> | |||
| @@ -1,26 +1,29 @@ | |||
| <resources> | |||
| <string name="app_name">HiMindSpore</string> | |||
| <string name="app_name_title">MindSpore</string> | |||
| <string name="switch_custom">custom</string> | |||
| <string name="app_name">MindSpore</string> | |||
| <string name="app_need_permission">"MindSpore需要访问 “相机” 和 “外部存储器”,请到 “应用信息 -> 权限” 中授予!"</string> | |||
| <string name="app_permission_by_hand">"去手动授权"</string> | |||
| <string name="cancel">"取消"</string> | |||
| <string name="confirm">"确定"</string> | |||
| <string name="app_download_success">"下载完成"</string> | |||
| <string name="app_need_install">"是否安装"</string> | |||
| <string name="app_is_loading">"正在下载"</string> | |||
| <string name="app_wait">"请稍候..."</string> | |||
| <string name="app_load_fail">"下载失败"</string> | |||
| <string name="app_update_lastest">"请升级新版本"</string> | |||
| <string name="title_image">Image Classification</string> | |||
| <string name="title_image_garbage">Garbage Classification</string> | |||
| <string name="title_object">Photo Detection</string> | |||
| <string name="title_object_camera">Camera Detection</string> | |||
| <string name="title_pose_net">PoseNet</string> | |||
| <string name="title_style_transfer">Style Transfer</string> | |||
| <string name="title_segmentation">Image Segmentation</string> | |||
| <string name="title_source">Code</string> | |||
| <string name="title_scene">Scene Detection</string> | |||
| <string name="title_help">FeedBack</string> | |||
| <string name="title_star">Star</string> | |||
| <string name="title_segmentation">Image Segmentation</string> | |||
| <string name="title_photo">Photo</string> | |||
| <string name="title_camera">Camera</string> | |||
| <string name="title_demo">Demo</string> | |||
| <string name="title_custom">Custom</string> | |||
| <string name="title_time">Inference Time</string> | |||
| <string name="title_version">Version: </string> | |||
| <string name="title_share">Share</string> | |||
| <string name="title_share_commend">MindSpore APP:初学者的一站式协同学习、演示、体验平台\t</string> | |||
| </resources> | |||
| @@ -9,9 +9,6 @@ buildscript { | |||
| } | |||
| dependencies { | |||
| classpath "com.android.tools.build:gradle:4.0.1" | |||
| // NOTE: Do not place your application dependencies here; they belong | |||
| // in the individual module build.gradle files | |||
| } | |||
| } | |||
| @@ -8,11 +8,12 @@ cmake_minimum_required(VERSION 3.4.1) | |||
| set(CMAKE_VERBOSE_MAKEFILE on) | |||
| set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}) | |||
| set(MINDSPORELITE_VERSION mindspore-lite-1.0.1-runtime-arm64-cpu) | |||
| set(MINDSPORELITE_VERSION mindspore-lite-1.1.0-inference-android) | |||
| # ============== Set MindSpore Dependencies. ============= | |||
| include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp) | |||
| include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/${MINDSPORELITE_VERSION}/third_party/flatbuffers/include) | |||
| include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/${MINDSPORELITE_VERSION}/third_party/hiai_ddk/lib/aarch64) | |||
| include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/${MINDSPORELITE_VERSION}) | |||
| include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/${MINDSPORELITE_VERSION}/include) | |||
| include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/${MINDSPORELITE_VERSION}/include/ir/dtype) | |||
| @@ -21,14 +22,21 @@ include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/${MINDSPORELITE_VERSION}/mi | |||
| add_library(mindspore-lite SHARED IMPORTED) | |||
| add_library(minddata-lite SHARED IMPORTED) | |||
| #add_library(libmindspore-lite-fp16 SHARED IMPORTED ) | |||
| add_library(hiai SHARED IMPORTED) | |||
| add_library(hiai_ir SHARED IMPORTED) | |||
| add_library(hiai_ir_build SHARED IMPORTED) | |||
| set_target_properties(mindspore-lite PROPERTIES IMPORTED_LOCATION | |||
| ${CMAKE_SOURCE_DIR}/src/main/cpp/${MINDSPORELITE_VERSION}/lib/libmindspore-lite.so) | |||
| ${CMAKE_SOURCE_DIR}/src/main/cpp/${MINDSPORELITE_VERSION}/lib/aarch64/libmindspore-lite.so) | |||
| set_target_properties(minddata-lite PROPERTIES IMPORTED_LOCATION | |||
| ${CMAKE_SOURCE_DIR}/src/main/cpp/${MINDSPORELITE_VERSION}/minddata/lib/libminddata-lite.so) | |||
| #set_target_properties(libmindspore-lite-fp16 PROPERTIES IMPORTED_LOCATION | |||
| # ${CMAKE_SOURCE_DIR}/src/main/cpp/${MINDSPORELITE_VERSION}/lib/libmindspore-lite-fp16.so) | |||
| ${CMAKE_SOURCE_DIR}/src/main/cpp/${MINDSPORELITE_VERSION}/minddata/lib/aarch64/libminddata-lite.so) | |||
| set_target_properties(hiai PROPERTIES IMPORTED_LOCATION | |||
| ${CMAKE_SOURCE_DIR}/src/main/cpp/${MINDSPORELITE_VERSION}/third_party/hiai_ddk/lib/aarch64/libhiai.so) | |||
| set_target_properties(hiai_ir PROPERTIES IMPORTED_LOCATION | |||
| ${CMAKE_SOURCE_DIR}/src/main/cpp/${MINDSPORELITE_VERSION}/third_party/hiai_ddk/lib/aarch64/libhiai_ir.so) | |||
| set_target_properties(hiai_ir_build PROPERTIES IMPORTED_LOCATION | |||
| ${CMAKE_SOURCE_DIR}/src/main/cpp/${MINDSPORELITE_VERSION}/third_party/hiai_ddk/lib/aarch64/libhiai_ir_build.so) | |||
| # --------------- MindSpore Lite set End. -------------------- | |||
| @@ -75,6 +83,9 @@ target_link_libraries( # Specifies the target library. | |||
| # --- mindspore --- | |||
| minddata-lite | |||
| mindspore-lite | |||
| hiai | |||
| hiai_ir | |||
| hiai_ir_build | |||
| # libmindspore-lite-fp16 | |||
| # --- other dependencies.--- | |||
| @@ -71,7 +71,7 @@ apply from: 'download.gradle' | |||
| dependencies { | |||
| implementation 'androidx.appcompat:appcompat:1.2.0' | |||
| implementation 'androidx.appcompat:appcompat:1.3.0-alpha02' | |||
| implementation 'com.google.android.material:material:1.2.1' | |||
| implementation 'androidx.constraintlayout:constraintlayout:2.0.4' | |||
| androidTestImplementation 'androidx.test.ext:junit:1.1.2' | |||
| @@ -4,13 +4,18 @@ | |||
| * The libraries can be downloaded manually. | |||
| */ | |||
| def targetMindSporeInclude = "src/main/cpp/" | |||
| def mindsporeLite_Version = "mindspore-lite-1.0.1-runtime-arm64-cpu" | |||
| def mindsporeLite_Version = "mindspore-lite-1.1.0-inference-android" | |||
| def mindsporeLite_Version_AAR = "mindspore-lite-maven-1.1.0" | |||
| def targetModelFile = "src/main/assets/model/mobilenetv2.ms" | |||
| def mindSporeLibrary_arm64 = "src/main/cpp/${mindsporeLite_Version}.tar.gz" | |||
| def modelDownloadUrl = "https://download.mindspore.cn/model_zoo/official/lite/mobilenetv2_openimage_lite/mobilenetv2.ms" | |||
| def mindsporeLiteDownloadUrl = "https://ms-release.obs.cn-north-4.myhuaweicloud.com/1.0.1/lite/android_aarch64/${mindsporeLite_Version}.tar.gz" | |||
| def mindsporeLiteDownloadUrl = "https://ms-release.obs.cn-north-4.myhuaweicloud.com/1.1.0/MindSpore/lite/release/android/${mindsporeLite_Version}.tar.gz" | |||
| def mindSporeLibraryAAR = "src/main/cpp/${mindsporeLite_Version}/${mindsporeLite_Version_AAR}.zip" | |||
| def cleantargetMindSporeIncludeAAR = "../mindsporelibrary" | |||
| def targetMindSporeIncludeAAR = "../mindsporelibrary/" | |||
| def targetObjectModelFile = "src/main/assets/model/ssd.ms" | |||
| def targetGarbageModelFile = "src/main/assets/model/garbage_mobilenetv2.ms" | |||
| @@ -66,15 +71,29 @@ task unzipMindSporeInclude(type: Copy, dependsOn: 'downloadMindSporeLibrary') { | |||
| } | |||
| task cleanUnusedmindsporeFiles(type: Delete, dependsOn: ['unzipMindSporeInclude']) { | |||
| delete fileTree("${cleantargetMindSporeInclude}").matching { | |||
| delete fileTree("${targetMindSporeInclude}").matching { | |||
| include "*.tar.gz" | |||
| } | |||
| } | |||
| task unzipMindSporeIncludeAAR(type: Copy, dependsOn: ['cleanUnusedmindsporeFiles']) { | |||
| doFirst { | |||
| println "Unzipping ${mindSporeLibraryAAR}" | |||
| } | |||
| from zipTree("${mindSporeLibraryAAR}") | |||
| into "${targetMindSporeIncludeAAR}" | |||
| } | |||
| task cleanUnusedmindsporeAARFiles(type: Delete, dependsOn: ['unzipMindSporeIncludeAAR']) { | |||
| delete fileTree("${cleantargetMindSporeIncludeAAR}").matching { | |||
| include "*.zip" | |||
| } | |||
| } | |||
| /* | |||
| * Using preBuild to download mindspore library and model file. | |||
| * Run before gradle build. | |||
| */ | |||
| if (file("src/main/cpp/${mindsporeLite_Version}/lib/libmindspore-lite.so").exists()) { | |||
| if (file("src/main/cpp/${mindsporeLite_Version}/lib/aarch64/libmindspore-lite.so").exists()) { | |||
| downloadMindSporeLibrary.enabled = false | |||
| unzipMindSporeInclude.enabled = false | |||
| cleanUnusedmindsporeFiles.enabled = false | |||
| @@ -92,13 +111,22 @@ if (file("src/main/assets/model/ssd.ms").exists()) { | |||
| downloadObjectModelFile.enabled = false | |||
| } | |||
| if (file("../mindsporelibrary/mindspore/mindspore-lite/1.1.0/mindspore-lite-1.1.0.aar").exists()) { | |||
| downloadMindSporeLibrary.enabled = false | |||
| unzipMindSporeIncludeAAR.enabled = false | |||
| cleanUnusedmindsporeAARFiles.enabled = false | |||
| } | |||
| preBuild.dependsOn cleanCmakeCache | |||
| preBuild.dependsOn downloadModelFile | |||
| preBuild.dependsOn downloadObjectModelFile | |||
| preBuild.dependsOn downloadMindSporeLibrary | |||
| preBuild.dependsOn downloadGarbageModelFile | |||
| preBuild.dependsOn unzipMindSporeInclude | |||
| preBuild.dependsOn unzipMindSporeIncludeAAR | |||
| preBuild.dependsOn cleanUnusedmindsporeFiles | |||
| preBuild.dependsOn cleanUnusedmindsporeAARFiles | |||
| class DownloadUrlTask extends DefaultTask { | |||
| @Input | |||
| @@ -111,4 +139,4 @@ class DownloadUrlTask extends DefaultTask { | |||
| void download() { | |||
| ant.get(src: sourceUrl, dest: target) | |||
| } | |||
| } | |||
| } | |||
| @@ -35,42 +35,7 @@ using mindspore::dataset::LPixelType; | |||
| using mindspore::dataset::LDataType; | |||
| #define MS_PRINT(format, ...) __android_log_print(ANDROID_LOG_INFO, "MSJNI", format, ##__VA_ARGS__) | |||
| static const int RET_GARBAGE_SORT_SUM = 4; | |||
| static const char *labels_name_grbage_sort_map[RET_GARBAGE_SORT_SUM] = {"可回收物", | |||
| "干垃圾", | |||
| "有害垃圾", | |||
| "湿垃圾"}; | |||
| static const int RET_GARBAGE_DETAILED_SUM = 26; | |||
| static const char *labels_name_grbage_detailed_map[RET_GARBAGE_DETAILED_SUM] = { | |||
| "塑料瓶", | |||
| "帽子", | |||
| "报纸", | |||
| "易拉罐", | |||
| "玻璃制品", | |||
| "玻璃瓶", | |||
| "硬纸板", | |||
| "篮球", | |||
| "纸张", | |||
| "金属制品", | |||
| "一次性筷子", | |||
| "打火机", | |||
| "扫把", | |||
| "旧镜子", | |||
| "牙刷", | |||
| "脏污衣服", | |||
| "贝壳", | |||
| "陶瓷碗", | |||
| "油漆桶", | |||
| "电池", | |||
| "荧光灯", | |||
| "药片胶囊", | |||
| "橙皮", | |||
| "菜叶", | |||
| "蛋壳", | |||
| "香蕉皮"}; | |||
| char *CreateLocalModelBuffer(JNIEnv *env, jobject modelBuffer) { | |||
| jbyte *modelAddr = static_cast<jbyte *>(env->GetDirectBufferAddress(modelBuffer)); | |||
| @@ -86,7 +51,7 @@ char *CreateLocalModelBuffer(JNIEnv *env, jobject modelBuffer) { | |||
| * @return | |||
| */ | |||
| std::string | |||
| GarbageProcessRunnetResult(const int RET_CATEGORY_SUM, const char *const labels_name_map[], | |||
| GarbageProcessRunnetResult(const int RET_CATEGORY_SUM, | |||
| std::unordered_map<std::string, mindspore::tensor::MSTensor *> msOutputs) { | |||
| // Get the branch of the model output. | |||
| // Use iterators to get map elements. | |||
| @@ -110,20 +75,7 @@ GarbageProcessRunnetResult(const int RET_CATEGORY_SUM, const char *const labels_ | |||
| // Score for each category. | |||
| // Converted to text information that needs to be displayed in the APP. | |||
| std::string categoryScore = ""; | |||
| if (maxIndex <= 9) { | |||
| categoryScore += labels_name_grbage_sort_map[0]; | |||
| categoryScore += ":"; | |||
| } else if (maxIndex > 9 && maxIndex <= 17) { | |||
| categoryScore += labels_name_grbage_sort_map[1]; | |||
| categoryScore += ":"; | |||
| } else if (maxIndex > 17 && maxIndex <= 21) { | |||
| categoryScore += labels_name_grbage_sort_map[2]; | |||
| categoryScore += ":"; | |||
| } else if (maxIndex > 21 && maxIndex <= 25) { | |||
| categoryScore += labels_name_grbage_sort_map[3]; | |||
| categoryScore += ":"; | |||
| } | |||
| categoryScore += labels_name_map[maxIndex]; | |||
| categoryScore = std::to_string(maxIndex); | |||
| return categoryScore; | |||
| } | |||
| @@ -317,7 +269,6 @@ Java_com_mindspore_imageobject_imageclassification_help_GarbageTrackingMobile_ru | |||
| } | |||
| std::string resultStr = GarbageProcessRunnetResult(::RET_GARBAGE_DETAILED_SUM, | |||
| ::labels_name_grbage_detailed_map, | |||
| msOutputs); | |||
| const char *resultCharData = resultStr.c_str(); | |||
| @@ -37,417 +37,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, | |||
| @@ -547,7 +136,7 @@ char *ImageCreateLocalModelBuffer(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<std::string, mindspore::tensor::MSTensor *> msOutputs) { | |||
| // Get the branch of the model output. | |||
| // Use iterators to get map elements. | |||
| @@ -590,7 +179,7 @@ std::string ProcessRunnetResult(const int RET_CATEGORY_SUM, const char *const la | |||
| // 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; | |||
| @@ -787,8 +376,7 @@ Java_com_mindspore_imageobject_imageclassification_help_ImageTrackingMobile_runN | |||
| msOutputs.insert(std::pair<std::string, mindspore::tensor::MSTensor *>{name, temp_dat}); | |||
| } | |||
| std::string resultStr = ProcessRunnetResult(::RET_CATEGORY_SUM, | |||
| ::labels_name_map, msOutputs); | |||
| std::string resultStr = ProcessRunnetResult(::RET_CATEGORY_SUM, msOutputs); | |||
| const char *resultCharData = resultStr.c_str(); | |||
| return (env)->NewStringUTF(resultCharData); | |||
| @@ -123,7 +123,6 @@ ProcessRunnetResult(std::unordered_map<std::string, mindspore::tensor::MSTensor | |||
| auto branch1_tensor = iter->second; | |||
| MS_PRINT("%s %s", branch1_string.c_str(), branch2_string.c_str()); | |||
| // ----------- 接口测试 -------------------------- | |||
| float *tmpscores2 = reinterpret_cast<float *>(branch1_tensor->MutableData()); | |||
| float *tmpdata = reinterpret_cast<float *>(branch2_tensor->MutableData()); | |||
| @@ -35,176 +35,7 @@ using mindspore::dataset::LPixelType; | |||
| using mindspore::dataset::LDataType; | |||
| #define MS_PRINT(format, ...) __android_log_print(ANDROID_LOG_INFO, "MSJNI", format, ##__VA_ARGS__) | |||
| static const int RET_CATEGORY_SUM = 365; | |||
| static const char *labels_name_map[RET_CATEGORY_SUM] = {"airfield", "airplane_cabin", | |||
| "airport_terminal", "alcove", "alley", | |||
| "amphitheater", "amusement_arcade", | |||
| "amusement_park", | |||
| "apartment_building/outdoor", "aquarium", | |||
| "aqueduct", "arcade", "arch", | |||
| "archaelogical_excavation", "archive", | |||
| "arena/hockey", "arena/performance", | |||
| "arena/rodeo", "army_base", "art_gallery", | |||
| "art_school", "art_studio", "artists_loft", | |||
| "assembly_line", "athletic_field/outdoor", | |||
| "atrium/public", "attic", "auditorium", | |||
| "auto_factory", "auto_showroom", | |||
| "badlands", "bakery/shop", | |||
| "balcony/exterior", "balcony/interior", | |||
| "ball_pit", | |||
| "ballroom", "bamboo_forest", "bank_vault", | |||
| "banquet_hall", "bar", | |||
| "barn", "barndoor", "baseball_field", | |||
| "basement", "basketball_court/indoor", | |||
| "bathroom", "bazaar/indoor", | |||
| "bazaar/outdoor", "beach", "beach_house", | |||
| "beauty_salon", "bedchamber", "bedroom", | |||
| "beer_garden", "beer_hall", | |||
| "berth", "biology_laboratory", "boardwalk", | |||
| "boat_deck", "boathouse", | |||
| "bookstore", "booth/indoor", | |||
| "botanical_garden", "bow_window/indoor", | |||
| "bowling_alley", | |||
| "boxing_ring", "bridge", "building_facade", | |||
| "bullring", "burial_chamber", | |||
| "bus_interior", "bus_station/indoor", | |||
| "butchers_shop", "butte", "cabin/outdoor", | |||
| "cafeteria", "campsite", "campus", | |||
| "canal/natural", "canal/urban", | |||
| "candy_store", "canyon", "car_interior", | |||
| "carrousel", "castle", | |||
| "catacomb", "cemetery", "chalet", | |||
| "chemistry_lab", "childs_room", | |||
| "church/indoor", "church/outdoor", | |||
| "classroom", "clean_room", "cliff", | |||
| "closet", "clothing_store", "coast", | |||
| "cockpit", "coffee_shop", | |||
| "computer_room", "conference_center", | |||
| "conference_room", "construction_site", | |||
| "corn_field", | |||
| "corral", "corridor", "cottage", | |||
| "courthouse", "courtyard", | |||
| "creek", "crevasse", "crosswalk", "dam", | |||
| "delicatessen", | |||
| "department_store", "desert/sand", | |||
| "desert/vegetation", "desert_road", | |||
| "diner/outdoor", | |||
| "dining_hall", "dining_room", "discotheque", | |||
| "doorway/outdoor", "dorm_room", | |||
| "downtown", "dressing_room", "driveway", | |||
| "drugstore", "elevator/door", | |||
| "elevator_lobby", "elevator_shaft", | |||
| "embassy", "engine_room", "entrance_hall", | |||
| "escalator/indoor", "excavation", | |||
| "fabric_store", "farm", | |||
| "fastfood_restaurant", | |||
| "field/cultivated", "field/wild", | |||
| "field_road", "fire_escape", "fire_station", | |||
| "fishpond", "flea_market/indoor", | |||
| "florist_shop/indoor", "food_court", | |||
| "football_field", | |||
| "forest/broadleaf", "forest_path", | |||
| "forest_road", "formal_garden", "fountain", | |||
| "galley", "garage/indoor", "garage/outdoor", | |||
| "gas_station", "gazebo/exterior", | |||
| "general_store/indoor", | |||
| "general_store/outdoor", "gift_shop", | |||
| "glacier", "golf_course", | |||
| "greenhouse/indoor", "greenhouse/outdoor", | |||
| "grotto", "gymnasium/indoor", | |||
| "hangar/indoor", | |||
| "hangar/outdoor", "harbor", | |||
| "hardware_store", "hayfield", "heliport", | |||
| "highway", "home_office", "home_theater", | |||
| "hospital", "hospital_room", | |||
| "hot_spring", "hotel/outdoor", "hotel_room", | |||
| "house", "hunting_lodge/outdoor", | |||
| "ice_cream_parlor", "ice_floe", "ice_shelf", | |||
| "ice_skating_rink/indoor", | |||
| "ice_skating_rink/outdoor", | |||
| "iceberg", "igloo", "industrial_area", | |||
| "inn/outdoor", "islet", | |||
| "jacuzzi/indoor", "jail_cell", | |||
| "japanese_garden", "jewelry_shop", | |||
| "junkyard", | |||
| "kasbah", "kennel/outdoor", | |||
| "kindergarden_classroom", "kitchen", | |||
| "lagoon", | |||
| "lake/natural", "landfill", "landing_deck", | |||
| "laundromat", "lawn", | |||
| "lecture_room", "legislative_chamber", | |||
| "library/indoor", "library/outdoor", | |||
| "lighthouse", | |||
| "living_room", "loading_dock", "lobby", | |||
| "lock_chamber", "locker_room", | |||
| "mansion", "manufactured_home", | |||
| "market/indoor", "market/outdoor", "marsh", | |||
| "martial_arts_gym", "mausoleum", "medina", | |||
| "mezzanine", "moat/water", | |||
| "mosque/outdoor", "motel", "mountain", | |||
| "mountain_path", "mountain_snowy", | |||
| "movie_theater/indoor", "museum/indoor", | |||
| "museum/outdoor", "music_studio", | |||
| "natural_history_museum", | |||
| "nursery", "nursing_home", "oast_house", | |||
| "ocean", "office", | |||
| "office_building", "office_cubicles", | |||
| "oilrig", "operating_room", "orchard", | |||
| "orchestra_pit", "pagoda", "palace", | |||
| "pantry", "park", | |||
| "parking_garage/indoor", | |||
| "parking_garage/outdoor", "parking_lot", | |||
| "pasture", "patio", | |||
| "pavilion", "pet_shop", "pharmacy", | |||
| "phone_booth", "physics_laboratory", | |||
| "picnic_area", "pier", "pizzeria", | |||
| "playground", "playroom", | |||
| "plaza", "pond", "porch", "promenade", | |||
| "pub/indoor", | |||
| "racecourse", "raceway", "raft", | |||
| "railroad_track", "rainforest", | |||
| "reception", "recreation_room", | |||
| "repair_shop", "residential_neighborhood", | |||
| "restaurant", | |||
| "restaurant_kitchen", "restaurant_patio", | |||
| "rice_paddy", "river", "rock_arch", | |||
| "roof_garden", "rope_bridge", "ruin", | |||
| "runway", "sandbox", | |||
| "sauna", "schoolhouse", "science_museum", | |||
| "server_room", "shed", | |||
| "shoe_shop", "shopfront", | |||
| "shopping_mall/indoor", "shower", | |||
| "ski_resort", | |||
| "ski_slope", "sky", "skyscraper", "slum", | |||
| "snowfield", | |||
| "soccer_field", "stable", | |||
| "stadium/baseball", "stadium/football", | |||
| "stadium/soccer", | |||
| "stage/indoor", "stage/outdoor", | |||
| "staircase", "storage_room", "street", | |||
| "subway_station/platform", "supermarket", | |||
| "sushi_bar", "swamp", "swimming_hole", | |||
| "swimming_pool/indoor", | |||
| "swimming_pool/outdoor", | |||
| "synagogue/outdoor", "television_room", | |||
| "television_studio", | |||
| "temple/asia", "throne_room", | |||
| "ticket_booth", "topiary_garden", "tower", | |||
| "toyshop", "train_interior", | |||
| "train_station/platform", "tree_farm", | |||
| "tree_house", | |||
| "trench", "tundra", "underwater/ocean_deep", | |||
| "utility_room", "valley", | |||
| "vegetable_garden", "veterinarians_office", | |||
| "viaduct", "village", "vineyard", | |||
| "volcano", "volleyball_court/outdoor", | |||
| "waiting_room", "water_park", "water_tower", | |||
| "waterfall", "watering_hole", "wave", | |||
| "wet_bar", "wheat_field", | |||
| "wind_farm", "windmill", "yard", | |||
| "youth_hostel", "zen_garden"}; | |||
| char *SceneCreateLocalModelBuffer(JNIEnv *env, jobject modelBuffer) { | |||
| jbyte *modelAddr = static_cast<jbyte *>(env->GetDirectBufferAddress(modelBuffer)); | |||
| @@ -219,7 +50,7 @@ char *SceneCreateLocalModelBuffer(JNIEnv *env, jobject modelBuffer) { | |||
| * @param msOutputs | |||
| * @return | |||
| */ | |||
| std::string SceneProcessRunnetResult(const int RET_CATEGORY_SUM, const char *const labels_name_map[], | |||
| std::string SceneProcessRunnetResult(const int RET_CATEGORY_SUM, | |||
| std::unordered_map<std::string, mindspore::tensor::MSTensor *> msOutputs) { | |||
| // Get the branch of the model output. | |||
| // Use iterators to get map elements. | |||
| @@ -251,7 +82,7 @@ std::string SceneProcessRunnetResult(const int RET_CATEGORY_SUM, const char *con | |||
| // Score for each category. | |||
| // Converted to text information that needs to be displayed in the APP. | |||
| std::string categoryScore = ""; | |||
| categoryScore += labels_name_map[cat_loc]; | |||
| categoryScore += std::to_string(cat_loc); | |||
| categoryScore += ":"; | |||
| std::string score_str = std::to_string(scores); | |||
| categoryScore += score_str; | |||
| @@ -448,8 +279,7 @@ Java_com_mindspore_imageobject_imageclassification_help_SceneTrackingMobile_runN | |||
| msOutputs.insert(std::pair<std::string, mindspore::tensor::MSTensor *>{name, temp_dat}); | |||
| } | |||
| std::string resultStr = SceneProcessRunnetResult(::RET_CATEGORY_SUM, | |||
| ::labels_name_map, msOutputs); | |||
| std::string resultStr = SceneProcessRunnetResult(::RET_CATEGORY_SUM, msOutputs); | |||
| const char *resultCharData = resultStr.c_str(); | |||
| return (env)->NewStringUTF(resultCharData); | |||
| @@ -64,23 +64,20 @@ public class ImageCameraActivity extends AppCompatActivity implements CameraPrev | |||
| int enterType; | |||
| private LinearLayout bottomLayout; | |||
| private List<RecognitionImageBean> recognitionObjectBeanList; | |||
| private CameraPreview cameraPreview; | |||
| private ImageTrackingMobile imageTrackingMobile; | |||
| private GarbageTrackingMobile garbageTrackingMobile; | |||
| private SceneTrackingMobile sceneTrackingMobile; | |||
| private RecognitionImageBean bean; | |||
| @Override | |||
| protected void onCreate(Bundle savedInstanceState) { | |||
| super.onCreate(savedInstanceState); | |||
| //inject | |||
| ARouter.getInstance().inject(this); | |||
| setContentView(R.layout.activity_image_camera); | |||
| cameraPreview = findViewById(R.id.image_camera_preview); | |||
| bottomLayout = findViewById(R.id.layout_bottom_content); | |||
| cameraPreview.setVisibility(View.VISIBLE); | |||
| @@ -172,34 +169,48 @@ public class ImageCameraActivity extends AppCompatActivity implements CameraPrev | |||
| String[] resultArray = result.split(";"); | |||
| for (String singleRecognitionResult : resultArray) { | |||
| String[] singleResult = singleRecognitionResult.split(":"); | |||
| int lableIndex = Integer.parseInt(singleResult[0]); | |||
| float score = Float.parseFloat(singleResult[1]); | |||
| String[] IMAGEOBJECT = getResources().getStringArray(R.array.image_category); | |||
| if (score > 0.5) { | |||
| recognitionObjectBeanList.add(new RecognitionImageBean(singleResult[0], score)); | |||
| recognitionObjectBeanList.add(new RecognitionImageBean(IMAGEOBJECT[lableIndex], score)); | |||
| } | |||
| } | |||
| Collections.sort(recognitionObjectBeanList, new Comparator<RecognitionImageBean>() { | |||
| @Override | |||
| public int compare(RecognitionImageBean t1, RecognitionImageBean t2) { | |||
| return Float.compare(t2.getScore(), t1.getScore()); | |||
| } | |||
| }); | |||
| Collections.sort(recognitionObjectBeanList, (t1, t2) -> Float.compare(t2.getScore(), t1.getScore())); | |||
| } | |||
| runOnUiThread(() -> showResultsInBottomSheet(recognitionObjectBeanList, time)); | |||
| } else if (TYPE_GARBAGE == enterType) { | |||
| runOnUiThread(() -> showResultsInBottomSheetGarbage(result, time)); | |||
| int maxIndex = Integer.parseInt(result); | |||
| String[] GABAGETITLE = getResources().getStringArray(R.array.grbage_sort_map); | |||
| StringBuilder categoryScore = new StringBuilder(); | |||
| if (maxIndex <= 9) { | |||
| categoryScore.append(GABAGETITLE[0]); | |||
| categoryScore.append(":"); | |||
| } else if (maxIndex > 9 && maxIndex <= 17) { | |||
| categoryScore.append(GABAGETITLE[1]); | |||
| categoryScore.append(":"); | |||
| } else if (maxIndex > 17 && maxIndex <= 21) { | |||
| categoryScore.append(GABAGETITLE[2]); | |||
| categoryScore.append(":"); | |||
| } else if (maxIndex > 21 && maxIndex <= 25) { | |||
| categoryScore.append(GABAGETITLE[3]); | |||
| categoryScore.append(":"); | |||
| } | |||
| categoryScore.append(getResources().getStringArray(R.array.grbage_sort_detailed_map)[maxIndex]); | |||
| String finalCategoryScore = categoryScore.toString(); | |||
| runOnUiThread(() -> showResultsInBottomSheetGarbage(finalCategoryScore, time)); | |||
| } else if (TYPE_SCENE == enterType) { | |||
| if (!result.equals("") && result.contains(":")) { | |||
| String[] resultArray = result.split(":"); | |||
| bean = new RecognitionImageBean(resultArray[0], Float.valueOf(resultArray[1])); | |||
| int lableIndex = Integer.parseInt(resultArray[0]); | |||
| float score = Float.parseFloat(resultArray[1]); | |||
| String[] SCENEOBJECT = getResources().getStringArray(R.array.scene_category); | |||
| bean = new RecognitionImageBean(SCENEOBJECT[lableIndex], score); | |||
| } | |||
| runOnUiThread(() -> showResultsInBottomSheetScene(bean, time)); | |||
| } | |||
| } | |||
| RecognitionImageBean bean; | |||
| @UiThread | |||
| protected void showResultsInBottomSheet(List<RecognitionImageBean> list, String time) { | |||
| bottomLayout.removeAllViews(); | |||
| @@ -259,14 +270,14 @@ public class ImageCameraActivity extends AppCompatActivity implements CameraPrev | |||
| bottomLayout.addView(horTextView); | |||
| HorTextView horTimeView = new HorTextView(this); | |||
| horTimeView.setLeftTitle("Inference Time:"); | |||
| horTimeView.setLeftTitle(getResources().getString(R.string.title_time)); | |||
| horTimeView.setRightContent(time); | |||
| horTimeView.setBottomLineVisible(View.INVISIBLE); | |||
| bottomLayout.addView(horTimeView); | |||
| } else { | |||
| TextView textView = new TextView(this); | |||
| textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); | |||
| textView.setText("Keep moving."); | |||
| textView.setText(getResources().getString(R.string.title_keep)); | |||
| textView.setGravity(Gravity.CENTER); | |||
| textView.setTextColor(Color.BLACK); | |||
| textView.setTextSize(30); | |||
| @@ -277,12 +288,10 @@ public class ImageCameraActivity extends AppCompatActivity implements CameraPrev | |||
| private void showLoadView() { | |||
| TextView textView = new TextView(this); | |||
| textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); | |||
| textView.setText("Keep moving."); | |||
| textView.setText(getResources().getString(R.string.title_keep)); | |||
| textView.setGravity(Gravity.CENTER); | |||
| textView.setTextColor(Color.WHITE); | |||
| textView.setTextSize(30); | |||
| bottomLayout.addView(textView); | |||
| } | |||
| } | |||
| @@ -84,7 +84,6 @@ public class ObjectTrackingMobile { | |||
| */ | |||
| public boolean loadModelFromBuf(AssetManager assetManager) { | |||
| String ModelPath = "model/ssd.ms"; | |||
| ByteBuffer buffer = loadModelFile(ModelPath); | |||
| netEnv = loadModel(assetManager, buffer, 2); | |||
| return true; | |||
| @@ -16,7 +16,6 @@ | |||
| package com.mindspore.imageobject.objectdetection.ui; | |||
| import android.content.Intent; | |||
| import android.content.res.Configuration; | |||
| import android.graphics.Bitmap; | |||
| import android.graphics.Canvas; | |||
| import android.graphics.Paint; | |||
| @@ -25,8 +24,6 @@ import android.net.Uri; | |||
| import android.os.Bundle; | |||
| import android.provider.MediaStore; | |||
| import android.util.Log; | |||
| import android.util.Pair; | |||
| import android.view.View; | |||
| import android.widget.ImageView; | |||
| import android.widget.Toast; | |||
| @@ -36,10 +33,11 @@ import androidx.appcompat.app.AppCompatActivity; | |||
| import com.alibaba.android.arouter.facade.annotation.Route; | |||
| import com.mindspore.imageobject.R; | |||
| import com.mindspore.imageobject.objectdetection.bean.RecognitionObjectBean; | |||
| import com.mindspore.imageobject.objectdetection.help.ObjectTrackingMobile; | |||
| import com.mindspore.imageobject.util.BitmapUtils; | |||
| import com.mindspore.imageobject.util.DisplayUtil; | |||
| import com.mindspore.imageobject.objectdetection.help.ObjectTrackingMobile; | |||
| import java.io.File; | |||
| import java.io.FileNotFoundException; | |||
| import java.util.List; | |||
| @@ -57,13 +55,8 @@ public class ObjectPhotoActivity extends AppCompatActivity { | |||
| private ObjectTrackingMobile trackingMobile; | |||
| private List<RecognitionObjectBean> recognitionObjectBeanList; | |||
| private Integer maxWidthOfImage; | |||
| private Integer maxHeightOfImage; | |||
| boolean isLandScape; | |||
| private Bitmap originBitmap; | |||
| Uri imageUri; | |||
| private Uri imageUri; | |||
| @Override | |||
| protected void onCreate(Bundle savedInstanceState) { | |||
| @@ -71,10 +64,7 @@ public class ObjectPhotoActivity extends AppCompatActivity { | |||
| setContentView(R.layout.activity_object_photo); | |||
| preview = findViewById(R.id.img_photo); | |||
| this.isLandScape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; | |||
| openGallay(); | |||
| } | |||
| private void openGallay() { | |||
| @@ -86,10 +76,9 @@ public class ObjectPhotoActivity extends AppCompatActivity { | |||
| @Override | |||
| protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | |||
| super.onActivityResult(requestCode, resultCode, data); | |||
| if (RC_CHOOSE_PHOTO == requestCode && null != data && null != data.getData()) { | |||
| this.imageUri = data.getData(); | |||
| showOriginImage(); | |||
| this.imageUri = data.getData(); | |||
| showOriginImage(); | |||
| } else { | |||
| Toast.makeText(this, R.string.image_invalid, Toast.LENGTH_LONG).show(); | |||
| finish(); | |||
| @@ -97,13 +86,10 @@ public class ObjectPhotoActivity extends AppCompatActivity { | |||
| } | |||
| private void showOriginImage() { | |||
| Pair<Integer, Integer> targetedSize = this.getTargetSize(); | |||
| int targetWidth = targetedSize.first; | |||
| int maxHeight = targetedSize.second; | |||
| originBitmap = BitmapUtils.loadFromPath(this, imageUri, targetWidth, maxHeight).copy(Bitmap.Config.ARGB_8888, true); | |||
| // Determine how much to scale down the image. | |||
| Log.i(ObjectPhotoActivity.TAG, "resized image size width:" + originBitmap.getWidth() + ",height: " + originBitmap.getHeight()); | |||
| File file = BitmapUtils.getFileFromMediaUri(this, imageUri); | |||
| Bitmap photoBmp = BitmapUtils.getBitmapFormUri(this, Uri.fromFile(file)); | |||
| int degree = BitmapUtils.getBitmapDegree(file.getAbsolutePath()); | |||
| originBitmap = BitmapUtils.rotateBitmapByDegree(photoBmp, degree).copy(Bitmap.Config.ARGB_8888, true); | |||
| if (originBitmap != null) { | |||
| initMindspore(originBitmap); | |||
| preview.setImageBitmap(originBitmap); | |||
| @@ -171,41 +157,4 @@ public class ObjectPhotoActivity extends AppCompatActivity { | |||
| } | |||
| BitmapUtils.recycleBitmap(originBitmap); | |||
| } | |||
| // Returns max width of image. | |||
| private Integer getMaxWidthOfImage() { | |||
| if (this.maxWidthOfImage == null) { | |||
| if (this.isLandScape) { | |||
| this.maxWidthOfImage = ((View) this.preview.getParent()).getHeight(); | |||
| } else { | |||
| this.maxWidthOfImage = ((View) this.preview.getParent()).getWidth(); | |||
| } | |||
| } | |||
| return this.maxWidthOfImage; | |||
| } | |||
| // Returns max height of image. | |||
| private Integer getMaxHeightOfImage() { | |||
| if (this.maxHeightOfImage == null) { | |||
| if (this.isLandScape) { | |||
| this.maxHeightOfImage = ((View) this.preview.getParent()).getWidth(); | |||
| } else { | |||
| this.maxHeightOfImage = ((View) this.preview.getParent()).getHeight(); | |||
| } | |||
| } | |||
| return this.maxHeightOfImage; | |||
| } | |||
| // Gets the targeted size(width / height). | |||
| private Pair<Integer, Integer> getTargetSize() { | |||
| Integer targetWidth; | |||
| Integer targetHeight; | |||
| Integer maxWidth = this.getMaxWidthOfImage(); | |||
| Integer maxHeight = this.getMaxHeightOfImage(); | |||
| targetWidth = this.isLandScape ? maxHeight : maxWidth; | |||
| targetHeight = this.isLandScape ? maxWidth : maxHeight; | |||
| Log.i(TAG, "height:" + targetHeight + ",width:" + targetWidth); | |||
| return new Pair<>(targetWidth, targetHeight); | |||
| } | |||
| } | |||
| @@ -16,15 +16,19 @@ | |||
| package com.mindspore.imageobject.util; | |||
| import android.app.Activity; | |||
| import android.content.ContentResolver; | |||
| import android.content.Context; | |||
| import android.database.Cursor; | |||
| import android.graphics.Bitmap; | |||
| import android.graphics.BitmapFactory; | |||
| import android.graphics.Matrix; | |||
| import android.media.ExifInterface; | |||
| import android.net.Uri; | |||
| import android.provider.MediaStore; | |||
| import android.util.Log; | |||
| import java.io.ByteArrayInputStream; | |||
| import java.io.ByteArrayOutputStream; | |||
| import java.io.File; | |||
| import java.io.FileNotFoundException; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| @@ -40,112 +44,122 @@ public class BitmapUtils { | |||
| } | |||
| } | |||
| private static String getImagePath(Activity activity, Uri uri) { | |||
| String[] projection = {MediaStore.Images.Media.DATA}; | |||
| Cursor cursor = activity.managedQuery(uri, projection, null, null, null); | |||
| int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); | |||
| cursor.moveToFirst(); | |||
| return cursor.getString(columnIndex); | |||
| } | |||
| public static Bitmap loadFromPath(Activity activity, int id, int width, int height) { | |||
| BitmapFactory.Options options = new BitmapFactory.Options(); | |||
| options.inJustDecodeBounds = true; | |||
| InputStream is = activity.getResources().openRawResource(id); | |||
| int sampleSize = calculateInSampleSize(options, width, height); | |||
| options.inSampleSize = sampleSize; | |||
| options.inJustDecodeBounds = false; | |||
| return zoomImage(BitmapFactory.decodeStream(is), width, height); | |||
| } | |||
| public static Bitmap loadFromPath(Activity activity, Uri uri, int width, int height) { | |||
| BitmapFactory.Options options = new BitmapFactory.Options(); | |||
| options.inJustDecodeBounds = true; | |||
| public static Bitmap getBitmapFormUri(Activity ac, Uri uri) { | |||
| Bitmap bitmap = null; | |||
| try { | |||
| InputStream input = ac.getContentResolver().openInputStream(uri); | |||
| BitmapFactory.Options onlyBoundsOptions = new BitmapFactory.Options(); | |||
| onlyBoundsOptions.inJustDecodeBounds = true; | |||
| onlyBoundsOptions.inDither = true;//optional | |||
| onlyBoundsOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;//optional | |||
| BitmapFactory.decodeStream(input, null, onlyBoundsOptions); | |||
| input.close(); | |||
| int originalWidth = onlyBoundsOptions.outWidth; | |||
| int originalHeight = onlyBoundsOptions.outHeight; | |||
| if ((originalWidth == -1) || (originalHeight == -1)) | |||
| return null; | |||
| float hh = 1920f; | |||
| float ww = 1080f; | |||
| int be = 1; | |||
| if (originalWidth > originalHeight && originalWidth > ww) { | |||
| be = (int) (originalWidth / ww); | |||
| } else if (originalWidth < originalHeight && originalHeight > hh) { | |||
| be = (int) (originalHeight / hh); | |||
| } | |||
| if (be <= 0) { | |||
| be = 1; | |||
| } | |||
| BitmapFactory.Options bitmapOptions = new BitmapFactory.Options(); | |||
| bitmapOptions.inSampleSize = be; | |||
| bitmapOptions.inDither = true;//optional | |||
| bitmapOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;//optional | |||
| input = ac.getContentResolver().openInputStream(uri); | |||
| bitmap = BitmapFactory.decodeStream(input, null, bitmapOptions); | |||
| input.close(); | |||
| String path = getImagePath(activity, uri); | |||
| BitmapFactory.decodeFile(path, options); | |||
| int sampleSize = calculateInSampleSize(options, width, height); | |||
| options.inSampleSize = sampleSize; | |||
| options.inJustDecodeBounds = false; | |||
| Bitmap bitmap = zoomImage(BitmapFactory.decodeFile(path, options), width, height); | |||
| return rotateBitmap(bitmap, getRotationAngle(path)); | |||
| } catch (FileNotFoundException e) { | |||
| e.printStackTrace(); | |||
| } catch (IOException e) { | |||
| e.printStackTrace(); | |||
| } | |||
| return compressImage(bitmap); | |||
| } | |||
| private static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) { | |||
| final int width = options.outWidth; | |||
| final int height = options.outHeight; | |||
| int inSampleSize = 1; | |||
| if (height > reqHeight || width > reqWidth) { | |||
| // Calculate height and required height scale. | |||
| final int heightRatio = Math.round((float) height / (float) reqHeight); | |||
| // Calculate width and required width scale. | |||
| final int widthRatio = Math.round((float) width / (float) reqWidth); | |||
| // Take the larger of the values. | |||
| inSampleSize = heightRatio > widthRatio ? heightRatio : widthRatio; | |||
| public static Bitmap compressImage(Bitmap image) { | |||
| if (image != null) { | |||
| ByteArrayOutputStream baos = new ByteArrayOutputStream(); | |||
| image.compress(Bitmap.CompressFormat.JPEG, 100, baos); | |||
| int options = 100; | |||
| while (baos.toByteArray().length / 1024 > 100) { | |||
| baos.reset(); | |||
| image.compress(Bitmap.CompressFormat.JPEG, options, baos); | |||
| options -= 10; | |||
| } | |||
| ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray()); | |||
| Bitmap bitmap = BitmapFactory.decodeStream(isBm, null, null); | |||
| return bitmap; | |||
| }else { | |||
| return null; | |||
| } | |||
| return inSampleSize; | |||
| } | |||
| // Scale pictures to screen width. | |||
| private static Bitmap zoomImage(Bitmap imageBitmap, int targetWidth, int maxHeight) { | |||
| float scaleFactor = | |||
| Math.max( | |||
| (float) imageBitmap.getWidth() / (float) targetWidth, | |||
| (float) imageBitmap.getHeight() / (float) maxHeight); | |||
| Bitmap resizedBitmap = | |||
| Bitmap.createScaledBitmap( | |||
| imageBitmap, | |||
| (int) (imageBitmap.getWidth() / scaleFactor), | |||
| (int) (imageBitmap.getHeight() / scaleFactor), | |||
| true); | |||
| return resizedBitmap; | |||
| public static File getFileFromMediaUri(Context ac, Uri uri) { | |||
| if (uri.getScheme().toString().compareTo("content") == 0) { | |||
| ContentResolver cr = ac.getContentResolver(); | |||
| Cursor cursor = cr.query(uri, null, null, null, null); | |||
| if (cursor != null) { | |||
| cursor.moveToFirst(); | |||
| String filePath = cursor.getString(cursor.getColumnIndex("_data")); | |||
| cursor.close(); | |||
| if (filePath != null) { | |||
| return new File(filePath); | |||
| } | |||
| } | |||
| } else if (uri.getScheme().toString().compareTo("file") == 0) { | |||
| return new File(uri.toString().replace("file://", "")); | |||
| } | |||
| return null; | |||
| } | |||
| /** | |||
| * Get the rotation angle of the photo. | |||
| * | |||
| * @param path photo path. | |||
| * @return angle. | |||
| */ | |||
| public static int getRotationAngle(String path) { | |||
| int rotation = 0; | |||
| public static int getBitmapDegree(String path) { | |||
| int degree = 0; | |||
| try { | |||
| ExifInterface exifInterface = new ExifInterface(path); | |||
| int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); | |||
| int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, | |||
| ExifInterface.ORIENTATION_NORMAL); | |||
| switch (orientation) { | |||
| case ExifInterface.ORIENTATION_ROTATE_90: | |||
| rotation = 90; | |||
| degree = 90; | |||
| break; | |||
| case ExifInterface.ORIENTATION_ROTATE_180: | |||
| rotation = 180; | |||
| degree = 180; | |||
| break; | |||
| case ExifInterface.ORIENTATION_ROTATE_270: | |||
| rotation = 270; | |||
| break; | |||
| default: | |||
| degree = 270; | |||
| break; | |||
| } | |||
| } catch (IOException e) { | |||
| Log.e(TAG, "Failed to get rotation: " + e.getMessage()); | |||
| e.printStackTrace(); | |||
| } | |||
| return rotation; | |||
| return degree; | |||
| } | |||
| public static Bitmap rotateBitmap(Bitmap bitmap, int angle) { | |||
| public static Bitmap rotateBitmapByDegree(Bitmap bm, int degree) { | |||
| Bitmap returnBm = null; | |||
| Matrix matrix = new Matrix(); | |||
| matrix.postRotate(angle); | |||
| Bitmap result = null; | |||
| matrix.postRotate(degree); | |||
| try { | |||
| result = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); | |||
| returnBm = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), matrix, true); | |||
| } catch (OutOfMemoryError e) { | |||
| Log.e(TAG, "Failed to rotate bitmap: " + e.getMessage()); | |||
| } | |||
| if (result == null) { | |||
| return bitmap; | |||
| if (returnBm == null) { | |||
| returnBm = bm; | |||
| } | |||
| if (bm != returnBm) { | |||
| bm.recycle(); | |||
| } | |||
| return result; | |||
| return returnBm; | |||
| } | |||
| } | |||
| @@ -26,7 +26,7 @@ | |||
| android:drawableStart="@drawable/logo2" | |||
| android:drawablePadding="5dp" | |||
| android:gravity="center_vertical" | |||
| android:text="@string/app_name_title" | |||
| android:text="@string/app_name" | |||
| android:textColor="@color/white" | |||
| android:textSize="20sp" /> | |||
| @@ -40,6 +40,4 @@ | |||
| android:background="@color/colorPrimary" | |||
| android:gravity="center" | |||
| android:orientation="vertical" /> | |||
| </RelativeLayout> | |||
| @@ -0,0 +1,828 @@ | |||
| <resources> | |||
| <string name="app_name">MindSpore</string> | |||
| <string name="title_time">Inference Time</string> | |||
| <string name="title_keep">Continue to identify</string> | |||
| <string name="image_invalid">The image path you selected is not valid. Please choose again</string> | |||
| <string name="train_invalid">Sorry, there is no object identified in this picture. Try another picture</string> | |||
| <string-array name="image_category"> | |||
| <item>Herd</item> | |||
| <item>Safari</item> | |||
| <item>Bangle</item> | |||
| <item>Cushion</item> | |||
| <item>Countertop</item> | |||
| <item>Prom</item> | |||
| <item>Branch</item> | |||
| <item>Sports</item> | |||
| <item>Sky</item> | |||
| <item>Community</item> | |||
| <item>Wheel</item> | |||
| <item>Cola</item> | |||
| <item>Tuxedo</item> | |||
| <item>Flowerpot</item> | |||
| <item>Team</item> | |||
| <item>Computer</item> | |||
| <item>Unicycle</item> | |||
| <item>Brig</item> | |||
| <item>Aerospace engineering</item> | |||
| <item>Scuba diving</item> | |||
| <item>Goggles</item> | |||
| <item>Fruit</item> | |||
| <item>Badminton</item> | |||
| <item>Horse</item> | |||
| <item>Sunglasses</item> | |||
| <item>Fun</item> | |||
| <item>Prairie</item> | |||
| <item>Poster</item> | |||
| <item>Flag</item> | |||
| <item>Speedboat</item> | |||
| <item>Eyelash</item> | |||
| <item>Veil</item> | |||
| <item>Mobile phone</item> | |||
| <item>Wheelbarrow</item> | |||
| <item>Saucer</item> | |||
| <item>Leather</item> | |||
| <item>Drawer</item> | |||
| <item>Paper</item> | |||
| <item>Pier</item> | |||
| <item>Waterfowl</item> | |||
| <item>Tights</item> | |||
| <item>Rickshaw</item> | |||
| <item>Vegetable</item> | |||
| <item>Handrail</item> | |||
| <item>Ice</item> | |||
| <item>Metal</item> | |||
| <item>Flower</item> | |||
| <item>Wing</item> | |||
| <item>Silverware</item> | |||
| <item>Event</item> | |||
| <item>Skyline</item> | |||
| <item>Money</item> | |||
| <item>Comics</item> | |||
| <item>Handbag</item> | |||
| <item>Porcelain</item> | |||
| <item>Rodeo</item> | |||
| <item>Curtain</item> | |||
| <item>Tile</item> | |||
| <item>Human mouth</item> | |||
| <item>Army</item> | |||
| <item>Menu</item> | |||
| <item>Boat</item> | |||
| <item>Snowboarding</item> | |||
| <item>Cairn terrier</item> | |||
| <item>Net</item> | |||
| <item>Pasteles</item> | |||
| <item>Cup</item> | |||
| <item>Rugby</item> | |||
| <item>Pho</item> | |||
| <item>Cap</item> | |||
| <item>Human hair</item> | |||
| <item>Surfing</item> | |||
| <item>Loveseat</item> | |||
| <item>Museum</item> | |||
| <item>Shipwreck</item> | |||
| <item>Trunk (Tree)</item> | |||
| <item>Plush</item> | |||
| <item>Monochrome</item> | |||
| <item>Volcano</item> | |||
| <item>Rock</item> | |||
| <item>Pillow</item> | |||
| <item>Presentation</item> | |||
| <item>Nebula</item> | |||
| <item>Subwoofer</item> | |||
| <item>Lake</item> | |||
| <item>Sledding</item> | |||
| <item>Bangs</item> | |||
| <item>Tablecloth</item> | |||
| <item>Necklace</item> | |||
| <item>Swimwear</item> | |||
| <item>Standing</item> | |||
| <item>Jeans</item> | |||
| <item>Carnival</item> | |||
| <item>Softball</item> | |||
| <item>Centrepiece</item> | |||
| <item>Skateboarder</item> | |||
| <item>Cake</item> | |||
| <item>Dragon</item> | |||
| <item>Aurora</item> | |||
| <item>Skiing</item> | |||
| <item>Bathroom</item> | |||
| <item>Dog</item> | |||
| <item>Needlework</item> | |||
| <item>Umbrella</item> | |||
| <item>Church</item> | |||
| <item>Fire</item> | |||
| <item>Piano</item> | |||
| <item>Denim</item> | |||
| <item>Bridle</item> | |||
| <item>Cabinetry</item> | |||
| <item>Lipstick</item> | |||
| <item>Ring</item> | |||
| <item>Television</item> | |||
| <item>Roller</item> | |||
| <item>Seal</item> | |||
| <item>Concert</item> | |||
| <item>Product</item> | |||
| <item>News</item> | |||
| <item>Fast food</item> | |||
| <item>Horn (Animal)</item> | |||
| <item>Tattoo</item> | |||
| <item>Bird</item> | |||
| <item>Bridegroom</item> | |||
| <item>Love</item> | |||
| <item>Helmet</item> | |||
| <item>Dinosaur</item> | |||
| <item>Icing</item> | |||
| <item>Miniature</item> | |||
| <item>Tire</item> | |||
| <item>Toy</item> | |||
| <item>Icicle</item> | |||
| <item>Jacket</item> | |||
| <item>Coffee</item> | |||
| <item>Mosque</item> | |||
| <item>Rowing</item> | |||
| <item>Wetsuit</item> | |||
| <item>Camping</item> | |||
| <item>Underwater</item> | |||
| <item>Christmas</item> | |||
| <item>Gelato</item> | |||
| <item>Whiteboard</item> | |||
| <item>Field</item> | |||
| <item>Ragdoll</item> | |||
| <item>Construction</item> | |||
| <item>Lampshade</item> | |||
| <item>Palace</item> | |||
| <item>Meal</item> | |||
| <item>Factory</item> | |||
| <item>Cage</item> | |||
| <item>Clipper (Boat)</item> | |||
| <item>Gymnastics</item> | |||
| <item>Turtle</item> | |||
| <item>Human foot</item> | |||
| <item>Marriage</item> | |||
| <item>Web page</item> | |||
| <item>Human beard</item> | |||
| <item>Fog</item> | |||
| <item>Wool</item> | |||
| <item>Cappuccino</item> | |||
| <item>Lighthouse</item> | |||
| <item>Lego</item> | |||
| <item>Sparkler</item> | |||
| <item>Sari</item> | |||
| <item>Model</item> | |||
| <item>Temple</item> | |||
| <item>Beanie</item> | |||
| <item>Building</item> | |||
| <item>Waterfall</item> | |||
| <item>Penguin</item> | |||
| <item>Cave</item> | |||
| <item>Stadium</item> | |||
| <item>Smile</item> | |||
| <item>Human hand</item> | |||
| <item>Park</item> | |||
| <item>Desk</item> | |||
| <item>Shetland sheepdog</item> | |||
| <item>Bar</item> | |||
| <item>Eating</item> | |||
| <item>Neon</item> | |||
| <item>Dalmatian</item> | |||
| <item>Crocodile</item> | |||
| <item>Wakeboarding</item> | |||
| <item>Longboard</item> | |||
| <item>Road</item> | |||
| <item>Race</item> | |||
| <item>Kitchen</item> | |||
| <item>Odometer</item> | |||
| <item>Cliff</item> | |||
| <item>Fiction</item> | |||
| <item>School</item> | |||
| <item>Interaction</item> | |||
| <item>Bullfighting</item> | |||
| <item>Boxer</item> | |||
| <item>Gown</item> | |||
| <item>Aquarium</item> | |||
| <item>Superhero</item> | |||
| <item>Pie</item> | |||
| <item>Asphalt</item> | |||
| <item>Surfboard</item> | |||
| <item>Cheeseburger</item> | |||
| <item>Screenshot</item> | |||
| <item>Supper</item> | |||
| <item>Laugh</item> | |||
| <item>Lunch</item> | |||
| <item>Party </item> | |||
| <item>Glacier</item> | |||
| <item>Bench</item> | |||
| <item>Grandparent</item> | |||
| <item>Sink</item> | |||
| <item>Pomacentridae</item> | |||
| <item>Blazer</item> | |||
| <item>Brick</item> | |||
| <item>Space</item> | |||
| <item>Backpacking</item> | |||
| <item>Stuffed toy</item> | |||
| <item>Sushi</item> | |||
| <item>Glitter</item> | |||
| <item>Bonfire</item> | |||
| <item>Castle</item> | |||
| <item>Marathon</item> | |||
| <item>Pizza</item> | |||
| <item>Beach</item> | |||
| <item>Human ear</item> | |||
| <item>Racing</item> | |||
| <item>Sitting</item> | |||
| <item>Iceberg</item> | |||
| <item>Shelf</item> | |||
| <item>Vehicle</item> | |||
| <item>Pop music</item> | |||
| <item>Playground</item> | |||
| <item>Clown</item> | |||
| <item>Car</item> | |||
| <item>Rein</item> | |||
| <item>Fur</item> | |||
| <item>Musician</item> | |||
| <item>Casino</item> | |||
| <item>Baby</item> | |||
| <item>Alcohol</item> | |||
| <item>Strap</item> | |||
| <item>Reef</item> | |||
| <item>Balloon</item> | |||
| <item>Outerwear</item> | |||
| <item>Cathedral</item> | |||
| <item>Competition</item> | |||
| <item>Joker</item> | |||
| <item>Blackboard</item> | |||
| <item>Bunk bed</item> | |||
| <item>Bear</item> | |||
| <item>Moon</item> | |||
| <item>Archery</item> | |||
| <item>Polo</item> | |||
| <item>River</item> | |||
| <item>Fishing</item> | |||
| <item>Ferris wheel</item> | |||
| <item>Mortarboard</item> | |||
| <item>Bracelet</item> | |||
| <item>Flesh</item> | |||
| <item>Statue</item> | |||
| <item>Farm</item> | |||
| <item>Desert</item> | |||
| <item>Chain</item> | |||
| <item>Aircraft</item> | |||
| <item>Textile</item> | |||
| <item>Hot dog</item> | |||
| <item>Knitting</item> | |||
| <item>Singer</item> | |||
| <item>Juice</item> | |||
| <item>Circus</item> | |||
| <item>Chair</item> | |||
| <item>Musical instrument</item> | |||
| <item>Room</item> | |||
| <item>Crochet</item> | |||
| <item>Sailboat</item> | |||
| <item>Newspaper</item> | |||
| <item>Santa claus</item> | |||
| <item>Swamp</item> | |||
| <item>Skyscraper</item> | |||
| <item>Skin</item> | |||
| <item>Rocket</item> | |||
| <item>Aviation</item> | |||
| <item>Airliner</item> | |||
| <item>Garden</item> | |||
| <item>Ruins</item> | |||
| <item>Storm</item> | |||
| <item>Glasses</item> | |||
| <item>Balance</item> | |||
| <item>Nail (Body part)</item> | |||
| <item>Rainbow</item> | |||
| <item>Soil </item> | |||
| <item>Vacation </item> | |||
| <item>Moustache</item> | |||
| <item>Doily</item> | |||
| <item>Food</item> | |||
| <item>Bride </item> | |||
| <item>Cattle</item> | |||
| <item>Pocket</item> | |||
| <item>Infrastructure</item> | |||
| <item>Train</item> | |||
| <item>Gerbil</item> | |||
| <item>Fireworks</item> | |||
| <item>Pet</item> | |||
| <item>Dam</item> | |||
| <item>Crew</item> | |||
| <item>Couch</item> | |||
| <item>Bathing</item> | |||
| <item>Quilting</item> | |||
| <item>Motorcycle</item> | |||
| <item>Butterfly</item> | |||
| <item>Sled</item> | |||
| <item>Watercolor paint</item> | |||
| <item>Rafting</item> | |||
| <item>Monument</item> | |||
| <item>Lightning</item> | |||
| <item>Sunset</item> | |||
| <item>Bumper</item> | |||
| <item>Shoe</item> | |||
| <item>Waterskiing</item> | |||
| <item>Sneakers</item> | |||
| <item>Tower</item> | |||
| <item>Insect</item> | |||
| <item>Pool</item> | |||
| <item>Placemat</item> | |||
| <item>Airplane</item> | |||
| <item>Plant</item> | |||
| <item>Jungle</item> | |||
| <item>Armrest</item> | |||
| <item>Duck</item> | |||
| <item>Dress</item> | |||
| <item>Tableware</item> | |||
| <item>Petal</item> | |||
| <item>Bus</item> | |||
| <item>Hanukkah</item> | |||
| <item>Forest</item> | |||
| <item>Hat</item> | |||
| <item>Barn</item> | |||
| <item>Tubing</item> | |||
| <item>Snorkeling</item> | |||
| <item>Cool</item> | |||
| <item>Cookware and bakeware</item> | |||
| <item>Cycling</item> | |||
| <item>Swing (Seat)</item> | |||
| <item>Muscle</item> | |||
| <item>Cat</item> | |||
| <item>Skateboard</item> | |||
| <item>Star</item> | |||
| <item>Toe</item> | |||
| <item>Junk</item> | |||
| <item>Bicycle</item> | |||
| <item>Bedroom</item> | |||
| <item>Person</item> | |||
| <item>Sand</item> | |||
| <item>Canyon</item> | |||
| <item>Tie</item> | |||
| <item>Twig</item> | |||
| <item>Sphynx</item> | |||
| <item>Supervillain</item> | |||
| <item>Nightclub</item> | |||
| <item>Ranch</item> | |||
| <item>Pattern</item> | |||
| <item>Shorts</item> | |||
| <item>Himalayan</item> | |||
| <item>Wall</item> | |||
| <item>Leggings</item> | |||
| <item>Windsurfing</item> | |||
| <item>Deejay</item> | |||
| <item>Dance</item> | |||
| <item>Van</item> | |||
| <item>Bento</item> | |||
| <item>Sleep</item> | |||
| <item>Wine</item> | |||
| <item>Picnic</item> | |||
| <item>Leisure</item> | |||
| <item>Dune</item> | |||
| <item>Crowd</item> | |||
| <item>Kayak</item> | |||
| <item>Ballroom</item> | |||
| <item>Selfie</item> | |||
| <item>Graduation</item> | |||
| <item>Frigate</item> | |||
| <item>Mountain</item> | |||
| <item>Dude</item> | |||
| <item>Windshield</item> | |||
| <item>Skiff</item> | |||
| <item>Class</item> | |||
| <item>Scarf</item> | |||
| <item>Bull</item> | |||
| <item>Soccer</item> | |||
| <item>Bag</item> | |||
| <item>Basset hound</item> | |||
| <item>Tractor</item> | |||
| <item>Swimming</item> | |||
| <item>Running</item> | |||
| <item>Track</item> | |||
| <item>Helicopter</item> | |||
| <item>Pitch</item> | |||
| <item>Clock</item> | |||
| <item>Song</item> | |||
| <item>Jersey</item> | |||
| <item>Stairs</item> | |||
| <item>Flap</item> | |||
| <item>Jewellery</item> | |||
| <item>Bridge</item> | |||
| <item>Cuisine</item> | |||
| <item>Bread</item> | |||
| <item>Caving</item> | |||
| <item>Shell</item> | |||
| <item>Wreath</item> | |||
| <item>Roof</item> | |||
| <item>Cookie</item> | |||
| <item>Canoe</item> | |||
| </string-array> | |||
| <string-array name="scene_category"> | |||
| <item>airfield</item> | |||
| <item>airplane_cabin</item> | |||
| <item>airport_terminal</item> | |||
| <item>alcove</item> | |||
| <item>alley</item> | |||
| <item>amphitheater</item> | |||
| <item>amusement_arcade</item> | |||
| <item>amusement_park</item> | |||
| <item>apartment_building/outdoor</item> | |||
| <item>aquarium</item> | |||
| <item>aqueduct</item> | |||
| <item>arcade</item> | |||
| <item>arch</item> | |||
| <item>archaelogical_excavation</item> | |||
| <item>archive</item> | |||
| <item>arena/hockey</item> | |||
| <item>arena/performance</item> | |||
| <item>arena/rodeo</item> | |||
| <item>army_base</item> | |||
| <item>art_gallery</item> | |||
| <item>art_school</item> | |||
| <item>art_studio</item> | |||
| <item>artists_loft</item> | |||
| <item>assembly_line</item> | |||
| <item>athletic_field/outdoor</item> | |||
| <item>atrium/public</item> | |||
| <item>attic</item> | |||
| <item>auditorium</item> | |||
| <item>auto_factory</item> | |||
| <item>auto_showroom</item> | |||
| <item>badlands</item> | |||
| <item>bakery/shop</item> | |||
| <item>balcony/exterior</item> | |||
| <item>balcony/interior</item> | |||
| <item>ball_pit</item> | |||
| <item>ballroom</item> | |||
| <item>bamboo_forest</item> | |||
| <item>bank_vault</item> | |||
| <item>banquet_hall</item> | |||
| <item>bar</item> | |||
| <item>barn</item> | |||
| <item>barndoor</item> | |||
| <item>baseball_field</item> | |||
| <item>basement</item> | |||
| <item>basketball_court/indoor</item> | |||
| <item>bathroom</item> | |||
| <item>bazaar/indoor</item> | |||
| <item>bazaar/outdoor</item> | |||
| <item>beach</item> | |||
| <item>beach_house</item> | |||
| <item>beauty_salon</item> | |||
| <item>bedchamber</item> | |||
| <item>bedroom</item> | |||
| <item>beer_garden</item> | |||
| <item>beer_hall</item> | |||
| <item>berth</item> | |||
| <item>biology_laboratory</item> | |||
| <item>boardwalk</item> | |||
| <item>boat_deck</item> | |||
| <item>boathouse</item> | |||
| <item>bookstore</item> | |||
| <item>booth/indoor</item> | |||
| <item>botanical_garden</item> | |||
| <item>bow_window/indoor</item> | |||
| <item>bowling_alley</item> | |||
| <item>boxing_ring</item> | |||
| <item>bridge</item> | |||
| <item>building_facade</item> | |||
| <item>bullring</item> | |||
| <item>burial_chamber</item> | |||
| <item>bus_interior</item> | |||
| <item>bus_station/indoor</item> | |||
| <item>butchers_shop</item> | |||
| <item>butte</item> | |||
| <item>cabin/outdoor</item> | |||
| <item>cafeteria</item> | |||
| <item>campsite</item> | |||
| <item>campus</item> | |||
| <item>canal/natural</item> | |||
| <item>canal/urban</item> | |||
| <item>candy_store</item> | |||
| <item>canyon</item> | |||
| <item>car_interior</item> | |||
| <item>carrousel</item> | |||
| <item>castle</item> | |||
| <item>catacomb</item> | |||
| <item>cemetery</item> | |||
| <item>chalet</item> | |||
| <item>chemistry_lab</item> | |||
| <item>childs_room</item> | |||
| <item>church/indoor</item> | |||
| <item>church/outdoor</item> | |||
| <item>classroom</item> | |||
| <item>clean_room</item> | |||
| <item>cliff</item> | |||
| <item>closet</item> | |||
| <item>clothing_store</item> | |||
| <item>coast</item> | |||
| <item>cockpit</item> | |||
| <item>coffee_shop</item> | |||
| <item>computer_room</item> | |||
| <item>conference_center</item> | |||
| <item>conference_room</item> | |||
| <item>construction_site</item> | |||
| <item>corn_field</item> | |||
| <item>corral</item> | |||
| <item>corridor</item> | |||
| <item>cottage</item> | |||
| <item>courthouse</item> | |||
| <item>courtyard</item> | |||
| <item>creek</item> | |||
| <item>crevasse</item> | |||
| <item>crosswalk</item> | |||
| <item>dam</item> | |||
| <item>delicatessen</item> | |||
| <item>department_store</item> | |||
| <item>desert/sand</item> | |||
| <item>desert/vegetation</item> | |||
| <item>desert_road</item> | |||
| <item>diner/outdoor</item> | |||
| <item>dining_hall</item> | |||
| <item>dining_room</item> | |||
| <item>discotheque</item> | |||
| <item>doorway/outdoor</item> | |||
| <item>dorm_room</item> | |||
| <item>downtown</item> | |||
| <item>dressing_room</item> | |||
| <item>driveway</item> | |||
| <item>drugstore</item> | |||
| <item>elevator/door</item> | |||
| <item>elevator_lobby</item> | |||
| <item>elevator_shaft</item> | |||
| <item>embassy</item> | |||
| <item>engine_room</item> | |||
| <item>entrance_hall</item> | |||
| <item>escalator/indoor</item> | |||
| <item>excavation</item> | |||
| <item>fabric_store</item> | |||
| <item>farm</item> | |||
| <item>fastfood_restaurant</item> | |||
| <item>field/cultivated</item> | |||
| <item>field/wild</item> | |||
| <item>field_road</item> | |||
| <item>fire_escape</item> | |||
| <item>fire_station</item> | |||
| <item>fishpond</item> | |||
| <item>flea_market/indoor</item> | |||
| <item>florist_shop/indoor</item> | |||
| <item>food_court</item> | |||
| <item>football_field</item> | |||
| <item>forest/broadleaf</item> | |||
| <item>forest_path</item> | |||
| <item>forest_road</item> | |||
| <item>formal_garden</item> | |||
| <item>fountain</item> | |||
| <item>galley</item> | |||
| <item>garage/indoor</item> | |||
| <item>garage/outdoor</item> | |||
| <item>gas_station</item> | |||
| <item>gazebo/exterior</item> | |||
| <item>general_store/indoor</item> | |||
| <item>general_store/outdoor</item> | |||
| <item>gift_shop</item> | |||
| <item>glacier</item> | |||
| <item>golf_course</item> | |||
| <item>greenhouse/indoor</item> | |||
| <item>greenhouse/outdoor</item> | |||
| <item>grotto</item> | |||
| <item>gymnasium/indoor</item> | |||
| <item>hangar/indoor</item> | |||
| <item>hangar/outdoor</item> | |||
| <item>harbor</item> | |||
| <item>hardware_store</item> | |||
| <item>hayfield</item> | |||
| <item>heliport</item> | |||
| <item>highway</item> | |||
| <item>home_office</item> | |||
| <item>home_theater</item> | |||
| <item>hospital</item> | |||
| <item>hospital_room</item> | |||
| <item>hot_spring</item> | |||
| <item>hotel/outdoor</item> | |||
| <item>hotel_room</item> | |||
| <item>house</item> | |||
| <item>hunting_lodge/outdoor</item> | |||
| <item>ice_cream_parlor</item> | |||
| <item>ice_floe</item> | |||
| <item>ice_shelf</item> | |||
| <item>ice_skating_rink/indoor</item> | |||
| <item>ice_skating_rink/outdoor</item> | |||
| <item>iceberg</item> | |||
| <item>igloo</item> | |||
| <item>industrial_area</item> | |||
| <item>inn/outdoor</item> | |||
| <item>islet</item> | |||
| <item>jacuzzi/indoor</item> | |||
| <item>jail_cell</item> | |||
| <item>japanese_garden</item> | |||
| <item>jewelry_shop</item> | |||
| <item>junkyard</item> | |||
| <item>kasbah</item> | |||
| <item>kennel/outdoor</item> | |||
| <item>kindergarden_classroom</item> | |||
| <item>kitchen</item> | |||
| <item>lagoon</item> | |||
| <item>lake/natural</item> | |||
| <item>landfill</item> | |||
| <item>landing_deck</item> | |||
| <item>laundromat</item> | |||
| <item>lawn</item> | |||
| <item>lecture_room</item> | |||
| <item>legislative_chamber</item> | |||
| <item>library/indoor</item> | |||
| <item>library/outdoor</item> | |||
| <item>lighthouse</item> | |||
| <item>living_room</item> | |||
| <item>loading_dock</item> | |||
| <item>lobby</item> | |||
| <item>lock_chamber</item> | |||
| <item>locker_room</item> | |||
| <item>mansion</item> | |||
| <item>manufactured_home</item> | |||
| <item>market/indoor</item> | |||
| <item>market/outdoor</item> | |||
| <item>marsh</item> | |||
| <item>martial_arts_gym</item> | |||
| <item>mausoleum</item> | |||
| <item>medina</item> | |||
| <item>mezzanine</item> | |||
| <item>moat/water</item> | |||
| <item>mosque/outdoor</item> | |||
| <item>motel</item> | |||
| <item>mountain</item> | |||
| <item>mountain_path</item> | |||
| <item>mountain_snowy</item> | |||
| <item>movie_theater/indoor</item> | |||
| <item>museum/indoor</item> | |||
| <item>museum/outdoor</item> | |||
| <item>music_studio</item> | |||
| <item>natural_history_museum</item> | |||
| <item>nursery</item> | |||
| <item>nursing_home</item> | |||
| <item>oast_house</item> | |||
| <item>ocean</item> | |||
| <item>office</item> | |||
| <item>office_building</item> | |||
| <item>office_cubicles</item> | |||
| <item>oilrig</item> | |||
| <item>operating_room</item> | |||
| <item>orchard</item> | |||
| <item>orchestra_pit</item> | |||
| <item>pagoda</item> | |||
| <item>palace</item> | |||
| <item>pantry</item> | |||
| <item>park</item> | |||
| <item>parking_garage/indoor</item> | |||
| <item>parking_garage/outdoor</item> | |||
| <item>parking_lot</item> | |||
| <item>pasture</item> | |||
| <item>patio</item> | |||
| <item>pavilion</item> | |||
| <item>pet_shop</item> | |||
| <item>pharmacy</item> | |||
| <item>phone_booth</item> | |||
| <item>physics_laboratory</item> | |||
| <item>picnic_area</item> | |||
| <item>pier</item> | |||
| <item>pizzeria</item> | |||
| <item>playground</item> | |||
| <item>playroom</item> | |||
| <item>plaza</item> | |||
| <item>pond</item> | |||
| <item>porch</item> | |||
| <item>promenade</item> | |||
| <item>pub/indoor</item> | |||
| <item>racecourse</item> | |||
| <item>raceway</item> | |||
| <item>raft</item> | |||
| <item>railroad_track</item> | |||
| <item>rainforest</item> | |||
| <item>reception</item> | |||
| <item>recreation_room</item> | |||
| <item>repair_shop</item> | |||
| <item>residential_neighborhood</item> | |||
| <item>restaurant</item> | |||
| <item>restaurant_kitchen</item> | |||
| <item>restaurant_patio</item> | |||
| <item>rice_paddy</item> | |||
| <item>river</item> | |||
| <item>rock_arch</item> | |||
| <item>roof_garden</item> | |||
| <item>rope_bridge</item> | |||
| <item>ruin</item> | |||
| <item>runway</item> | |||
| <item>sandbox</item> | |||
| <item>sauna</item> | |||
| <item>schoolhouse</item> | |||
| <item>science_museum</item> | |||
| <item>server_room</item> | |||
| <item>shed</item> | |||
| <item>shoe_shop</item> | |||
| <item>shopfront</item> | |||
| <item>shopping_mall/indoor</item> | |||
| <item>shower</item> | |||
| <item>ski_resort</item> | |||
| <item>ski_slope</item> | |||
| <item>sky</item> | |||
| <item>skyscraper</item> | |||
| <item>slum</item> | |||
| <item>snowfield</item> | |||
| <item>soccer_field</item> | |||
| <item>stable</item> | |||
| <item>stadium/baseball</item> | |||
| <item>stadium/football</item> | |||
| <item>stadium/soccer</item> | |||
| <item>stage/indoor</item> | |||
| <item>stage/outdoor</item> | |||
| <item>staircase</item> | |||
| <item>storage_room</item> | |||
| <item>street</item> | |||
| <item>subway_station/platform</item> | |||
| <item>supermarket</item> | |||
| <item>sushi_bar</item> | |||
| <item>swamp</item> | |||
| <item>swimming_hole</item> | |||
| <item>swimming_pool/indoor</item> | |||
| <item>swimming_pool/outdoor</item> | |||
| <item>synagogue/outdoor</item> | |||
| <item>television_room</item> | |||
| <item>television_studio</item> | |||
| <item>temple/asia</item> | |||
| <item>throne_room</item> | |||
| <item>ticket_booth</item> | |||
| <item>topiary_garden</item> | |||
| <item>tower</item> | |||
| <item>toyshop</item> | |||
| <item>train_interior</item> | |||
| <item>train_station/platform</item> | |||
| <item>tree_farm</item> | |||
| <item>tree_house</item> | |||
| <item>trench</item> | |||
| <item>tundra</item> | |||
| <item>underwater/ocean_deep</item> | |||
| <item>utility_room</item> | |||
| <item>valley</item> | |||
| <item>vegetable_garden</item> | |||
| <item>veterinarians_office</item> | |||
| <item>viaduct</item> | |||
| <item>village</item> | |||
| <item>vineyard</item> | |||
| <item>volcano</item> | |||
| <item>volleyball_court/outdoor</item> | |||
| <item>waiting_room</item> | |||
| <item>water_park</item> | |||
| <item>water_tower</item> | |||
| <item>waterfall</item> | |||
| <item>watering_hole</item> | |||
| <item>wave</item> | |||
| <item>wet_bar</item> | |||
| <item>wheat_field</item> | |||
| <item>wind_farm</item> | |||
| <item>windmill</item> | |||
| <item>yard</item> | |||
| <item>youth_hostel</item> | |||
| <item>zen_garden</item> | |||
| </string-array> | |||
| <string-array name="grbage_sort_map"> | |||
| <item>Recyclables</item> | |||
| <item>Dry garbage</item> | |||
| <item>Hazardous garbage</item> | |||
| <item>Wet garbage</item> | |||
| </string-array> | |||
| <string-array name="grbage_sort_detailed_map"> | |||
| <item>Plastic bottle</item> | |||
| <item>Hat</item> | |||
| <item>Newspaper</item> | |||
| <item>Can</item> | |||
| <item>Glasswork</item> | |||
| <item>Glass Bottle</item> | |||
| <item>Cardboard</item> | |||
| <item>Basketball</item> | |||
| <item>Paper</item> | |||
| <item>Metalwork</item> | |||
| <item>Disposable chopsticks</item> | |||
| <item>Lighter</item> | |||
| <item>Broom</item> | |||
| <item>Old Mirror</item> | |||
| <item>Toothbrush</item> | |||
| <item>Dirty clothes</item> | |||
| <item>Shell</item> | |||
| <item>Ceramic Bowl</item> | |||
| <item>Paint Bucket</item> | |||
| <item>Battery</item> | |||
| <item>Fluorescent Light</item> | |||
| <item>Pill Capsule</item> | |||
| <item>Orange Peel</item> | |||
| <item>Leaf</item> | |||
| <item>Eggshell</item> | |||
| <item>Banana peel</item> | |||
| </string-array> | |||
| </resources> | |||
| @@ -0,0 +1,11 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <resources> | |||
| <string name="app_name">MindSpore</string> | |||
| <string name="title_time">推理时间</string> | |||
| <string name="title_keep">正在识别</string> | |||
| <string name="image_invalid">您选择的图像路径无效。请再次选择</string> | |||
| <string name="train_invalid">对不起,此图片中没有任何物体。请尝试另一张图片</string> | |||
| </resources> | |||
| @@ -1,25 +1,828 @@ | |||
| <resources> | |||
| <string name="app_name">HiMindSpore</string> | |||
| <string name="app_name_title">MindSpore</string> | |||
| <string name="switch_custom">custom</string> | |||
| <string name="app_name">MindSpore</string> | |||
| <string name="title_image">Image Classification</string> | |||
| <string name="title_image_garbage">Garbage Classification</string> | |||
| <string name="title_object">Photo Detection</string> | |||
| <string name="title_object_camera">Camera Detection</string> | |||
| <string name="title_pose_net">PoseNet</string> | |||
| <string name="title_style_transfer">Style Transfer</string> | |||
| <string name="title_source">Source Code</string> | |||
| <string name="title_help">Help And FeedBack</string> | |||
| <string name="title_time">Inference Time</string> | |||
| <string name="title_keep">Keep moving.</string> | |||
| <string name="image_invalid">The image path you selected is not valid. Please choose again</string> | |||
| <string name="train_invalid">Sorry, there is no object identified in this picture. Try another picture</string> | |||
| <string name="title_photo">Photo</string> | |||
| <string name="title_camera">Camera</string> | |||
| <string-array name="image_category"> | |||
| <item>Herd</item> | |||
| <item>Safari</item> | |||
| <item>Bangle</item> | |||
| <item>Cushion</item> | |||
| <item>Countertop</item> | |||
| <item>Prom</item> | |||
| <item>Branch</item> | |||
| <item>Sports</item> | |||
| <item>Sky</item> | |||
| <item>Community</item> | |||
| <item>Wheel</item> | |||
| <item>Cola</item> | |||
| <item>Tuxedo</item> | |||
| <item>Flowerpot</item> | |||
| <item>Team</item> | |||
| <item>Computer</item> | |||
| <item>Unicycle</item> | |||
| <item>Brig</item> | |||
| <item>Aerospace engineering</item> | |||
| <item>Scuba diving</item> | |||
| <item>Goggles</item> | |||
| <item>Fruit</item> | |||
| <item>Badminton</item> | |||
| <item>Horse</item> | |||
| <item>Sunglasses</item> | |||
| <item>Fun</item> | |||
| <item>Prairie</item> | |||
| <item>Poster</item> | |||
| <item>Flag</item> | |||
| <item>Speedboat</item> | |||
| <item>Eyelash</item> | |||
| <item>Veil</item> | |||
| <item>Mobile phone</item> | |||
| <item>Wheelbarrow</item> | |||
| <item>Saucer</item> | |||
| <item>Leather</item> | |||
| <item>Drawer</item> | |||
| <item>Paper</item> | |||
| <item>Pier</item> | |||
| <item>Waterfowl</item> | |||
| <item>Tights</item> | |||
| <item>Rickshaw</item> | |||
| <item>Vegetable</item> | |||
| <item>Handrail</item> | |||
| <item>Ice</item> | |||
| <item>Metal</item> | |||
| <item>Flower</item> | |||
| <item>Wing</item> | |||
| <item>Silverware</item> | |||
| <item>Event</item> | |||
| <item>Skyline</item> | |||
| <item>Money</item> | |||
| <item>Comics</item> | |||
| <item>Handbag</item> | |||
| <item>Porcelain</item> | |||
| <item>Rodeo</item> | |||
| <item>Curtain</item> | |||
| <item>Tile</item> | |||
| <item>Human mouth</item> | |||
| <item>Army</item> | |||
| <item>Menu</item> | |||
| <item>Boat</item> | |||
| <item>Snowboarding</item> | |||
| <item>Cairn terrier</item> | |||
| <item>Net</item> | |||
| <item>Pasteles</item> | |||
| <item>Cup</item> | |||
| <item>Rugby</item> | |||
| <item>Pho</item> | |||
| <item>Cap</item> | |||
| <item>Human hair</item> | |||
| <item>Surfing</item> | |||
| <item>Loveseat</item> | |||
| <item>Museum</item> | |||
| <item>Shipwreck</item> | |||
| <item>Trunk (Tree)</item> | |||
| <item>Plush</item> | |||
| <item>Monochrome</item> | |||
| <item>Volcano</item> | |||
| <item>Rock</item> | |||
| <item>Pillow</item> | |||
| <item>Presentation</item> | |||
| <item>Nebula</item> | |||
| <item>Subwoofer</item> | |||
| <item>Lake</item> | |||
| <item>Sledding</item> | |||
| <item>Bangs</item> | |||
| <item>Tablecloth</item> | |||
| <item>Necklace</item> | |||
| <item>Swimwear</item> | |||
| <item>Standing</item> | |||
| <item>Jeans</item> | |||
| <item>Carnival</item> | |||
| <item>Softball</item> | |||
| <item>Centrepiece</item> | |||
| <item>Skateboarder</item> | |||
| <item>Cake</item> | |||
| <item>Dragon</item> | |||
| <item>Aurora</item> | |||
| <item>Skiing</item> | |||
| <item>Bathroom</item> | |||
| <item>Dog</item> | |||
| <item>Needlework</item> | |||
| <item>Umbrella</item> | |||
| <item>Church</item> | |||
| <item>Fire</item> | |||
| <item>Piano</item> | |||
| <item>Denim</item> | |||
| <item>Bridle</item> | |||
| <item>Cabinetry</item> | |||
| <item>Lipstick</item> | |||
| <item>Ring</item> | |||
| <item>Television</item> | |||
| <item>Roller</item> | |||
| <item>Seal</item> | |||
| <item>Concert</item> | |||
| <item>Product</item> | |||
| <item>News</item> | |||
| <item>Fast food</item> | |||
| <item>Horn (Animal)</item> | |||
| <item>Tattoo</item> | |||
| <item>Bird</item> | |||
| <item>Bridegroom</item> | |||
| <item>Love</item> | |||
| <item>Helmet</item> | |||
| <item>Dinosaur</item> | |||
| <item>Icing</item> | |||
| <item>Miniature</item> | |||
| <item>Tire</item> | |||
| <item>Toy</item> | |||
| <item>Icicle</item> | |||
| <item>Jacket</item> | |||
| <item>Coffee</item> | |||
| <item>Mosque</item> | |||
| <item>Rowing</item> | |||
| <item>Wetsuit</item> | |||
| <item>Camping</item> | |||
| <item>Underwater</item> | |||
| <item>Christmas</item> | |||
| <item>Gelato</item> | |||
| <item>Whiteboard</item> | |||
| <item>Field</item> | |||
| <item>Ragdoll</item> | |||
| <item>Construction</item> | |||
| <item>Lampshade</item> | |||
| <item>Palace</item> | |||
| <item>Meal</item> | |||
| <item>Factory</item> | |||
| <item>Cage</item> | |||
| <item>Clipper (Boat)</item> | |||
| <item>Gymnastics</item> | |||
| <item>Turtle</item> | |||
| <item>Human foot</item> | |||
| <item>Marriage</item> | |||
| <item>Web page</item> | |||
| <item>Human beard</item> | |||
| <item>Fog</item> | |||
| <item>Wool</item> | |||
| <item>Cappuccino</item> | |||
| <item>Lighthouse</item> | |||
| <item>Lego</item> | |||
| <item>Sparkler</item> | |||
| <item>Sari</item> | |||
| <item>Model</item> | |||
| <item>Temple</item> | |||
| <item>Beanie</item> | |||
| <item>Building</item> | |||
| <item>Waterfall</item> | |||
| <item>Penguin</item> | |||
| <item>Cave</item> | |||
| <item>Stadium</item> | |||
| <item>Smile</item> | |||
| <item>Human hand</item> | |||
| <item>Park</item> | |||
| <item>Desk</item> | |||
| <item>Shetland sheepdog</item> | |||
| <item>Bar</item> | |||
| <item>Eating</item> | |||
| <item>Neon</item> | |||
| <item>Dalmatian</item> | |||
| <item>Crocodile</item> | |||
| <item>Wakeboarding</item> | |||
| <item>Longboard</item> | |||
| <item>Road</item> | |||
| <item>Race</item> | |||
| <item>Kitchen</item> | |||
| <item>Odometer</item> | |||
| <item>Cliff</item> | |||
| <item>Fiction</item> | |||
| <item>School</item> | |||
| <item>Interaction</item> | |||
| <item>Bullfighting</item> | |||
| <item>Boxer</item> | |||
| <item>Gown</item> | |||
| <item>Aquarium</item> | |||
| <item>Superhero</item> | |||
| <item>Pie</item> | |||
| <item>Asphalt</item> | |||
| <item>Surfboard</item> | |||
| <item>Cheeseburger</item> | |||
| <item>Screenshot</item> | |||
| <item>Supper</item> | |||
| <item>Laugh</item> | |||
| <item>Lunch</item> | |||
| <item>Party </item> | |||
| <item>Glacier</item> | |||
| <item>Bench</item> | |||
| <item>Grandparent</item> | |||
| <item>Sink</item> | |||
| <item>Pomacentridae</item> | |||
| <item>Blazer</item> | |||
| <item>Brick</item> | |||
| <item>Space</item> | |||
| <item>Backpacking</item> | |||
| <item>Stuffed toy</item> | |||
| <item>Sushi</item> | |||
| <item>Glitter</item> | |||
| <item>Bonfire</item> | |||
| <item>Castle</item> | |||
| <item>Marathon</item> | |||
| <item>Pizza</item> | |||
| <item>Beach</item> | |||
| <item>Human ear</item> | |||
| <item>Racing</item> | |||
| <item>Sitting</item> | |||
| <item>Iceberg</item> | |||
| <item>Shelf</item> | |||
| <item>Vehicle</item> | |||
| <item>Pop music</item> | |||
| <item>Playground</item> | |||
| <item>Clown</item> | |||
| <item>Car</item> | |||
| <item>Rein</item> | |||
| <item>Fur</item> | |||
| <item>Musician</item> | |||
| <item>Casino</item> | |||
| <item>Baby</item> | |||
| <item>Alcohol</item> | |||
| <item>Strap</item> | |||
| <item>Reef</item> | |||
| <item>Balloon</item> | |||
| <item>Outerwear</item> | |||
| <item>Cathedral</item> | |||
| <item>Competition</item> | |||
| <item>Joker</item> | |||
| <item>Blackboard</item> | |||
| <item>Bunk bed</item> | |||
| <item>Bear</item> | |||
| <item>Moon</item> | |||
| <item>Archery</item> | |||
| <item>Polo</item> | |||
| <item>River</item> | |||
| <item>Fishing</item> | |||
| <item>Ferris wheel</item> | |||
| <item>Mortarboard</item> | |||
| <item>Bracelet</item> | |||
| <item>Flesh</item> | |||
| <item>Statue</item> | |||
| <item>Farm</item> | |||
| <item>Desert</item> | |||
| <item>Chain</item> | |||
| <item>Aircraft</item> | |||
| <item>Textile</item> | |||
| <item>Hot dog</item> | |||
| <item>Knitting</item> | |||
| <item>Singer</item> | |||
| <item>Juice</item> | |||
| <item>Circus</item> | |||
| <item>Chair</item> | |||
| <item>Musical instrument</item> | |||
| <item>Room</item> | |||
| <item>Crochet</item> | |||
| <item>Sailboat</item> | |||
| <item>Newspaper</item> | |||
| <item>Santa claus</item> | |||
| <item>Swamp</item> | |||
| <item>Skyscraper</item> | |||
| <item>Skin</item> | |||
| <item>Rocket</item> | |||
| <item>Aviation</item> | |||
| <item>Airliner</item> | |||
| <item>Garden</item> | |||
| <item>Ruins</item> | |||
| <item>Storm</item> | |||
| <item>Glasses</item> | |||
| <item>Balance</item> | |||
| <item>Nail (Body part)</item> | |||
| <item>Rainbow</item> | |||
| <item>Soil </item> | |||
| <item>Vacation </item> | |||
| <item>Moustache</item> | |||
| <item>Doily</item> | |||
| <item>Food</item> | |||
| <item>Bride </item> | |||
| <item>Cattle</item> | |||
| <item>Pocket</item> | |||
| <item>Infrastructure</item> | |||
| <item>Train</item> | |||
| <item>Gerbil</item> | |||
| <item>Fireworks</item> | |||
| <item>Pet</item> | |||
| <item>Dam</item> | |||
| <item>Crew</item> | |||
| <item>Couch</item> | |||
| <item>Bathing</item> | |||
| <item>Quilting</item> | |||
| <item>Motorcycle</item> | |||
| <item>Butterfly</item> | |||
| <item>Sled</item> | |||
| <item>Watercolor paint</item> | |||
| <item>Rafting</item> | |||
| <item>Monument</item> | |||
| <item>Lightning</item> | |||
| <item>Sunset</item> | |||
| <item>Bumper</item> | |||
| <item>Shoe</item> | |||
| <item>Waterskiing</item> | |||
| <item>Sneakers</item> | |||
| <item>Tower</item> | |||
| <item>Insect</item> | |||
| <item>Pool</item> | |||
| <item>Placemat</item> | |||
| <item>Airplane</item> | |||
| <item>Plant</item> | |||
| <item>Jungle</item> | |||
| <item>Armrest</item> | |||
| <item>Duck</item> | |||
| <item>Dress</item> | |||
| <item>Tableware</item> | |||
| <item>Petal</item> | |||
| <item>Bus</item> | |||
| <item>Hanukkah</item> | |||
| <item>Forest</item> | |||
| <item>Hat</item> | |||
| <item>Barn</item> | |||
| <item>Tubing</item> | |||
| <item>Snorkeling</item> | |||
| <item>Cool</item> | |||
| <item>Cookware and bakeware</item> | |||
| <item>Cycling</item> | |||
| <item>Swing (Seat)</item> | |||
| <item>Muscle</item> | |||
| <item>Cat</item> | |||
| <item>Skateboard</item> | |||
| <item>Star</item> | |||
| <item>Toe</item> | |||
| <item>Junk</item> | |||
| <item>Bicycle</item> | |||
| <item>Bedroom</item> | |||
| <item>Person</item> | |||
| <item>Sand</item> | |||
| <item>Canyon</item> | |||
| <item>Tie</item> | |||
| <item>Twig</item> | |||
| <item>Sphynx</item> | |||
| <item>Supervillain</item> | |||
| <item>Nightclub</item> | |||
| <item>Ranch</item> | |||
| <item>Pattern</item> | |||
| <item>Shorts</item> | |||
| <item>Himalayan</item> | |||
| <item>Wall</item> | |||
| <item>Leggings</item> | |||
| <item>Windsurfing</item> | |||
| <item>Deejay</item> | |||
| <item>Dance</item> | |||
| <item>Van</item> | |||
| <item>Bento</item> | |||
| <item>Sleep</item> | |||
| <item>Wine</item> | |||
| <item>Picnic</item> | |||
| <item>Leisure</item> | |||
| <item>Dune</item> | |||
| <item>Crowd</item> | |||
| <item>Kayak</item> | |||
| <item>Ballroom</item> | |||
| <item>Selfie</item> | |||
| <item>Graduation</item> | |||
| <item>Frigate</item> | |||
| <item>Mountain</item> | |||
| <item>Dude</item> | |||
| <item>Windshield</item> | |||
| <item>Skiff</item> | |||
| <item>Class</item> | |||
| <item>Scarf</item> | |||
| <item>Bull</item> | |||
| <item>Soccer</item> | |||
| <item>Bag</item> | |||
| <item>Basset hound</item> | |||
| <item>Tractor</item> | |||
| <item>Swimming</item> | |||
| <item>Running</item> | |||
| <item>Track</item> | |||
| <item>Helicopter</item> | |||
| <item>Pitch</item> | |||
| <item>Clock</item> | |||
| <item>Song</item> | |||
| <item>Jersey</item> | |||
| <item>Stairs</item> | |||
| <item>Flap</item> | |||
| <item>Jewellery</item> | |||
| <item>Bridge</item> | |||
| <item>Cuisine</item> | |||
| <item>Bread</item> | |||
| <item>Caving</item> | |||
| <item>Shell</item> | |||
| <item>Wreath</item> | |||
| <item>Roof</item> | |||
| <item>Cookie</item> | |||
| <item>Canoe</item> | |||
| </string-array> | |||
| <string name="title_demo">Demo</string> | |||
| <string name="title_custom">Custom</string> | |||
| <string name="title_time">Inference Time</string> | |||
| <string-array name="scene_category"> | |||
| <item>airfield</item> | |||
| <item>airplane_cabin</item> | |||
| <item>airport_terminal</item> | |||
| <item>alcove</item> | |||
| <item>alley</item> | |||
| <item>amphitheater</item> | |||
| <item>amusement_arcade</item> | |||
| <item>amusement_park</item> | |||
| <item>apartment_building/outdoor</item> | |||
| <item>aquarium</item> | |||
| <item>aqueduct</item> | |||
| <item>arcade</item> | |||
| <item>arch</item> | |||
| <item>archaelogical_excavation</item> | |||
| <item>archive</item> | |||
| <item>arena/hockey</item> | |||
| <item>arena/performance</item> | |||
| <item>arena/rodeo</item> | |||
| <item>army_base</item> | |||
| <item>art_gallery</item> | |||
| <item>art_school</item> | |||
| <item>art_studio</item> | |||
| <item>artists_loft</item> | |||
| <item>assembly_line</item> | |||
| <item>athletic_field/outdoor</item> | |||
| <item>atrium/public</item> | |||
| <item>attic</item> | |||
| <item>auditorium</item> | |||
| <item>auto_factory</item> | |||
| <item>auto_showroom</item> | |||
| <item>badlands</item> | |||
| <item>bakery/shop</item> | |||
| <item>balcony/exterior</item> | |||
| <item>balcony/interior</item> | |||
| <item>ball_pit</item> | |||
| <item>ballroom</item> | |||
| <item>bamboo_forest</item> | |||
| <item>bank_vault</item> | |||
| <item>banquet_hall</item> | |||
| <item>bar</item> | |||
| <item>barn</item> | |||
| <item>barndoor</item> | |||
| <item>baseball_field</item> | |||
| <item>basement</item> | |||
| <item>basketball_court/indoor</item> | |||
| <item>bathroom</item> | |||
| <item>bazaar/indoor</item> | |||
| <item>bazaar/outdoor</item> | |||
| <item>beach</item> | |||
| <item>beach_house</item> | |||
| <item>beauty_salon</item> | |||
| <item>bedchamber</item> | |||
| <item>bedroom</item> | |||
| <item>beer_garden</item> | |||
| <item>beer_hall</item> | |||
| <item>berth</item> | |||
| <item>biology_laboratory</item> | |||
| <item>boardwalk</item> | |||
| <item>boat_deck</item> | |||
| <item>boathouse</item> | |||
| <item>bookstore</item> | |||
| <item>booth/indoor</item> | |||
| <item>botanical_garden</item> | |||
| <item>bow_window/indoor</item> | |||
| <item>bowling_alley</item> | |||
| <item>boxing_ring</item> | |||
| <item>bridge</item> | |||
| <item>building_facade</item> | |||
| <item>bullring</item> | |||
| <item>burial_chamber</item> | |||
| <item>bus_interior</item> | |||
| <item>bus_station/indoor</item> | |||
| <item>butchers_shop</item> | |||
| <item>butte</item> | |||
| <item>cabin/outdoor</item> | |||
| <item>cafeteria</item> | |||
| <item>campsite</item> | |||
| <item>campus</item> | |||
| <item>canal/natural</item> | |||
| <item>canal/urban</item> | |||
| <item>candy_store</item> | |||
| <item>canyon</item> | |||
| <item>car_interior</item> | |||
| <item>carrousel</item> | |||
| <item>castle</item> | |||
| <item>catacomb</item> | |||
| <item>cemetery</item> | |||
| <item>chalet</item> | |||
| <item>chemistry_lab</item> | |||
| <item>childs_room</item> | |||
| <item>church/indoor</item> | |||
| <item>church/outdoor</item> | |||
| <item>classroom</item> | |||
| <item>clean_room</item> | |||
| <item>cliff</item> | |||
| <item>closet</item> | |||
| <item>clothing_store</item> | |||
| <item>coast</item> | |||
| <item>cockpit</item> | |||
| <item>coffee_shop</item> | |||
| <item>computer_room</item> | |||
| <item>conference_center</item> | |||
| <item>conference_room</item> | |||
| <item>construction_site</item> | |||
| <item>corn_field</item> | |||
| <item>corral</item> | |||
| <item>corridor</item> | |||
| <item>cottage</item> | |||
| <item>courthouse</item> | |||
| <item>courtyard</item> | |||
| <item>creek</item> | |||
| <item>crevasse</item> | |||
| <item>crosswalk</item> | |||
| <item>dam</item> | |||
| <item>delicatessen</item> | |||
| <item>department_store</item> | |||
| <item>desert/sand</item> | |||
| <item>desert/vegetation</item> | |||
| <item>desert_road</item> | |||
| <item>diner/outdoor</item> | |||
| <item>dining_hall</item> | |||
| <item>dining_room</item> | |||
| <item>discotheque</item> | |||
| <item>doorway/outdoor</item> | |||
| <item>dorm_room</item> | |||
| <item>downtown</item> | |||
| <item>dressing_room</item> | |||
| <item>driveway</item> | |||
| <item>drugstore</item> | |||
| <item>elevator/door</item> | |||
| <item>elevator_lobby</item> | |||
| <item>elevator_shaft</item> | |||
| <item>embassy</item> | |||
| <item>engine_room</item> | |||
| <item>entrance_hall</item> | |||
| <item>escalator/indoor</item> | |||
| <item>excavation</item> | |||
| <item>fabric_store</item> | |||
| <item>farm</item> | |||
| <item>fastfood_restaurant</item> | |||
| <item>field/cultivated</item> | |||
| <item>field/wild</item> | |||
| <item>field_road</item> | |||
| <item>fire_escape</item> | |||
| <item>fire_station</item> | |||
| <item>fishpond</item> | |||
| <item>flea_market/indoor</item> | |||
| <item>florist_shop/indoor</item> | |||
| <item>food_court</item> | |||
| <item>football_field</item> | |||
| <item>forest/broadleaf</item> | |||
| <item>forest_path</item> | |||
| <item>forest_road</item> | |||
| <item>formal_garden</item> | |||
| <item>fountain</item> | |||
| <item>galley</item> | |||
| <item>garage/indoor</item> | |||
| <item>garage/outdoor</item> | |||
| <item>gas_station</item> | |||
| <item>gazebo/exterior</item> | |||
| <item>general_store/indoor</item> | |||
| <item>general_store/outdoor</item> | |||
| <item>gift_shop</item> | |||
| <item>glacier</item> | |||
| <item>golf_course</item> | |||
| <item>greenhouse/indoor</item> | |||
| <item>greenhouse/outdoor</item> | |||
| <item>grotto</item> | |||
| <item>gymnasium/indoor</item> | |||
| <item>hangar/indoor</item> | |||
| <item>hangar/outdoor</item> | |||
| <item>harbor</item> | |||
| <item>hardware_store</item> | |||
| <item>hayfield</item> | |||
| <item>heliport</item> | |||
| <item>highway</item> | |||
| <item>home_office</item> | |||
| <item>home_theater</item> | |||
| <item>hospital</item> | |||
| <item>hospital_room</item> | |||
| <item>hot_spring</item> | |||
| <item>hotel/outdoor</item> | |||
| <item>hotel_room</item> | |||
| <item>house</item> | |||
| <item>hunting_lodge/outdoor</item> | |||
| <item>ice_cream_parlor</item> | |||
| <item>ice_floe</item> | |||
| <item>ice_shelf</item> | |||
| <item>ice_skating_rink/indoor</item> | |||
| <item>ice_skating_rink/outdoor</item> | |||
| <item>iceberg</item> | |||
| <item>igloo</item> | |||
| <item>industrial_area</item> | |||
| <item>inn/outdoor</item> | |||
| <item>islet</item> | |||
| <item>jacuzzi/indoor</item> | |||
| <item>jail_cell</item> | |||
| <item>japanese_garden</item> | |||
| <item>jewelry_shop</item> | |||
| <item>junkyard</item> | |||
| <item>kasbah</item> | |||
| <item>kennel/outdoor</item> | |||
| <item>kindergarden_classroom</item> | |||
| <item>kitchen</item> | |||
| <item>lagoon</item> | |||
| <item>lake/natural</item> | |||
| <item>landfill</item> | |||
| <item>landing_deck</item> | |||
| <item>laundromat</item> | |||
| <item>lawn</item> | |||
| <item>lecture_room</item> | |||
| <item>legislative_chamber</item> | |||
| <item>library/indoor</item> | |||
| <item>library/outdoor</item> | |||
| <item>lighthouse</item> | |||
| <item>living_room</item> | |||
| <item>loading_dock</item> | |||
| <item>lobby</item> | |||
| <item>lock_chamber</item> | |||
| <item>locker_room</item> | |||
| <item>mansion</item> | |||
| <item>manufactured_home</item> | |||
| <item>market/indoor</item> | |||
| <item>market/outdoor</item> | |||
| <item>marsh</item> | |||
| <item>martial_arts_gym</item> | |||
| <item>mausoleum</item> | |||
| <item>medina</item> | |||
| <item>mezzanine</item> | |||
| <item>moat/water</item> | |||
| <item>mosque/outdoor</item> | |||
| <item>motel</item> | |||
| <item>mountain</item> | |||
| <item>mountain_path</item> | |||
| <item>mountain_snowy</item> | |||
| <item>movie_theater/indoor</item> | |||
| <item>museum/indoor</item> | |||
| <item>museum/outdoor</item> | |||
| <item>music_studio</item> | |||
| <item>natural_history_museum</item> | |||
| <item>nursery</item> | |||
| <item>nursing_home</item> | |||
| <item>oast_house</item> | |||
| <item>ocean</item> | |||
| <item>office</item> | |||
| <item>office_building</item> | |||
| <item>office_cubicles</item> | |||
| <item>oilrig</item> | |||
| <item>operating_room</item> | |||
| <item>orchard</item> | |||
| <item>orchestra_pit</item> | |||
| <item>pagoda</item> | |||
| <item>palace</item> | |||
| <item>pantry</item> | |||
| <item>park</item> | |||
| <item>parking_garage/indoor</item> | |||
| <item>parking_garage/outdoor</item> | |||
| <item>parking_lot</item> | |||
| <item>pasture</item> | |||
| <item>patio</item> | |||
| <item>pavilion</item> | |||
| <item>pet_shop</item> | |||
| <item>pharmacy</item> | |||
| <item>phone_booth</item> | |||
| <item>physics_laboratory</item> | |||
| <item>picnic_area</item> | |||
| <item>pier</item> | |||
| <item>pizzeria</item> | |||
| <item>playground</item> | |||
| <item>playroom</item> | |||
| <item>plaza</item> | |||
| <item>pond</item> | |||
| <item>porch</item> | |||
| <item>promenade</item> | |||
| <item>pub/indoor</item> | |||
| <item>racecourse</item> | |||
| <item>raceway</item> | |||
| <item>raft</item> | |||
| <item>railroad_track</item> | |||
| <item>rainforest</item> | |||
| <item>reception</item> | |||
| <item>recreation_room</item> | |||
| <item>repair_shop</item> | |||
| <item>residential_neighborhood</item> | |||
| <item>restaurant</item> | |||
| <item>restaurant_kitchen</item> | |||
| <item>restaurant_patio</item> | |||
| <item>rice_paddy</item> | |||
| <item>river</item> | |||
| <item>rock_arch</item> | |||
| <item>roof_garden</item> | |||
| <item>rope_bridge</item> | |||
| <item>ruin</item> | |||
| <item>runway</item> | |||
| <item>sandbox</item> | |||
| <item>sauna</item> | |||
| <item>schoolhouse</item> | |||
| <item>science_museum</item> | |||
| <item>server_room</item> | |||
| <item>shed</item> | |||
| <item>shoe_shop</item> | |||
| <item>shopfront</item> | |||
| <item>shopping_mall/indoor</item> | |||
| <item>shower</item> | |||
| <item>ski_resort</item> | |||
| <item>ski_slope</item> | |||
| <item>sky</item> | |||
| <item>skyscraper</item> | |||
| <item>slum</item> | |||
| <item>snowfield</item> | |||
| <item>soccer_field</item> | |||
| <item>stable</item> | |||
| <item>stadium/baseball</item> | |||
| <item>stadium/football</item> | |||
| <item>stadium/soccer</item> | |||
| <item>stage/indoor</item> | |||
| <item>stage/outdoor</item> | |||
| <item>staircase</item> | |||
| <item>storage_room</item> | |||
| <item>street</item> | |||
| <item>subway_station/platform</item> | |||
| <item>supermarket</item> | |||
| <item>sushi_bar</item> | |||
| <item>swamp</item> | |||
| <item>swimming_hole</item> | |||
| <item>swimming_pool/indoor</item> | |||
| <item>swimming_pool/outdoor</item> | |||
| <item>synagogue/outdoor</item> | |||
| <item>television_room</item> | |||
| <item>television_studio</item> | |||
| <item>temple/asia</item> | |||
| <item>throne_room</item> | |||
| <item>ticket_booth</item> | |||
| <item>topiary_garden</item> | |||
| <item>tower</item> | |||
| <item>toyshop</item> | |||
| <item>train_interior</item> | |||
| <item>train_station/platform</item> | |||
| <item>tree_farm</item> | |||
| <item>tree_house</item> | |||
| <item>trench</item> | |||
| <item>tundra</item> | |||
| <item>underwater/ocean_deep</item> | |||
| <item>utility_room</item> | |||
| <item>valley</item> | |||
| <item>vegetable_garden</item> | |||
| <item>veterinarians_office</item> | |||
| <item>viaduct</item> | |||
| <item>village</item> | |||
| <item>vineyard</item> | |||
| <item>volcano</item> | |||
| <item>volleyball_court/outdoor</item> | |||
| <item>waiting_room</item> | |||
| <item>water_park</item> | |||
| <item>water_tower</item> | |||
| <item>waterfall</item> | |||
| <item>watering_hole</item> | |||
| <item>wave</item> | |||
| <item>wet_bar</item> | |||
| <item>wheat_field</item> | |||
| <item>wind_farm</item> | |||
| <item>windmill</item> | |||
| <item>yard</item> | |||
| <item>youth_hostel</item> | |||
| <item>zen_garden</item> | |||
| </string-array> | |||
| <string-array name="grbage_sort_map"> | |||
| <item>Recyclables</item> | |||
| <item>Dry garbage</item> | |||
| <item>Hazardous garbage</item> | |||
| <item>Wet garbage</item> | |||
| </string-array> | |||
| <string-array name="grbage_sort_detailed_map"> | |||
| <item>Plastic bottle</item> | |||
| <item>Hat</item> | |||
| <item>Newspaper</item> | |||
| <item>Can</item> | |||
| <item>Glasswork</item> | |||
| <item>Glass Bottle</item> | |||
| <item>Cardboard</item> | |||
| <item>Basketball</item> | |||
| <item>Paper</item> | |||
| <item>Metalwork</item> | |||
| <item>Disposable chopsticks</item> | |||
| <item>Lighter</item> | |||
| <item>Broom</item> | |||
| <item>Old Mirror</item> | |||
| <item>Toothbrush</item> | |||
| <item>Dirty clothes</item> | |||
| <item>Shell</item> | |||
| <item>Ceramic Bowl</item> | |||
| <item>Paint Bucket</item> | |||
| <item>Battery</item> | |||
| <item>Fluorescent Light</item> | |||
| <item>Pill Capsule</item> | |||
| <item>Orange Peel</item> | |||
| <item>Leaf</item> | |||
| <item>Eggshell</item> | |||
| <item>Banana peel</item> | |||
| </string-array> | |||
| <string name="image_invalid">The image path you selected is not valid. Please choose again</string> | |||
| <string name="train_invalid">Sorry, there is no object identified in this picture. Try another picture</string> | |||
| </resources> | |||
| @@ -1,2 +1,2 @@ | |||
| configurations.maybeCreate("default") | |||
| artifacts.add("default", file('mindspore-lite-1.0.1.aar')) | |||
| artifacts.add("default", file('mindspore/mindspore-lite/1.1.0/mindspore-lite-1.1.0.aar')) | |||
| @@ -60,7 +60,7 @@ apply from: 'download.gradle' | |||
| dependencies { | |||
| implementation project(':mindsporelibrary') | |||
| implementation 'androidx.appcompat:appcompat:1.2.0' | |||
| implementation 'androidx.appcompat:appcompat:1.3.0-alpha02' | |||
| implementation 'com.google.android.material:material:1.2.1' | |||
| implementation 'androidx.constraintlayout:constraintlayout:2.0.4' | |||
| androidTestImplementation 'androidx.test.ext:junit:1.1.2' | |||
| @@ -115,14 +115,14 @@ public class Posenet { | |||
| } | |||
| msConfig.free(); | |||
| // Complile graph. | |||
| // Compile graph. | |||
| if (!session.compileGraph(model)) { | |||
| Log.e("MS_LITE", "Compile graph failed"); | |||
| model.freeBuffer(); | |||
| return false; | |||
| } | |||
| // Note: when use model.freeBuffer(), the model can not be complile graph again. | |||
| // Note: when use model.freeBuffer(), the model can not be compile graph again. | |||
| model.freeBuffer(); | |||
| return true; | |||
| @@ -171,7 +171,7 @@ public class Posenet { | |||
| * returns: | |||
| * person: a Person object containing data about keypoint locations and confidence scores | |||
| */ | |||
| Person estimateSinglePose(Bitmap bitmap) { | |||
| public Person estimateSinglePose(Bitmap bitmap) { | |||
| long estimationStartTimeNanos = SystemClock.elapsedRealtimeNanos(); | |||
| ByteBuffer inputArray = this.initInputArray(bitmap); | |||
| List<MSTensor> inputs = session.getInputs(); | |||
| @@ -198,60 +198,8 @@ public class Posenet { | |||
| String.format("Interpreter took %.2f ms", 1.0f * lastInferenceTimeNanos / 1_000_000) | |||
| ); | |||
| // Get output tensor values. | |||
| List<MSTensor> heatmaps_list = session.getOutputsByNodeName("Conv2D-27"); | |||
| if (heatmaps_list == null) { | |||
| return null; | |||
| } | |||
| MSTensor heatmaps_tensors = heatmaps_list.get(0); | |||
| float[] heatmaps_results = heatmaps_tensors.getFloatData(); | |||
| int[] heatmapsShape = heatmaps_tensors.getShape(); //1, 9, 9 ,17 | |||
| float[][][][] heatmaps = new float[heatmapsShape[0]][][][]; | |||
| for (int x = 0; x < heatmapsShape[0]; x++) { // heatmapsShape[0] =1 | |||
| float[][][] arrayThree = new float[heatmapsShape[1]][][]; | |||
| for (int y = 0; y < heatmapsShape[1]; y++) { // heatmapsShape[1] = 9 | |||
| float[][] arrayTwo = new float[heatmapsShape[2]][]; | |||
| for (int z = 0; z < heatmapsShape[2]; z++) { //heatmapsShape[2] = 9 | |||
| float[] arrayOne = new float[heatmapsShape[3]]; //heatmapsShape[3] = 17 | |||
| for (int i = 0; i < heatmapsShape[3]; i++) { | |||
| int n = i + z * heatmapsShape[3] + y * heatmapsShape[2] * heatmapsShape[3] + x * heatmapsShape[1] * heatmapsShape[2] * heatmapsShape[3]; | |||
| arrayOne[i] = heatmaps_results[n]; //1*9*9*17 ?? | |||
| } | |||
| arrayTwo[z] = arrayOne; | |||
| } | |||
| arrayThree[y] = arrayTwo; | |||
| } | |||
| heatmaps[x] = arrayThree; | |||
| } | |||
| List<MSTensor> offsets_list = session.getOutputsByNodeName("Conv2D-28"); | |||
| if (offsets_list == null) { | |||
| return null; | |||
| } | |||
| MSTensor offsets_tensors = offsets_list.get(0); | |||
| float[] offsets_results = offsets_tensors.getFloatData(); | |||
| int[] offsetsShapes = offsets_tensors.getShape(); | |||
| float[][][][] offsets = new float[offsetsShapes[0]][][][]; | |||
| for (int x = 0; x < offsetsShapes[0]; x++) { | |||
| float[][][] offsets_arrayThree = new float[offsetsShapes[1]][][]; | |||
| for (int y = 0; y < offsetsShapes[1]; y++) { | |||
| float[][] offsets_arrayTwo = new float[offsetsShapes[2]][]; | |||
| for (int z = 0; z < offsetsShapes[2]; z++) { | |||
| float[] offsets_arrayOne = new float[offsetsShapes[3]]; | |||
| for (int i = 0; i < offsetsShapes[3]; i++) { | |||
| int n = i + z * offsetsShapes[3] + y * offsetsShapes[2] * offsetsShapes[3] + x * offsetsShapes[1] * offsetsShapes[2] * offsetsShapes[3]; | |||
| offsets_arrayOne[i] = offsets_results[n]; | |||
| } | |||
| offsets_arrayTwo[z] = offsets_arrayOne; | |||
| } | |||
| offsets_arrayThree[y] = offsets_arrayTwo; | |||
| } | |||
| offsets[x] = offsets_arrayThree; | |||
| } | |||
| float[][][][] heatmaps = runConv2Dfor27(); | |||
| float[][][][] offsets = runConv2Dfor28(); | |||
| int height = ((Object[]) heatmaps[0]).length; //9 | |||
| int width = ((Object[]) heatmaps[0][0]).length; //9 | |||
| @@ -288,8 +236,8 @@ public class Posenet { | |||
| int positionY = (int) position.first; | |||
| int positionX = (int) position.second; | |||
| yCoords[i] = ((float) positionY / (float) (height - 1) * bitmap.getHeight() + offsets[0][positionY][positionX][i]); | |||
| xCoords[i] = ((float) positionX / (float) (width - 1) * bitmap.getWidth() + offsets[0][positionY][positionX][i + numKeypoints]); | |||
| yCoords[i] = ((float) positionY / (float) (height - 1) * bitmap.getHeight() + offsets[0][positionY][positionX][i]); | |||
| xCoords[i] = ((float) positionX / (float) (width - 1) * bitmap.getWidth() + offsets[0][positionY][positionX][i + numKeypoints]); | |||
| confidenceScores[i] = sigmoid(heatmaps[0][positionY][positionX][i]); | |||
| } | |||
| @@ -311,4 +259,65 @@ public class Posenet { | |||
| return person; | |||
| } | |||
| private float[][][][] runConv2Dfor27() { | |||
| // Get output tensor values. | |||
| List<MSTensor> heatmaps_list = session.getOutputsByNodeName("Conv2D-27"); | |||
| if (heatmaps_list == null) { | |||
| return null; | |||
| } | |||
| MSTensor heatmaps_tensors = heatmaps_list.get(0); | |||
| float[] heatmaps_results = heatmaps_tensors.getFloatData(); | |||
| int[] heatmapsShape = heatmaps_tensors.getShape(); //1, 9, 9 ,17 | |||
| float[][][][] heatmaps = new float[heatmapsShape[0]][][][]; | |||
| for (int x = 0; x < heatmapsShape[0]; x++) { // heatmapsShape[0] =1 | |||
| float[][][] arrayThree = new float[heatmapsShape[1]][][]; | |||
| for (int y = 0; y < heatmapsShape[1]; y++) { // heatmapsShape[1] = 9 | |||
| float[][] arrayTwo = new float[heatmapsShape[2]][]; | |||
| for (int z = 0; z < heatmapsShape[2]; z++) { //heatmapsShape[2] = 9 | |||
| float[] arrayOne = new float[heatmapsShape[3]]; //heatmapsShape[3] = 17 | |||
| for (int i = 0; i < heatmapsShape[3]; i++) { | |||
| int n = i + z * heatmapsShape[3] + y * heatmapsShape[2] * heatmapsShape[3] + x * heatmapsShape[1] * heatmapsShape[2] * heatmapsShape[3]; | |||
| arrayOne[i] = heatmaps_results[n]; //1*9*9*17 ?? | |||
| } | |||
| arrayTwo[z] = arrayOne; | |||
| } | |||
| arrayThree[y] = arrayTwo; | |||
| } | |||
| heatmaps[x] = arrayThree; | |||
| } | |||
| return heatmaps; | |||
| } | |||
| private float[][][][] runConv2Dfor28() { | |||
| List<MSTensor> offsets_list = session.getOutputsByNodeName("Conv2D-28"); | |||
| if (offsets_list == null) { | |||
| return null; | |||
| } | |||
| MSTensor offsets_tensors = offsets_list.get(0); | |||
| float[] offsets_results = offsets_tensors.getFloatData(); | |||
| int[] offsetsShapes = offsets_tensors.getShape(); | |||
| float[][][][] offsets = new float[offsetsShapes[0]][][][]; | |||
| for (int x = 0; x < offsetsShapes[0]; x++) { | |||
| float[][][] offsets_arrayThree = new float[offsetsShapes[1]][][]; | |||
| for (int y = 0; y < offsetsShapes[1]; y++) { | |||
| float[][] offsets_arrayTwo = new float[offsetsShapes[2]][]; | |||
| for (int z = 0; z < offsetsShapes[2]; z++) { | |||
| float[] offsets_arrayOne = new float[offsetsShapes[3]]; | |||
| for (int i = 0; i < offsetsShapes[3]; i++) { | |||
| int n = i + z * offsetsShapes[3] + y * offsetsShapes[2] * offsetsShapes[3] + x * offsetsShapes[1] * offsetsShapes[2] * offsetsShapes[3]; | |||
| offsets_arrayOne[i] = offsets_results[n]; | |||
| } | |||
| offsets_arrayTwo[z] = offsets_arrayOne; | |||
| } | |||
| offsets_arrayThree[y] = offsets_arrayTwo; | |||
| } | |||
| offsets[x] = offsets_arrayThree; | |||
| } | |||
| return offsets; | |||
| } | |||
| } | |||
| @@ -77,87 +77,7 @@ public class PosenetMainActivity extends AppCompatActivity { | |||
| protected void onCreate(Bundle savedInstanceState) { | |||
| super.onCreate(savedInstanceState); | |||
| setContentView(R.layout.posenet_activity_main); | |||
| requestPermissions(); | |||
| } | |||
| private void requestPermissions() { | |||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | |||
| isAllGranted = checkPermissionAllGranted(PERMISSIONS); | |||
| if (!isAllGranted) { | |||
| ActivityCompat.requestPermissions(this, PERMISSIONS, REQUEST_PERMISSION); | |||
| } else { | |||
| addCameraFragment(); | |||
| } | |||
| } else { | |||
| isAllGranted = true; | |||
| addCameraFragment(); | |||
| } | |||
| } | |||
| private boolean checkPermissionAllGranted(String[] permissions) { | |||
| for (String permission : permissions) { | |||
| if (ContextCompat.checkSelfPermission(this, permission) != PackageManager.PERMISSION_GRANTED) { | |||
| return false; | |||
| } | |||
| } | |||
| return true; | |||
| } | |||
| /** | |||
| * Authority application result callback | |||
| */ | |||
| @Override | |||
| public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | |||
| if (REQUEST_PERMISSION == requestCode) { | |||
| isAllGranted = true; | |||
| for (int grant : grantResults) { | |||
| if (grant != PackageManager.PERMISSION_GRANTED) { | |||
| isAllGranted = false; | |||
| break; | |||
| } | |||
| } | |||
| if (!isAllGranted) { | |||
| openAppDetails(); | |||
| } else { | |||
| addCameraFragment(); | |||
| } | |||
| } | |||
| } | |||
| private void openAppDetails() { | |||
| AlertDialog.Builder builder = new AlertDialog.Builder(this); | |||
| builder.setMessage("PoseNet 需要访问 “相机” 和 “外部存储器”,请到 “应用信息 -> 权限” 中授予!"); | |||
| 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); | |||
| startActivityForResult(intent, REQUEST_PERMISSION_AGAIN); | |||
| } | |||
| }); | |||
| builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { | |||
| @Override | |||
| public void onClick(DialogInterface dialog, int which) { | |||
| finish(); | |||
| } | |||
| }); | |||
| builder.show(); | |||
| } | |||
| @Override | |||
| protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | |||
| super.onActivityResult(requestCode, resultCode, data); | |||
| if (REQUEST_PERMISSION_AGAIN == requestCode) { | |||
| requestPermissions(); | |||
| } | |||
| addCameraFragment(); | |||
| } | |||
| private void addCameraFragment() { | |||
| @@ -172,5 +92,4 @@ public class PosenetMainActivity extends AppCompatActivity { | |||
| poseNetFragment.switchCamera(); | |||
| } | |||
| } | |||
| @@ -24,7 +24,7 @@ | |||
| android:drawableStart="@drawable/logo2" | |||
| android:drawablePadding="5dp" | |||
| android:gravity="center_vertical" | |||
| android:text="MindSpore PoseNet" | |||
| android:text="@string/posenet_app_name_title" | |||
| android:textColor="#ffffff" | |||
| android:textSize="20sp" /> | |||
| @@ -1,5 +1,4 @@ | |||
| <resources> | |||
| <string name="posenet_app_name">PoseNetDemo</string> | |||
| <!-- TODO: Remove or change this placeholder text --> | |||
| <string name="posenet_hello_blank_fragment">Hello blank fragment</string> | |||
| <string name="posenet_app_name_title">MS PoseNet</string> | |||
| </resources> | |||
| @@ -58,7 +58,7 @@ android { | |||
| apply from: 'download.gradle' | |||
| dependencies { | |||
| implementation 'androidx.appcompat:appcompat:1.2.0' | |||
| implementation 'androidx.appcompat:appcompat:1.3.0-alpha02' | |||
| implementation 'androidx.constraintlayout:constraintlayout:2.0.1' | |||
| implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0' | |||
| implementation 'com.google.android.material:material:1.2.1' | |||
| @@ -16,6 +16,7 @@ | |||
| package com.mindspore.imagesegmentation.help; | |||
| import android.app.Activity; | |||
| import android.content.ContentResolver; | |||
| import android.content.Context; | |||
| import android.content.Intent; | |||
| import android.database.Cursor; | |||
| @@ -31,6 +32,8 @@ import android.os.Environment; | |||
| import android.provider.MediaStore; | |||
| import android.util.Log; | |||
| import java.io.ByteArrayInputStream; | |||
| import java.io.ByteArrayOutputStream; | |||
| import java.io.File; | |||
| import java.io.FileNotFoundException; | |||
| import java.io.FileOutputStream; | |||
| @@ -51,154 +54,123 @@ public class BitmapUtils { | |||
| } | |||
| } | |||
| private static String getImagePath(Activity activity, Uri uri) { | |||
| String[] projection = {MediaStore.Images.Media.DATA}; | |||
| Cursor cursor = activity.managedQuery(uri, projection, null, null, null); | |||
| int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); | |||
| cursor.moveToFirst(); | |||
| return cursor.getString(columnIndex); | |||
| } | |||
| public static Bitmap loadFromPath(Activity activity, int id, int width, int height) { | |||
| BitmapFactory.Options options = new BitmapFactory.Options(); | |||
| options.inJustDecodeBounds = true; | |||
| InputStream is = activity.getResources().openRawResource(id); | |||
| int sampleSize = calculateInSampleSize(options, width, height); | |||
| options.inSampleSize = sampleSize; | |||
| options.inJustDecodeBounds = false; | |||
| return zoomImage(BitmapFactory.decodeStream(is), width, height); | |||
| } | |||
| public static Bitmap loadFromPath(Activity activity, Uri uri, int width, int height) { | |||
| BitmapFactory.Options options = new BitmapFactory.Options(); | |||
| options.inJustDecodeBounds = true; | |||
| public static Bitmap getBitmapFormUri(Activity ac, Uri uri) { | |||
| Bitmap bitmap = null; | |||
| try { | |||
| InputStream input = ac.getContentResolver().openInputStream(uri); | |||
| BitmapFactory.Options onlyBoundsOptions = new BitmapFactory.Options(); | |||
| onlyBoundsOptions.inJustDecodeBounds = true; | |||
| onlyBoundsOptions.inDither = true;//optional | |||
| onlyBoundsOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;//optional | |||
| BitmapFactory.decodeStream(input, null, onlyBoundsOptions); | |||
| input.close(); | |||
| int originalWidth = onlyBoundsOptions.outWidth; | |||
| int originalHeight = onlyBoundsOptions.outHeight; | |||
| if ((originalWidth == -1) || (originalHeight == -1)) | |||
| return null; | |||
| float hh = 800f; | |||
| float ww = 480f; | |||
| int be = 1; | |||
| if (originalWidth > originalHeight && originalWidth > ww) { | |||
| be = (int) (originalWidth / ww); | |||
| } else if (originalWidth < originalHeight && originalHeight > hh) { | |||
| be = (int) (originalHeight / hh); | |||
| } | |||
| if (be <= 0) { | |||
| be = 1; | |||
| } | |||
| BitmapFactory.Options bitmapOptions = new BitmapFactory.Options(); | |||
| bitmapOptions.inSampleSize = be; | |||
| bitmapOptions.inDither = true;//optional | |||
| bitmapOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;//optional | |||
| input = ac.getContentResolver().openInputStream(uri); | |||
| bitmap = BitmapFactory.decodeStream(input, null, bitmapOptions); | |||
| input.close(); | |||
| String path = getImagePath(activity, uri); | |||
| BitmapFactory.decodeFile(path, options); | |||
| int sampleSize = calculateInSampleSize(options, width, height); | |||
| options.inSampleSize = sampleSize; | |||
| options.inJustDecodeBounds = false; | |||
| Bitmap bitmap = zoomImage(BitmapFactory.decodeFile(path, options), width, height); | |||
| return rotateBitmap(bitmap, getRotationAngle(path)); | |||
| } catch (FileNotFoundException e) { | |||
| e.printStackTrace(); | |||
| } catch (IOException e) { | |||
| e.printStackTrace(); | |||
| } | |||
| return compressImage(bitmap); | |||
| } | |||
| private static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) { | |||
| final int width = options.outWidth; | |||
| final int height = options.outHeight; | |||
| int inSampleSize = 1; | |||
| if (height > reqHeight || width > reqWidth) { | |||
| // Calculate height and required height scale. | |||
| final int heightRatio = Math.round((float) height / (float) reqHeight); | |||
| // Calculate width and required width scale. | |||
| final int widthRatio = Math.round((float) width / (float) reqWidth); | |||
| // Take the larger of the values. | |||
| inSampleSize = heightRatio > widthRatio ? heightRatio : widthRatio; | |||
| public static Bitmap compressImage(Bitmap image) { | |||
| if (image != null) { | |||
| ByteArrayOutputStream baos = new ByteArrayOutputStream(); | |||
| image.compress(Bitmap.CompressFormat.JPEG, 100, baos); | |||
| int options = 100; | |||
| while (baos.toByteArray().length / 1024 > 100) { | |||
| baos.reset(); | |||
| image.compress(Bitmap.CompressFormat.JPEG, options, baos); | |||
| options -= 10; | |||
| } | |||
| ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray()); | |||
| Bitmap bitmap = BitmapFactory.decodeStream(isBm, null, null); | |||
| return bitmap; | |||
| }else { | |||
| return null; | |||
| } | |||
| return inSampleSize; | |||
| } | |||
| // Scale pictures to screen width. | |||
| private static Bitmap zoomImage(Bitmap imageBitmap, int targetWidth, int maxHeight) { | |||
| float scaleFactor = | |||
| Math.max( | |||
| (float) imageBitmap.getWidth() / (float) targetWidth, | |||
| (float) imageBitmap.getHeight() / (float) maxHeight); | |||
| Bitmap resizedBitmap = | |||
| Bitmap.createScaledBitmap( | |||
| imageBitmap, | |||
| (int) (imageBitmap.getWidth() / scaleFactor), | |||
| (int) (imageBitmap.getHeight() / scaleFactor), | |||
| true); | |||
| return resizedBitmap; | |||
| public static File getFileFromMediaUri(Context ac, Uri uri) { | |||
| if (uri.getScheme().toString().compareTo("content") == 0) { | |||
| ContentResolver cr = ac.getContentResolver(); | |||
| Cursor cursor = cr.query(uri, null, null, null, null); | |||
| if (cursor != null) { | |||
| cursor.moveToFirst(); | |||
| String filePath = cursor.getString(cursor.getColumnIndex("_data")); | |||
| cursor.close(); | |||
| if (filePath != null) { | |||
| return new File(filePath); | |||
| } | |||
| } | |||
| } else if (uri.getScheme().toString().compareTo("file") == 0) { | |||
| return new File(uri.toString().replace("file://", "")); | |||
| } | |||
| return null; | |||
| } | |||
| /** | |||
| * Get the rotation angle of the photo. | |||
| * | |||
| * @param path photo path. | |||
| * @return angle. | |||
| */ | |||
| public static int getRotationAngle(String path) { | |||
| int rotation = 0; | |||
| public static int getBitmapDegree(String path) { | |||
| int degree = 0; | |||
| try { | |||
| ExifInterface exifInterface = new ExifInterface(path); | |||
| int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); | |||
| int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, | |||
| ExifInterface.ORIENTATION_NORMAL); | |||
| switch (orientation) { | |||
| case ExifInterface.ORIENTATION_ROTATE_90: | |||
| rotation = 90; | |||
| degree = 90; | |||
| break; | |||
| case ExifInterface.ORIENTATION_ROTATE_180: | |||
| rotation = 180; | |||
| degree = 180; | |||
| break; | |||
| case ExifInterface.ORIENTATION_ROTATE_270: | |||
| rotation = 270; | |||
| break; | |||
| default: | |||
| degree = 270; | |||
| break; | |||
| } | |||
| } catch (IOException e) { | |||
| Log.e(TAG, "Failed to get rotation: " + e.getMessage()); | |||
| e.printStackTrace(); | |||
| } | |||
| return rotation; | |||
| return degree; | |||
| } | |||
| public static Bitmap rotateBitmap(Bitmap bitmap, int angle) { | |||
| public static Bitmap rotateBitmapByDegree(Bitmap bm, int degree) { | |||
| Bitmap returnBm = null; | |||
| Matrix matrix = new Matrix(); | |||
| matrix.postRotate(angle); | |||
| Bitmap result = null; | |||
| matrix.postRotate(degree); | |||
| try { | |||
| result = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); | |||
| returnBm = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), matrix, true); | |||
| } catch (OutOfMemoryError e) { | |||
| Log.e(TAG, "Failed to rotate bitmap: " + e.getMessage()); | |||
| } | |||
| if (result == null) { | |||
| return bitmap; | |||
| if (returnBm == null) { | |||
| returnBm = bm; | |||
| } | |||
| return result; | |||
| } | |||
| private static Matrix decodeExifOrientation(int orientation) { | |||
| Matrix matrix = new Matrix(); | |||
| switch (orientation) { | |||
| case androidx.exifinterface.media.ExifInterface.ORIENTATION_NORMAL: | |||
| case androidx.exifinterface.media.ExifInterface.ORIENTATION_UNDEFINED: | |||
| break; | |||
| case androidx.exifinterface.media.ExifInterface.ORIENTATION_ROTATE_90: | |||
| matrix.postRotate(90F); | |||
| break; | |||
| case androidx.exifinterface.media.ExifInterface.ORIENTATION_ROTATE_180: | |||
| matrix.postRotate(180F); | |||
| break; | |||
| case androidx.exifinterface.media.ExifInterface.ORIENTATION_ROTATE_270: | |||
| matrix.postRotate(270F); | |||
| break; | |||
| case androidx.exifinterface.media.ExifInterface.ORIENTATION_FLIP_HORIZONTAL: | |||
| matrix.postScale(-1F, 1F); | |||
| break; | |||
| case androidx.exifinterface.media.ExifInterface.ORIENTATION_FLIP_VERTICAL: | |||
| matrix.postScale(1F, -1F); | |||
| break; | |||
| case androidx.exifinterface.media.ExifInterface.ORIENTATION_TRANSPOSE: | |||
| matrix.postScale(-1F, 1F); | |||
| matrix.postRotate(270F); | |||
| break; | |||
| case androidx.exifinterface.media.ExifInterface.ORIENTATION_TRANSVERSE: | |||
| matrix.postScale(-1F, 1F); | |||
| matrix.postRotate(90F); | |||
| break; | |||
| default: | |||
| try { | |||
| new IllegalArgumentException("Invalid orientation: " + orientation); | |||
| } catch (Throwable throwable) { | |||
| throwable.printStackTrace(); | |||
| } | |||
| if (bm != returnBm) { | |||
| bm.recycle(); | |||
| } | |||
| return matrix; | |||
| return returnBm; | |||
| } | |||
| public static Bitmap scaleBitmapAndKeepRatio(Bitmap targetBmp, int reqHeightInPixels, int reqWidthInPixels) { | |||
| @@ -84,19 +84,19 @@ public class TrackingMobile { | |||
| } | |||
| msConfig.free(); | |||
| // Complile graph. | |||
| // Compile graph. | |||
| if (!session.compileGraph(model)) { | |||
| Log.e(TAG, "Compile graph failed"); | |||
| model.freeBuffer(); | |||
| return; | |||
| } | |||
| // Note: when use model.freeBuffer(), the model can not be complile graph again. | |||
| // Note: when use model.freeBuffer(), the model can not be compile graph again. | |||
| model.freeBuffer(); | |||
| } | |||
| public ModelTrackingResult execut(Bitmap bitmap) { | |||
| public ModelTrackingResult execute(Bitmap bitmap) { | |||
| // Set input tensor values. | |||
| List<MSTensor> inputs = session.getInputs(); | |||
| if (inputs.size() != 1) { | |||
| @@ -135,8 +135,8 @@ public class TrackingMobile { | |||
| int batch = output.getShape()[0]; | |||
| int channel = output.getShape()[1]; | |||
| int weight = output.getShape()[2]; | |||
| int hight = output.getShape()[3]; | |||
| int plane = weight * hight; | |||
| int height = output.getShape()[3]; | |||
| int plane = weight * height; | |||
| for (int n = 0; n < batch; n++) { | |||
| for (int c = 0; c < channel; c++) { | |||
| @@ -43,7 +43,7 @@ | |||
| android:layout_gravity="center" | |||
| android:gravity="center" | |||
| android:paddingLeft="4dp" | |||
| android:text="Choose a Image" | |||
| android:text="@string/title_choose_image" | |||
| android:textAllCaps="false" | |||
| android:textColor="@color/white" | |||
| android:textSize="20sp" /> | |||
| @@ -71,7 +71,7 @@ | |||
| android:background="@color/gray_btn" | |||
| android:gravity="center" | |||
| android:onClick="onClickPhoto" | |||
| android:text="PHOTO" | |||
| android:text="@string/btn_photo" | |||
| android:textAllCaps="false" | |||
| android:textColor="@color/white" | |||
| android:textSize="12sp" /> | |||
| @@ -85,7 +85,7 @@ | |||
| android:background="@color/gray_btn" | |||
| android:gravity="center" | |||
| android:onClick="onClickCamera" | |||
| android:text="CAMERA" | |||
| android:text="@string/btn_camera" | |||
| android:textAllCaps="false" | |||
| android:textColor="@color/white" | |||
| android:textSize="12sp" /> | |||
| @@ -99,7 +99,7 @@ | |||
| android:background="@color/gray_btn" | |||
| android:gravity="center" | |||
| android:onClick="onClickRecovery" | |||
| android:text="RECOVERY" | |||
| android:text="@string/btn_recovery" | |||
| android:textAllCaps="false" | |||
| android:textColor="@color/white" | |||
| android:textSize="12sp" /> | |||
| @@ -113,7 +113,7 @@ | |||
| android:background="@color/gray_btn" | |||
| android:gravity="center" | |||
| android:onClick="onClickSave" | |||
| android:text="SAVE" | |||
| android:text="@string/btn_save" | |||
| android:textAllCaps="false" | |||
| android:textColor="@color/white" | |||
| android:textSize="12sp" /> | |||
| @@ -124,7 +124,7 @@ | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginLeft="20dp" | |||
| android:layout_marginTop="10dp" | |||
| android:text="Choose a Background" | |||
| android:text="@string/title_choose_back" | |||
| android:textColor="@color/white" | |||
| android:textSize="20sp" /> | |||
| @@ -0,0 +1,15 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <resources> | |||
| <string name="app_name">ImageSegmentation</string> | |||
| <string name="no_pic_neededSave">Null Image needed to save</string> | |||
| <string name="save_success">Save success</string> | |||
| <string name="toast_original">Please select an original picture first</string> | |||
| <string name="toast_model_run">Previous Model still running</string> | |||
| <string name="title_choose_image">Choose an Image</string> | |||
| <string name="btn_photo">PHOTO</string> | |||
| <string name="btn_camera">CAMERA</string> | |||
| <string name="btn_recovery">RECOVERY</string> | |||
| <string name="btn_save">SAVE</string> | |||
| <string name="title_choose_back">Choose a Background</string> | |||
| </resources> | |||
| @@ -0,0 +1,15 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <resources> | |||
| <string name="app_name">图像分割</string> | |||
| <string name="no_pic_neededSave">没有需要保存的图片</string> | |||
| <string name="save_success">保存成功</string> | |||
| <string name="toast_original">请先选择原始图片</string> | |||
| <string name="toast_model_run">先前的模型仍在运行</string> | |||
| <string name="title_choose_image">选择图片</string> | |||
| <string name="btn_photo">图片</string> | |||
| <string name="btn_camera">相机</string> | |||
| <string name="btn_recovery">恢复</string> | |||
| <string name="btn_save">保存</string> | |||
| <string name="title_choose_back">选择背景</string> | |||
| </resources> | |||
| @@ -2,4 +2,14 @@ | |||
| <string name="app_name">ImageSegmentation</string> | |||
| <string name="no_pic_neededSave">Null Image needed to save</string> | |||
| <string name="save_success">Save success</string> | |||
| <string name="toast_original">Please select an original picture first</string> | |||
| <string name="toast_model_run">Previous Model still running</string> | |||
| <string name="title_choose_image">Choose an Image</string> | |||
| <string name="btn_photo">PHOTO</string> | |||
| <string name="btn_camera">CAMERA</string> | |||
| <string name="btn_recovery">RECOVERY</string> | |||
| <string name="btn_save">SAVE</string> | |||
| <string name="title_choose_back">Choose a Background</string> | |||
| </resources> | |||
| @@ -4,4 +4,4 @@ include ':imageObject' | |||
| include ':styletransfer' | |||
| include ':posenet' | |||
| include ':app' | |||
| rootProject.name = "HiMindSpore" | |||
| rootProject.name = "MindSpore" | |||
| @@ -63,7 +63,7 @@ apply from: 'download.gradle' | |||
| dependencies { | |||
| implementation 'androidx.legacy:legacy-support-v4:1.0.0' | |||
| implementation 'androidx.recyclerview:recyclerview:1.1.0' | |||
| implementation 'androidx.appcompat:appcompat:1.2.0' | |||
| implementation 'androidx.appcompat:appcompat:1.3.0-alpha02' | |||
| implementation 'androidx.constraintlayout:constraintlayout:2.0.4' | |||
| testImplementation 'junit:junit:4.12' | |||
| androidTestImplementation 'androidx.test.ext:junit:1.1.2' | |||
| @@ -249,13 +249,10 @@ public class ImageUtils { | |||
| Log.e(TAG, e.getMessage()); | |||
| } | |||
| MediaScannerConnection.scanFile(context, new String[]{path}, null, | |||
| new MediaScannerConnection.OnScanCompletedListener() { | |||
| @Override | |||
| public void onScanCompleted(String path, Uri uri) { | |||
| Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); | |||
| mediaScanIntent.setData(uri); | |||
| context.sendBroadcast(mediaScanIntent); | |||
| } | |||
| (path1, uri) -> { | |||
| Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); | |||
| mediaScanIntent.setData(uri); | |||
| context.sendBroadcast(mediaScanIntent); | |||
| }); | |||
| } else { | |||
| String relationDir = file.getParent(); | |||
| @@ -108,7 +108,7 @@ public class StyleMainActivity extends AppCompatActivity implements OnBackground | |||
| if (originBitmap != null) { | |||
| Glide.with(this).load(originBitmap).into(imgPreview); | |||
| } else { | |||
| Toast.makeText(this, "Please select an original picture first", Toast.LENGTH_SHORT).show(); | |||
| Toast.makeText(this, R.string.toast_original, Toast.LENGTH_SHORT).show(); | |||
| } | |||
| } | |||
| @@ -209,7 +209,7 @@ public class StyleMainActivity extends AppCompatActivity implements OnBackground | |||
| private void startRunningModel(Bitmap styleBitmap) { | |||
| if (originBitmap == null) { | |||
| Toast.makeText(this, "Please select an original picture first", Toast.LENGTH_SHORT).show(); | |||
| Toast.makeText(this, R.string.toast_original, Toast.LENGTH_SHORT).show(); | |||
| return; | |||
| } | |||
| @@ -219,15 +219,14 @@ public class StyleMainActivity extends AppCompatActivity implements OnBackground | |||
| ModelExecutionResult result = transferModelExecutor.execute(originBitmap, styleBitmap); | |||
| if (null != result && null != result.getStyledImage()) { | |||
| resultBitmap = BitmapUtils.changeBitmapSize(result.getStyledImage(), originBitmap.getWidth(), originBitmap.getHeight()); | |||
| Log.e("AAA", "w>>" + resultBitmap.getWidth() + ">>>h>>" + resultBitmap.getHeight()); | |||
| Glide.with(this).load(resultBitmap).override(resultBitmap.getWidth(), resultBitmap.getHeight()).into(imgPreview); | |||
| } else { | |||
| Toast.makeText(this, "ModelExecute failed", Toast.LENGTH_SHORT).show(); | |||
| Toast.makeText(this, R.string.toast_execute_fail, Toast.LENGTH_SHORT).show(); | |||
| } | |||
| isRunningModel = false; | |||
| progressBar.setVisibility(View.INVISIBLE); | |||
| } else { | |||
| Toast.makeText(this, "Previous Model still running", Toast.LENGTH_SHORT).show(); | |||
| Toast.makeText(this, R.string.toast_model_run, Toast.LENGTH_SHORT).show(); | |||
| } | |||
| } | |||
| @@ -34,7 +34,6 @@ import java.nio.FloatBuffer; | |||
| import java.util.LinkedHashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import java.util.Set; | |||
| public class StyleTransferModelExecutor { | |||
| @@ -96,7 +95,7 @@ public class StyleTransferModelExecutor { | |||
| msConfig.free(); | |||
| // Complile graph. | |||
| // Compile graph. | |||
| if (!Predict_session.compileGraph(style_predict_model)) { | |||
| Log.e("MS_LITE", "Compile style_predict graph failed"); | |||
| style_predict_model.freeBuffer(); | |||
| @@ -106,7 +105,7 @@ public class StyleTransferModelExecutor { | |||
| style_transform_model.freeBuffer(); | |||
| } | |||
| // Note: when use model.freeBuffer(), the model can not be complile graph again. | |||
| // Note: when use model.freeBuffer(), the model can not be compile graph again. | |||
| style_predict_model.freeBuffer(); | |||
| style_transform_model.freeBuffer(); | |||
| } | |||
| @@ -151,10 +150,29 @@ public class StyleTransferModelExecutor { | |||
| stylePredictTime = SystemClock.uptimeMillis() - stylePredictTime; | |||
| Log.d(TAG, "Style Predict Time to run: " + stylePredictTime); | |||
| float[][][][] outputImage = getDealData(contentArray); | |||
| Bitmap styledImage = | |||
| ImageUtils.convertArrayToBitmap(outputImage, CONTENT_IMAGE_SIZE, CONTENT_IMAGE_SIZE); | |||
| postProcessTime = SystemClock.uptimeMillis() - postProcessTime; | |||
| fullExecutionTime = SystemClock.uptimeMillis() - fullExecutionTime; | |||
| Log.d(TAG, "Time to run everything: $" + fullExecutionTime); | |||
| return new ModelExecutionResult(styledImage, | |||
| preProcessTime, | |||
| stylePredictTime, | |||
| styleTransferTime, | |||
| postProcessTime, | |||
| fullExecutionTime, | |||
| formatExecutionLog()); | |||
| } | |||
| @SuppressLint("LongLogTag") | |||
| private float[][][][] getDealData(ByteBuffer contentArray) { | |||
| // Get output tensor values. | |||
| List<String> tensorNames = Predict_session.getOutputTensorNames(); | |||
| Map<String, MSTensor> outputs = Predict_session.getOutputMapByTensor(); | |||
| Set<Map.Entry<String, MSTensor>> entrys = outputs.entrySet(); | |||
| float[] Predict_results = null; | |||
| for (String tensorName : tensorNames) { | |||
| @@ -163,11 +181,9 @@ public class StyleTransferModelExecutor { | |||
| Log.e("MS_LITE", "Can not find Predict_session output " + tensorName); | |||
| return null; | |||
| } | |||
| int type = output.getDataType(); | |||
| Predict_results = output.getFloatData(); | |||
| } | |||
| List<MSTensor> Transform_inputs = Transform_session.getInputs(); | |||
| // transform model have 2 input tensor, tensor0: 1*1*1*100, tensor1;1*384*384*3 | |||
| MSTensor Transform_inputs_inTensor0 = Transform_inputs.get(0); | |||
| @@ -217,24 +233,9 @@ public class StyleTransferModelExecutor { | |||
| } | |||
| outputImage[x] = arrayThree; | |||
| } | |||
| Bitmap styledImage = | |||
| ImageUtils.convertArrayToBitmap(outputImage, CONTENT_IMAGE_SIZE, CONTENT_IMAGE_SIZE); | |||
| postProcessTime = SystemClock.uptimeMillis() - postProcessTime; | |||
| fullExecutionTime = SystemClock.uptimeMillis() - fullExecutionTime; | |||
| Log.d(TAG, "Time to run everything: $" + fullExecutionTime); | |||
| return new ModelExecutionResult(styledImage, | |||
| preProcessTime, | |||
| stylePredictTime, | |||
| styleTransferTime, | |||
| postProcessTime, | |||
| fullExecutionTime, | |||
| formatExecutionLog()); | |||
| return outputImage; | |||
| } | |||
| private String formatExecutionLog() { | |||
| StringBuilder sb = new StringBuilder(); | |||
| sb.append("Input Image Size:" + CONTENT_IMAGE_SIZE * CONTENT_IMAGE_SIZE) | |||
| @@ -43,7 +43,7 @@ | |||
| android:layout_gravity="center" | |||
| android:gravity="center" | |||
| android:paddingLeft="4dp" | |||
| android:text="Choose a Image" | |||
| android:text="@string/title_choose_image" | |||
| android:textAllCaps="false" | |||
| android:textColor="@color/white" | |||
| android:textSize="20sp" /> | |||
| @@ -72,7 +72,7 @@ | |||
| android:background="@color/gray_btn" | |||
| android:gravity="center" | |||
| android:onClick="onClickPhoto" | |||
| android:text="PHOTO" | |||
| android:text="@string/btn_photo" | |||
| android:textAllCaps="false" | |||
| android:textColor="@color/white" | |||
| android:textSize="12sp" /> | |||
| @@ -86,7 +86,7 @@ | |||
| android:background="@color/gray_btn" | |||
| android:gravity="center" | |||
| android:onClick="onClickCamera" | |||
| android:text="CAMERA" | |||
| android:text="@string/btn_camera" | |||
| android:textAllCaps="false" | |||
| android:textColor="@color/white" | |||
| android:textSize="12sp" /> | |||
| @@ -100,7 +100,7 @@ | |||
| android:background="@color/gray_btn" | |||
| android:gravity="center" | |||
| android:onClick="onClickRecovery" | |||
| android:text="RECOVERY" | |||
| android:text="@string/btn_recovery" | |||
| android:textAllCaps="false" | |||
| android:textColor="@color/white" | |||
| android:textSize="12sp" /> | |||
| @@ -114,7 +114,7 @@ | |||
| android:background="@color/gray_btn" | |||
| android:gravity="center" | |||
| android:onClick="onClickSave" | |||
| android:text="SAVE" | |||
| android:text="@string/btn_save" | |||
| android:textAllCaps="false" | |||
| android:textColor="@color/white" | |||
| android:textSize="12sp" /> | |||
| @@ -125,7 +125,7 @@ | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginLeft="20dp" | |||
| android:layout_marginTop="20dp" | |||
| android:text="Choose a Style" | |||
| android:text="@string/title_choose_style" | |||
| android:textColor="@color/white" | |||
| android:textSize="20sp" /> | |||
| @@ -0,0 +1,16 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <resources> | |||
| <string name="app_name">StyleTransfer</string> | |||
| <!-- TODO: Remove or change this placeholder text --> | |||
| <string name="no_pic_neededSave">Null Image needed to save</string> | |||
| <string name="save_success">Save success</string> | |||
| <string name="toast_original">Please select an original picture first</string> | |||
| <string name="toast_model_run">Previous Model still running</string> | |||
| <string name="title_choose_image">Choose an Image</string> | |||
| <string name="btn_photo">PHOTO</string> | |||
| <string name="btn_camera">CAMERA</string> | |||
| <string name="btn_recovery">RECOVERY</string> | |||
| <string name="btn_save">SAVE</string> | |||
| <string name="title_choose_style">Choose a Style</string> | |||
| <string name="toast_execute_fail">ModelExecute failed</string></resources> | |||
| @@ -0,0 +1,16 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <resources> | |||
| <string name="app_name">StyleTransfer</string> | |||
| <string name="no_pic_neededSave">没有需要保存的图片</string> | |||
| <string name="save_success">保存成功</string> | |||
| <string name="toast_original">请先选择原始图片</string> | |||
| <string name="toast_model_run">先前的模型仍在运行</string> | |||
| <string name="title_choose_image">选择图片</string> | |||
| <string name="btn_photo">图片</string> | |||
| <string name="btn_camera">相机</string> | |||
| <string name="btn_recovery">恢复</string> | |||
| <string name="btn_save">保存</string> | |||
| <string name="title_choose_style">选择风格</string> | |||
| <string name="toast_execute_fail">解析失败</string> | |||
| </resources> | |||
| @@ -3,4 +3,14 @@ | |||
| <!-- TODO: Remove or change this placeholder text --> | |||
| <string name="no_pic_neededSave">Null Image needed to save</string> | |||
| <string name="save_success">Save success</string> | |||
| <string name="toast_original">Please select an original picture first</string> | |||
| <string name="toast_model_run">Previous Model still running</string> | |||
| <string name="title_choose_image">Choose an Image</string> | |||
| <string name="btn_photo">PHOTO</string> | |||
| <string name="btn_camera">CAMERA</string> | |||
| <string name="btn_recovery">RECOVERY</string> | |||
| <string name="btn_save">SAVE</string> | |||
| <string name="title_choose_style">Choose a Style</string> | |||
| <string name="toast_execute_fail">ModelExecute failed</string> | |||
| </resources> | |||