Created
June 9, 2019 13:35
-
-
Save frogermcs/698e792a82ee4e5b9db956e758ff62d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(AndroidJUnit4.class) | |
@LargeTest | |
public class MLModelTest { | |
/* ... */ | |
@Test | |
public void testClassificationBatch() throws IOException { | |
ModelTestActivity activity = mainActivityActivityRule.getActivity(); | |
ModelClassificator modelClassificator = new ModelClassificator(activity, new FlowersConfig()); | |
Map<Integer, Integer> batchClassificationResults = new HashMap<>(); | |
Map<Integer, Integer> batchClassificationExepectedResults = new HashMap<>(); | |
String[] valBatchImages = activity.getAssets().list("val_batch"); | |
for (String valImagePath : valBatchImages) { | |
ValImageInfo valImageInfo = new ValImageInfo(valImagePath); | |
Bitmap bmp = TestUtils.getBitmapFromAsset(activity.getAssets(), "val_batch/" + valImagePath); | |
//Does nothing, it's just test's preview | |
activity.setImagePreview(bmp); | |
List<ClassificationResult> classificationResults = modelClassificator.process(bmp); | |
ClassificationResult topClassificationResult = classificationResults.get(0); | |
batchClassificationResults.put(valImageInfo.n, topClassificationResult.labelIndex); | |
batchClassificationExepectedResults.put(valImageInfo.n, valImageInfo.tflitePredict); | |
//Does nothing, it's just test's preview | |
activity.showClassificationResults(classificationResults); | |
} | |
Truth.assertThat(batchClassificationResults).isNotEmpty(); | |
Truth.assertThat(batchClassificationResults).containsExactlyEntriesIn(batchClassificationExepectedResults); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment