diff --git a/model_zoo/official/lite/Himindspore/app/build.gradle b/model_zoo/official/lite/Himindspore/app/build.gradle index b37220a2383..0d86b0e8288 100644 --- a/model_zoo/official/lite/Himindspore/app/build.gradle +++ b/model_zoo/official/lite/Himindspore/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId "com.mindspore.himindspore" minSdkVersion 21 targetSdkVersion 30 - versionCode 2 - versionName "1.1.0" + versionCode 3 + versionName "1.1.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" javaCompileOptions { @@ -25,13 +25,23 @@ android { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } - } aaptOptions { noCompress "ms" } + repositories { + google() + jcenter() + mavenCentral() + maven { url "https://jitpack.io" } + + flatDir { + dirs 'libs', '../mindsporelibrary/libs' + } + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 @@ -45,7 +55,6 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'androidx.cardview:cardview:1.0.0' - testImplementation 'junit:junit:4.13.1' androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' diff --git a/model_zoo/official/lite/Himindspore/app/src/main/AndroidManifest.xml b/model_zoo/official/lite/Himindspore/app/src/main/AndroidManifest.xml index 089d4e1c711..07b96683100 100644 --- a/model_zoo/official/lite/Himindspore/app/src/main/AndroidManifest.xml +++ b/model_zoo/official/lite/Himindspore/app/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ @@ -21,10 +22,11 @@ android:requestLegacyExternalStorage="true" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" + tools:replace="android:label" android:theme="@style/AppTheme"> + android:resource="@xml/style_file_paths" /> + android:resource="@xml/style_file_paths" /> diff --git a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/SplashActivity.java b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/SplashActivity.java index 0899de37c4f..eb5fce60e8f 100644 --- a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/SplashActivity.java +++ b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/SplashActivity.java @@ -24,6 +24,7 @@ import android.content.pm.PackageManager; import android.net.Uri; import android.os.Build; import android.os.Environment; +import android.provider.Settings; import android.util.Log; import android.view.View; import android.widget.TextView; @@ -32,6 +33,7 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; import androidx.core.content.FileProvider; import com.alibaba.android.arouter.facade.annotation.Route; @@ -48,9 +50,12 @@ import java.io.File; public class SplashActivity extends BaseActivity implements MainContract.View { private static final String TAG = "SplashActivity"; + + private static final String[] PERMISSIONS = {Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, + Manifest.permission.READ_PHONE_STATE, Manifest.permission.CAMERA}; private static final int REQUEST_PERMISSION = 1; - private boolean isHasPermssion; + private boolean isAllGranted; private int now_version; private ProgressDialog progressDialog; @@ -83,13 +88,27 @@ public class SplashActivity extends BaseActivity implements MainC } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } - } private void requestPermissions() { - ActivityCompat.requestPermissions(this, - new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, - Manifest.permission.READ_PHONE_STATE, Manifest.permission.CAMERA}, REQUEST_PERMISSION); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + isAllGranted = checkPermissionAllGranted(PERMISSIONS); + if (!isAllGranted) { + ActivityCompat.requestPermissions(this, PERMISSIONS, REQUEST_PERMISSION); + } + } else { + isAllGranted = true; + } + } + + + private boolean checkPermissionAllGranted(String[] permissions) { + for (String permission : permissions) { + if (ContextCompat.checkSelfPermission(this, permission) != PackageManager.PERMISSION_GRANTED) { + return false; + } + } + return true; } /** @@ -98,17 +117,47 @@ public class SplashActivity extends BaseActivity implements MainC @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { if (REQUEST_PERMISSION == requestCode) { - isHasPermssion = true; + isAllGranted = true; + + for (int grant : grantResults) { + if (grant != PackageManager.PERMISSION_GRANTED) { + isAllGranted = false; + break; + } + } + if (!isAllGranted) { + openAppDetails(); + } } } + 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.setNegativeButton("取消", null); + builder.show(); + } + private void getUpdateInfo() { presenter.getUpdateInfo(); } public void onClickImage(View view) { - if (isHasPermssion) { + if (isAllGranted) { ARouter.getInstance().build("/imageobject/ImageCameraActivity") .withInt("OPEN_TYPE", 1).navigation(); } else { @@ -117,7 +166,7 @@ public class SplashActivity extends BaseActivity implements MainC } public void onClickGarbage(View view) { - if (isHasPermssion) { + if (isAllGranted) { ARouter.getInstance().build("/imageobject/ImageCameraActivity") .withInt("OPEN_TYPE", 2).navigation(); } else { @@ -126,7 +175,7 @@ public class SplashActivity extends BaseActivity implements MainC } public void onClickPhotoDetection(View view) { - if (isHasPermssion) { + if (isAllGranted) { ARouter.getInstance().build("/imageobject/ObjectPhotoActivity").navigation(); } else { requestPermissions(); @@ -134,7 +183,7 @@ public class SplashActivity extends BaseActivity implements MainC } public void onClickCameraDetection(View view) { - if (isHasPermssion) { + if (isAllGranted) { ARouter.getInstance().build("/imageobject/ObjectCameraActivity").navigation(); } else { requestPermissions(); @@ -142,7 +191,7 @@ public class SplashActivity extends BaseActivity implements MainC } public void onClickPoseNet(View view) { - if (isHasPermssion) { + if (isAllGranted) { ARouter.getInstance().build("/posenet/PosenetMainActivity").navigation(this); } else { requestPermissions(); @@ -150,7 +199,7 @@ public class SplashActivity extends BaseActivity implements MainC } public void onClickStyleTransfer(View view) { - if (isHasPermssion) { + if (isAllGranted) { ARouter.getInstance().build("/styletransfer/StyleMainActivity").navigation(this); } else { requestPermissions(); @@ -219,7 +268,6 @@ public class SplashActivity extends BaseActivity implements MainC public void showUpdate(final UpdateInfoBean updateInfo) { - if (now_version == updateInfo.getVersionCode()) { Toast.makeText(this, "已经是最新版本", Toast.LENGTH_SHORT).show(); Log.d(TAG + "版本号是", "onResponse: " + now_version); diff --git a/model_zoo/official/lite/Himindspore/app/src/main/res/values/styles.xml b/model_zoo/official/lite/Himindspore/app/src/main/res/values/styles.xml index d9b3e2990fb..e15b87cc9e3 100644 --- a/model_zoo/official/lite/Himindspore/app/src/main/res/values/styles.xml +++ b/model_zoo/official/lite/Himindspore/app/src/main/res/values/styles.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/model_zoo/official/lite/Himindspore/settings.gradle b/model_zoo/official/lite/Himindspore/settings.gradle index 71505fc553d..02f6392ec58 100644 --- a/model_zoo/official/lite/Himindspore/settings.gradle +++ b/model_zoo/official/lite/Himindspore/settings.gradle @@ -1,3 +1,4 @@ +include ':mindsporelibrary' include ':imageObject' include ':styletransfer' include ':posenet' diff --git a/model_zoo/official/lite/Himindspore/styletransfer/build.gradle b/model_zoo/official/lite/Himindspore/styletransfer/build.gradle index eb480f75566..0149c803f4e 100644 --- a/model_zoo/official/lite/Himindspore/styletransfer/build.gradle +++ b/model_zoo/official/lite/Himindspore/styletransfer/build.gradle @@ -46,7 +46,7 @@ android { google() jcenter() flatDir { - dirs 'libs' + dirs 'libs', '../mindsporelibrary/libs' } } @@ -63,7 +63,6 @@ apply from: 'download.gradle' dependencies { implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.recyclerview:recyclerview:1.1.0' - implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' testImplementation 'junit:junit:4.12' @@ -75,5 +74,7 @@ dependencies { implementation 'com.alibaba:arouter-api:1.2.1' annotationProcessor 'com.alibaba:arouter-compiler:1.1.2' + implementation(name: 'mindspore-lite-1.0.1', ext: 'aar') + } \ No newline at end of file diff --git a/model_zoo/official/lite/Himindspore/styletransfer/download.gradle b/model_zoo/official/lite/Himindspore/styletransfer/download.gradle index 5a5e4fe2cd6..31b48c84f49 100644 --- a/model_zoo/official/lite/Himindspore/styletransfer/download.gradle +++ b/model_zoo/official/lite/Himindspore/styletransfer/download.gradle @@ -3,16 +3,10 @@ * Including mindspore-lite .so file, minddata-lite .so file and model file. * The libraries can be downloaded manually. */ -def mindsporeLite_Version = "mindspore-lite-maven-1.0.1" def targetPredictModelFile = "src/main/assets/style_predict_quant.ms" def targetTransferModelFile = "src/main/assets/style_transfer_quant.ms" def modelPredictDownloadUrl = "https://download.mindspore.cn/model_zoo/official/lite/style_lite/style_predict_quant.ms" def modelTransferDownloadUrl = "https://download.mindspore.cn/model_zoo/official/lite/style_lite/style_transfer_quant.ms" -def mindsporeLiteDownloadUrl = "https://ms-release.obs.cn-north-4.myhuaweicloud.com/1.0.1/lite/java/${mindsporeLite_Version}.zip" -def mindSporeLibrary = "libs/${mindsporeLite_Version}.zip" -def cleantargetMindSporeInclude = "libs" -def targetMindSporeInclude = "libs/" - task downloadPredictModelFile(type: DownloadUrlTask) { doFirst { @@ -30,36 +24,6 @@ task downloadTransferModelFile(type: DownloadUrlTask) { target = file("${targetTransferModelFile}") } - -task downloadMindSporeLibrary(type: DownloadUrlTask) { - doFirst { - println "Downloading ${mindsporeLiteDownloadUrl}" - } - sourceUrl = "${mindsporeLiteDownloadUrl}" - target = file("${mindSporeLibrary}") -} - -task unzipMindSporeInclude(type: Copy, dependsOn: ['downloadMindSporeLibrary']) { - doFirst { - println "Unzipping ${mindSporeLibrary}" - } - from zipTree("${mindSporeLibrary}") - into "${targetMindSporeInclude}" -} - -task cleanUnusedmindsporeFiles(type: Delete, dependsOn: ['unzipMindSporeInclude']) { - delete fileTree("${cleantargetMindSporeInclude}").matching { - include "*.zip" - } -} - -if (file("libs/mindspore-lite-1.0.1.aar").exists()) { - downloadMindSporeLibrary.enabled = false - unzipMindSporeInclude.enabled = false - cleanUnusedmindsporeFiles.enabled = false -} - - if (file("src/main/assets/style_transfer_quant.ms").exists()) { downloadTransferModelFile.enabled = false } @@ -70,9 +34,6 @@ if (file("src/main/assets/style_predict_quant.ms").exists()) { preBuild.dependsOn downloadPredictModelFile preBuild.dependsOn downloadTransferModelFile -preBuild.dependsOn downloadMindSporeLibrary -preBuild.dependsOn unzipMindSporeInclude -preBuild.dependsOn cleanUnusedmindsporeFiles class DownloadUrlTask extends DefaultTask { @Input diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/AndroidManifest.xml b/model_zoo/official/lite/Himindspore/styletransfer/src/main/AndroidManifest.xml index 6dc2abdcd25..98ff0b5e299 100644 --- a/model_zoo/official/lite/Himindspore/styletransfer/src/main/AndroidManifest.xml +++ b/model_zoo/official/lite/Himindspore/styletransfer/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ + + + + - \ No newline at end of file diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/java/com/mindspore/styletransfer/BitmapUtils.java b/model_zoo/official/lite/Himindspore/styletransfer/src/main/java/com/mindspore/styletransfer/BitmapUtils.java index b3820550d23..e4befcae9bd 100644 --- a/model_zoo/official/lite/Himindspore/styletransfer/src/main/java/com/mindspore/styletransfer/BitmapUtils.java +++ b/model_zoo/official/lite/Himindspore/styletransfer/src/main/java/com/mindspore/styletransfer/BitmapUtils.java @@ -89,7 +89,7 @@ public class BitmapUtils { } // Scale pictures to screen width. - private static Bitmap zoomImage(Bitmap imageBitmap, int targetWidth, int maxHeight) { + public static Bitmap zoomImage(Bitmap imageBitmap, int targetWidth, int maxHeight) { float scaleFactor = Math.max( (float) imageBitmap.getWidth() / (float) targetWidth, @@ -104,6 +104,26 @@ public class BitmapUtils { return resizedBitmap; } + public static Bitmap changeBitmapSize(Bitmap bitmap, int targetWidth, int targetHeight) { + int width = bitmap.getWidth(); + int height = bitmap.getHeight(); + Log.e("width", "width:" + width); + Log.e("height", "height:" + height); + + float scaleWidth = ((float) targetWidth) / width; + float scaleHeight = ((float) targetHeight) / height; + + Matrix matrix = new Matrix(); + matrix.postScale(scaleWidth, scaleHeight); + + bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); + bitmap.getWidth(); + bitmap.getHeight(); + Log.e("newWidth", "newWidth" + bitmap.getWidth()); + Log.e("newHeight", "newHeight" + bitmap.getHeight()); + return bitmap; + } + /** * Get the rotation angle of the photo. * diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/java/com/mindspore/styletransfer/ImageUtils.java b/model_zoo/official/lite/Himindspore/styletransfer/src/main/java/com/mindspore/styletransfer/ImageUtils.java index 53382b6869f..9d7c35da1fc 100644 --- a/model_zoo/official/lite/Himindspore/styletransfer/src/main/java/com/mindspore/styletransfer/ImageUtils.java +++ b/model_zoo/official/lite/Himindspore/styletransfer/src/main/java/com/mindspore/styletransfer/ImageUtils.java @@ -16,16 +16,24 @@ package com.mindspore.styletransfer; import android.content.Context; +import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Color; import android.graphics.Matrix; import android.graphics.RectF; +import android.media.MediaScannerConnection; +import android.net.Uri; +import android.os.Build; +import android.os.Environment; +import android.util.Log; import androidx.annotation.NonNull; import androidx.exifinterface.media.ExifInterface; import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; @@ -33,6 +41,8 @@ import java.nio.ByteOrder; public class ImageUtils { + private static final String TAG = "ImageUtils"; + private static Matrix decodeExifOrientation(int orientation) { Matrix matrix = new Matrix(); @@ -198,4 +208,59 @@ public class ImageUtils { } return ret; } + + // Save the picture to the system album and refresh it. + public static void saveToAlbum(final Context context, Bitmap bitmap) { + File file = null; + String fileName = System.currentTimeMillis() + ".jpg"; + File root = new File(Environment.getExternalStorageDirectory().getAbsoluteFile(), context.getPackageName()); + File dir = new File(root, "image"); + if (dir.mkdirs() || dir.isDirectory()) { + file = new File(dir, fileName); + } + FileOutputStream os = null; + try { + os = new FileOutputStream(file); + bitmap.compress(Bitmap.CompressFormat.JPEG, 100, os); + os.flush(); + + } catch (FileNotFoundException e) { + Log.e(TAG, e.getMessage()); + } catch (IOException e) { + Log.e(TAG, e.getMessage()); + } finally { + try { + if (os != null) { + os.close(); + } + } catch (IOException e) { + Log.e(TAG, e.getMessage()); + } + } + if (file == null) { + return; + } + // Gallery refresh. + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + String path = null; + try { + path = file.getCanonicalPath(); + } catch (IOException e) { + 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); + } + }); + } else { + String relationDir = file.getParent(); + File file1 = new File(relationDir); + context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.fromFile(file1.getAbsoluteFile()))); + } + } } \ No newline at end of file diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/java/com/mindspore/styletransfer/OnBackgroundImageListener.java b/model_zoo/official/lite/Himindspore/styletransfer/src/main/java/com/mindspore/styletransfer/OnBackgroundImageListener.java new file mode 100644 index 00000000000..e12ad473a3b --- /dev/null +++ b/model_zoo/official/lite/Himindspore/styletransfer/src/main/java/com/mindspore/styletransfer/OnBackgroundImageListener.java @@ -0,0 +1,9 @@ +package com.mindspore.styletransfer; + +import android.view.View; + +public interface OnBackgroundImageListener { + void onBackImageSelected(int position); + + void onImageAdd(View view); +} diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/java/com/mindspore/styletransfer/OnListFragmentInteractionListener.java b/model_zoo/official/lite/Himindspore/styletransfer/src/main/java/com/mindspore/styletransfer/OnListFragmentInteractionListener.java deleted file mode 100644 index 9ba62bd62f2..00000000000 --- a/model_zoo/official/lite/Himindspore/styletransfer/src/main/java/com/mindspore/styletransfer/OnListFragmentInteractionListener.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.mindspore.styletransfer; - -public interface OnListFragmentInteractionListener { - void onListFragmentInteraction(String item); -} diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/java/com/mindspore/styletransfer/StyleMainActivity.java b/model_zoo/official/lite/Himindspore/styletransfer/src/main/java/com/mindspore/styletransfer/StyleMainActivity.java index f1d731eeef3..a1f24cfc4d3 100644 --- a/model_zoo/official/lite/Himindspore/styletransfer/src/main/java/com/mindspore/styletransfer/StyleMainActivity.java +++ b/model_zoo/official/lite/Himindspore/styletransfer/src/main/java/com/mindspore/styletransfer/StyleMainActivity.java @@ -18,44 +18,54 @@ package com.mindspore.styletransfer; import android.content.Intent; import android.content.res.Configuration; import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.net.Uri; import android.os.Bundle; +import android.os.Environment; import android.provider.MediaStore; -import android.text.TextUtils; import android.util.Log; import android.util.Pair; import android.view.View; -import android.widget.Button; import android.widget.ImageView; +import android.widget.ProgressBar; +import android.widget.TextView; import android.widget.Toast; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; +import androidx.core.content.FileProvider; import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.RecyclerView; import com.alibaba.android.arouter.facade.annotation.Route; import com.bumptech.glide.Glide; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import java.io.File; +import java.io.FileNotFoundException; @Route(path = "/styletransfer/StyleMainActivity") -public class StyleMainActivity extends AppCompatActivity implements View.OnClickListener, OnListFragmentInteractionListener { +public class StyleMainActivity extends AppCompatActivity implements OnBackgroundImageListener { private static final String TAG = "StyleMainActivity"; + private static final int[] IMAGES = {R.drawable.style0, R.drawable.style1, R.drawable.style2, R.drawable.style3, R.drawable.style4, + R.drawable.style5, R.drawable.style6, R.drawable.style7, R.drawable.style8, R.drawable.style9, + R.drawable.style10, R.drawable.style11, R.drawable.style12, R.drawable.style13, R.drawable.style14, + R.drawable.style15, R.drawable.style16, R.drawable.style17, R.drawable.style18, R.drawable.style19, R.drawable.add}; + private static final int RC_CHOOSE_PHOTO = 1; + private static final int RC_CHOOSE_PHOTO_FOR_BACKGROUND = 11; + private static final int RC_CHOOSE_CAMERA = 2; + private StyleTransferModelExecutor transferModelExecutor; private boolean isRunningModel; - private ImageView imgOrigin; - private Button btnImage; + private ImageView imgPreview; private Uri imageUri; + private TextView textOriginImage; + private ProgressBar progressBar; private RecyclerView recyclerView; @@ -63,8 +73,7 @@ public class StyleMainActivity extends AppCompatActivity implements View.OnClick private Integer maxHeightOfImage; private boolean isLandScape; - private Bitmap originBitmap, styleBitmap; - private String selectedStyle; + private Bitmap originBitmap, styleBitmap, resultBitmap; @Override protected void onCreate(Bundle savedInstanceState) { @@ -75,52 +84,78 @@ public class StyleMainActivity extends AppCompatActivity implements View.OnClick } private void init() { - imgOrigin = findViewById(R.id.img_origin); - btnImage = findViewById(R.id.btn_image); - imgOrigin.setOnClickListener(this); - btnImage.setOnClickListener(this); - + imgPreview = findViewById(R.id.img_origin); + textOriginImage = findViewById(R.id.tv_image); + progressBar = findViewById(R.id.progress); recyclerView = findViewById(R.id.recyclerview); - List styles = new ArrayList<>(); - try { - styles.addAll(Arrays.asList(getAssets().list("thumbnails"))); - } catch (IOException e) { - e.printStackTrace(); - } - - GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 3); - recyclerView.setLayoutManager(gridLayoutManager); - recyclerView.setAdapter(new StyleRecyclerViewAdapter(this, styles, this)); + recyclerView.setLayoutManager(new GridLayoutManager(this, 3)); + recyclerView.setAdapter(new StyleRecyclerViewAdapter(this, IMAGES, this)); transferModelExecutor = new StyleTransferModelExecutor(this, false); } + public void onClickPhoto(View view) { + openGallay(RC_CHOOSE_PHOTO); + textOriginImage.setVisibility(View.GONE); + } - @Override - public void onClick(View view) { - if (view.getId() == R.id.img_origin || view.getId() == R.id.btn_image) { - btnImage.setVisibility(View.GONE); - openGallay(); + public void onClickCamera(View view) { + openCamera(); + textOriginImage.setVisibility(View.GONE); + } + + public void onClickRecovery(View view) { + if (originBitmap != null) { + Glide.with(this).load(originBitmap).into(imgPreview); + } else { + Toast.makeText(this, "Please select an original picture first", Toast.LENGTH_SHORT).show(); } } - private void openGallay() { + public void onClickSave(View view) { + if (this.resultBitmap == null) { + Log.e(TAG, "null processed image"); + Toast.makeText(this.getApplicationContext(), R.string.no_pic_neededSave, Toast.LENGTH_SHORT).show(); + } else { + ImageUtils.saveToAlbum(getApplicationContext(), this.resultBitmap); + Toast.makeText(this.getApplicationContext(), R.string.save_success, Toast.LENGTH_SHORT).show(); + } + } + + private void openGallay(int request) { Intent intentToPickPic = new Intent(Intent.ACTION_PICK, null); intentToPickPic.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*"); - startActivityForResult(intentToPickPic, RC_CHOOSE_PHOTO); + startActivityForResult(intentToPickPic, request); + } + + private void openCamera() { + Intent intentToTakePhoto = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); + String mTempPhotoPath = Environment.getExternalStorageDirectory() + File.separator + "photo.jpeg"; + imageUri = FileProvider.getUriForFile(this, getApplicationContext().getPackageName() + ".fileprovider", new File(mTempPhotoPath)); + intentToTakePhoto.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); + startActivityForResult(intentToTakePhoto, RC_CHOOSE_CAMERA); } @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()) { - if (data != null) { - this.imageUri = data.getData(); - showOriginImage(); + if (resultCode == RESULT_OK) { + if (RC_CHOOSE_PHOTO == requestCode) { + if (null != data && null != data.getData()) { + this.imageUri = data.getData(); + showOriginImage(); + } else { + finish(); + } + } else if (RC_CHOOSE_PHOTO_FOR_BACKGROUND == requestCode) { + if (null != data && null != data.getData()) { + showCustomBack(data.getData()); + } else { + finish(); + } + } else if (RC_CHOOSE_CAMERA == requestCode) { + showOriginCamera(); } - } else { - finish(); } } @@ -128,49 +163,81 @@ public class StyleMainActivity extends AppCompatActivity implements View.OnClick Pair targetedSize = this.getTargetSize(); int targetWidth = targetedSize.first; int maxHeight = targetedSize.second; - originBitmap = BitmapUtils.loadFromPath(StyleMainActivity.this, imageUri, targetWidth, maxHeight); + originBitmap = BitmapUtils.loadFromPath(this, imageUri, targetWidth, maxHeight); // Determine how much to scale down the image. - Log.i(TAG, "resized image size width:" + originBitmap.getWidth() + ",height: " + originBitmap.getHeight()); - + Log.e(TAG, "resized image size width:" + originBitmap.getWidth() + ",height: " + originBitmap.getHeight()); if (originBitmap != null) { - Glide.with(this).load(originBitmap).into(imgOrigin); + Glide.with(this).load(originBitmap).into(imgPreview); } } - - @Override - public void onListFragmentInteraction(String item) { - this.selectedStyle = item; - startRunningModel(); + private void showOriginCamera() { + try { + Pair targetedSize = this.getTargetSize(); + int targetWidth = targetedSize.first; + int maxHeight = targetedSize.second; + Bitmap bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(imageUri)); + originBitmap = BitmapUtils.zoomImage(bitmap, targetWidth, maxHeight); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + // Determine how much to scale down the image. + Log.e(TAG, "resized image size width:" + originBitmap.getWidth() + ",height: " + originBitmap.getHeight()); + if (originBitmap != null) { + Glide.with(this).load(originBitmap).into(imgPreview); + } } - private void startRunningModel() { - if (!isRunningModel && !TextUtils.isEmpty(selectedStyle)) { - styleBitmap = ImageUtils.loadBitmapFromResources(this, getUriFromAssetThumb(selectedStyle)); - if (originBitmap == null) { - Toast.makeText(this, "Please select an original picture first", Toast.LENGTH_SHORT).show(); - return; - } + private void showCustomBack(Uri imageUri) { + Pair targetedSize = this.getTargetSize(); + int targetWidth = targetedSize.first; + int maxHeight = targetedSize.second; + styleBitmap = BitmapUtils.loadFromPath(this, imageUri, targetWidth, maxHeight); + startRunningModel(styleBitmap); + } + + @Override + public void onBackImageSelected(int position) { + styleBitmap = BitmapFactory.decodeResource(getResources(), IMAGES[position]); + startRunningModel(styleBitmap); + } + + @Override + public void onImageAdd(View view) { + openGallay(RC_CHOOSE_PHOTO_FOR_BACKGROUND); + } + + private void startRunningModel(Bitmap styleBitmap) { + if (originBitmap == null) { + Toast.makeText(this, "Please select an original picture first", Toast.LENGTH_SHORT).show(); + return; + } + + if (!isRunningModel) { isRunningModel = true; + progressBar.setVisibility(View.VISIBLE); ModelExecutionResult result = transferModelExecutor.execute(originBitmap, styleBitmap); - Glide.with(this).load(result.getStyledImage()).into(imgOrigin); + 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(); + } isRunningModel = false; + progressBar.setVisibility(View.INVISIBLE); } else { Toast.makeText(this, "Previous Model still running", Toast.LENGTH_SHORT).show(); } } - private String getUriFromAssetThumb(String thumb) { - return "thumbnails/" + thumb; - } - // Returns max width of image. private Integer getMaxWidthOfImage() { if (this.maxWidthOfImage == null) { if (this.isLandScape) { - this.maxWidthOfImage = ((View) this.imgOrigin.getParent()).getHeight(); + this.maxWidthOfImage = ((View) this.imgPreview.getParent()).getHeight(); } else { - this.maxWidthOfImage = ((View) this.imgOrigin.getParent()).getWidth(); + this.maxWidthOfImage = ((View) this.imgPreview.getParent()).getWidth(); } } return this.maxWidthOfImage; @@ -180,9 +247,9 @@ public class StyleMainActivity extends AppCompatActivity implements View.OnClick private Integer getMaxHeightOfImage() { if (this.maxHeightOfImage == null) { if (this.isLandScape) { - this.maxHeightOfImage = ((View) this.imgOrigin.getParent()).getWidth(); + this.maxHeightOfImage = ((View) this.imgPreview.getParent()).getWidth(); } else { - this.maxHeightOfImage = ((View) this.imgOrigin.getParent()).getHeight(); + this.maxHeightOfImage = ((View) this.imgPreview.getParent()).getHeight(); } } return this.maxHeightOfImage; diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/java/com/mindspore/styletransfer/StyleRecyclerViewAdapter.java b/model_zoo/official/lite/Himindspore/styletransfer/src/main/java/com/mindspore/styletransfer/StyleRecyclerViewAdapter.java index 7f0300ebea3..c4b3a8b7b54 100644 --- a/model_zoo/official/lite/Himindspore/styletransfer/src/main/java/com/mindspore/styletransfer/StyleRecyclerViewAdapter.java +++ b/model_zoo/official/lite/Himindspore/styletransfer/src/main/java/com/mindspore/styletransfer/StyleRecyclerViewAdapter.java @@ -16,7 +16,6 @@ package com.mindspore.styletransfer; import android.content.Context; -import android.net.Uri; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -27,35 +26,16 @@ import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.Glide; -import java.util.List; - public class StyleRecyclerViewAdapter extends RecyclerView.Adapter { - private View.OnClickListener mOnClickListener; - private List stylesList; - private Context context; - private OnListFragmentInteractionListener mListener; + private final int[] IMAGES; + private final Context context; + private final OnBackgroundImageListener mListener; - public StyleRecyclerViewAdapter(Context context, List stylesList, OnListFragmentInteractionListener mListener) { - this.stylesList = stylesList; + public StyleRecyclerViewAdapter(Context context, int[] IMAGES, OnBackgroundImageListener mListener) { + this.IMAGES = IMAGES; this.context = context; this.mListener = mListener; - - this.mOnClickListener = new View.OnClickListener() { - @Override - public void onClick(View view) { - - } - }; - - this.mOnClickListener = (View.OnClickListener) (new View.OnClickListener() { - public final void onClick(View v) { - - if (v.getTag() != null && v.getTag() instanceof String) { - mListener.onListFragmentInteraction(String.valueOf(v.getTag())); - } - } - }); } @NonNull @@ -68,21 +48,27 @@ public class StyleRecyclerViewAdapter extends RecyclerView.Adapter { + if (mListener != null) { + if (IMAGES.length - 1 == position) { + mListener.onImageAdd(holder.getImageView()); + } else { + mListener.onBackImageSelected(position); + } + } + }); } @Override public int getItemCount() { - return stylesList == null ? 0 : stylesList.size(); + return IMAGES == null ? 0 : IMAGES.length; } diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/java/com/mindspore/styletransfer/StyleTransferModelExecutor.java b/model_zoo/official/lite/Himindspore/styletransfer/src/main/java/com/mindspore/styletransfer/StyleTransferModelExecutor.java index 4d58a2f5658..95cd9da2767 100644 --- a/model_zoo/official/lite/Himindspore/styletransfer/src/main/java/com/mindspore/styletransfer/StyleTransferModelExecutor.java +++ b/model_zoo/official/lite/Himindspore/styletransfer/src/main/java/com/mindspore/styletransfer/StyleTransferModelExecutor.java @@ -113,8 +113,6 @@ public class StyleTransferModelExecutor { /** - * float 数组转 byte数组. - * * @param floats the floats * @return the byte [ ] */ @@ -127,23 +125,15 @@ public class StyleTransferModelExecutor { } @SuppressLint("LongLogTag") -// public ModelExecutionResult execute(String contentImagePath, String styleImageName) { public ModelExecutionResult execute(Bitmap contentImage, Bitmap styleBitmap) { Log.i(TAG, "running models"); fullExecutionTime = SystemClock.uptimeMillis(); preProcessTime = SystemClock.uptimeMillis(); - -// Bitmap contentImage = ImageUtils.decodeBitmap(new File(contentImagePath)); ByteBuffer contentArray = ImageUtils.bitmapToByteBuffer(contentImage, CONTENT_IMAGE_SIZE, CONTENT_IMAGE_SIZE, 0, 255); - - -// Bitmap styleBitmap = -// ImageUtils.loadBitmapFromResources(context, "thumbnails/" + styleImageName); ByteBuffer input = ImageUtils.bitmapToByteBuffer(styleBitmap, STYLE_IMAGE_SIZE, STYLE_IMAGE_SIZE, 0, 255); - List Predict_inputs = Predict_session.getInputs(); if (Predict_inputs.size() != 1) { return null; @@ -154,7 +144,6 @@ public class StyleTransferModelExecutor { preProcessTime = SystemClock.uptimeMillis() - preProcessTime; stylePredictTime = SystemClock.uptimeMillis(); - if (!Predict_session.runGraph()) { Log.e("MS_LITE", "Run Predict_graph failed"); return null; @@ -186,8 +175,6 @@ public class StyleTransferModelExecutor { MSTensor Transform_inputs_inTensor1 = Transform_inputs.get(1); Transform_inputs_inTensor1.setData(contentArray); - - styleTransferTime = SystemClock.uptimeMillis(); if (!Transform_session.runGraph()) { @@ -197,7 +184,6 @@ public class StyleTransferModelExecutor { styleTransferTime = SystemClock.uptimeMillis() - styleTransferTime; Log.d(TAG, "Style apply Time to run: " + styleTransferTime); - postProcessTime = SystemClock.uptimeMillis(); // Get output tensor values. @@ -232,7 +218,6 @@ public class StyleTransferModelExecutor { outputImage[x] = arrayThree; } - Bitmap styledImage = ImageUtils.convertArrayToBitmap(outputImage, CONTENT_IMAGE_SIZE, CONTENT_IMAGE_SIZE); postProcessTime = SystemClock.uptimeMillis() - postProcessTime; diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/add.jpg b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/add.jpg new file mode 100644 index 00000000000..bdfe6d75181 Binary files /dev/null and b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/add.jpg differ diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style0.jpg b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style0.jpg similarity index 100% rename from model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style0.jpg rename to model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style0.jpg diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style1.jpg b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style1.jpg similarity index 100% rename from model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style1.jpg rename to model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style1.jpg diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style10.jpg b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style10.jpg similarity index 100% rename from model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style10.jpg rename to model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style10.jpg diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style11.jpg b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style11.jpg similarity index 100% rename from model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style11.jpg rename to model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style11.jpg diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style12.jpg b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style12.jpg similarity index 100% rename from model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style12.jpg rename to model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style12.jpg diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style13.jpg b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style13.jpg similarity index 100% rename from model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style13.jpg rename to model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style13.jpg diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style14.jpg b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style14.jpg similarity index 100% rename from model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style14.jpg rename to model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style14.jpg diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style15.jpg b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style15.jpg similarity index 100% rename from model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style15.jpg rename to model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style15.jpg diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style16.jpg b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style16.jpg similarity index 100% rename from model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style16.jpg rename to model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style16.jpg diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style17.jpg b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style17.jpg similarity index 100% rename from model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style17.jpg rename to model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style17.jpg diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style18.jpg b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style18.jpg similarity index 100% rename from model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style18.jpg rename to model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style18.jpg diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style19.jpg b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style19.jpg similarity index 100% rename from model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style19.jpg rename to model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style19.jpg diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style2.jpg b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style2.jpg similarity index 100% rename from model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style2.jpg rename to model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style2.jpg diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style20.jpg b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style20.jpg similarity index 100% rename from model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style20.jpg rename to model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style20.jpg diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style3.jpg b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style3.jpg similarity index 100% rename from model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style3.jpg rename to model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style3.jpg diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style4.jpg b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style4.jpg similarity index 100% rename from model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style4.jpg rename to model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style4.jpg diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style5.jpg b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style5.jpg similarity index 100% rename from model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style5.jpg rename to model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style5.jpg diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style6.jpg b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style6.jpg similarity index 100% rename from model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style6.jpg rename to model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style6.jpg diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style7.jpg b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style7.jpg similarity index 100% rename from model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style7.jpg rename to model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style7.jpg diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style8.jpg b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style8.jpg similarity index 100% rename from model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style8.jpg rename to model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style8.jpg diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style9.jpg b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style9.jpg similarity index 100% rename from model_zoo/official/lite/Himindspore/styletransfer/src/main/assets/thumbnails/style9.jpg rename to model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style9.jpg diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style_chose.png b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style_chose.png deleted file mode 100644 index 932fe3df2ec..00000000000 Binary files a/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable-xxhdpi/style_chose.png and /dev/null differ diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable/progressbar.xml b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable/progressbar.xml new file mode 100644 index 00000000000..d48a929d888 --- /dev/null +++ b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/drawable/progressbar.xml @@ -0,0 +1,20 @@ + + + + + + \ No newline at end of file diff --git a/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/layout/activity_main_style.xml b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/layout/activity_main_style.xml index 7d0d9895273..3f7dc5cb3df 100644 --- a/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/layout/activity_main_style.xml +++ b/model_zoo/official/lite/Himindspore/styletransfer/src/main/res/layout/activity_main_style.xml @@ -18,6 +18,7 @@ android:drawableStart="@drawable/logo2" android:drawablePadding="5dp" android:gravity="center_vertical" + android:maxLines="1" android:text="MindSpore StyleTransfer" android:textColor="#ffffff" android:textSize="20sp" /> @@ -25,42 +26,117 @@ + android:layout_height="300dp"> -