forked from microsoft/onnxruntime-inference-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
715 additions
and
126 deletions.
There are no files selected for viewing
Binary file added
BIN
+17 Bytes
mobile/examples/phi-3-vision/android/.gradle/8.0/checksums/checksums.lock
Binary file not shown.
Binary file added
BIN
+33.5 KB
mobile/examples/phi-3-vision/android/.gradle/8.0/checksums/md5-checksums.bin
Binary file not shown.
Binary file added
BIN
+160 KB
mobile/examples/phi-3-vision/android/.gradle/8.0/checksums/sha1-checksums.bin
Binary file not shown.
Binary file added
BIN
+17 Bytes
...mples/phi-3-vision/android/.gradle/8.0/dependencies-accessors/dependencies-accessors.lock
Binary file not shown.
Empty file.
Binary file added
BIN
+2.54 MB
mobile/examples/phi-3-vision/android/.gradle/8.0/executionHistory/executionHistory.bin
Binary file not shown.
Binary file added
BIN
+17 Bytes
mobile/examples/phi-3-vision/android/.gradle/8.0/executionHistory/executionHistory.lock
Binary file not shown.
Binary file added
BIN
+1 Byte
mobile/examples/phi-3-vision/android/.gradle/8.0/fileChanges/last-build.bin
Binary file not shown.
Binary file added
BIN
+135 KB
mobile/examples/phi-3-vision/android/.gradle/8.0/fileHashes/fileHashes.bin
Binary file not shown.
Binary file added
BIN
+17 Bytes
mobile/examples/phi-3-vision/android/.gradle/8.0/fileHashes/fileHashes.lock
Binary file not shown.
Binary file added
BIN
+20.4 KB
mobile/examples/phi-3-vision/android/.gradle/8.0/fileHashes/resourceHashesCache.bin
Binary file not shown.
Empty file.
Binary file added
BIN
+17 Bytes
mobile/examples/phi-3-vision/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
2 changes: 2 additions & 0 deletions
2
mobile/examples/phi-3-vision/android/.gradle/buildOutputCleanup/cache.properties
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#Fri Jul 19 11:10:34 PDT 2024 | ||
gradle.version=8.0 |
Binary file added
BIN
+274 KB
mobile/examples/phi-3-vision/android/.gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
2 changes: 2 additions & 0 deletions
2
mobile/examples/phi-3-vision/android/.gradle/config.properties
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#Fri Jul 19 11:10:23 PDT 2024 | ||
java.home=C\:\\Program Files\\Android\\Android Studio\\jbr |
Binary file not shown.
Empty file.
Binary file added
BIN
+7.63 MB
mobile/examples/phi-3-vision/android/app/libs/onnxruntime-genai-android-0.4.1-dev-old.aar
Binary file not shown.
Binary file added
BIN
+1.18 MB
mobile/examples/phi-3-vision/android/app/libs/onnxruntime-genai-android-0.4.1-dev.aar
Binary file not shown.
26 changes: 26 additions & 0 deletions
26
...id/app/src/androidTest/java/ai/onnxruntime/genai/vision/demo/ExampleInstrumentedTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package ai.onnxruntime.genai.vision.demo; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry; | ||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); | ||
assertEquals("ai.onnxruntime.genai.vision.demo", appContext.getPackageName()); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
...s/phi-3-vision/android/app/src/main/java/ai/onnxruntime/genai/vision/demo/GenAIImage.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package ai.onnxruntime.genai.vision.demo; | ||
|
||
import android.content.Context; | ||
import android.graphics.Bitmap; | ||
import android.graphics.BitmapFactory; | ||
import android.net.Uri; | ||
|
||
import java.io.FileNotFoundException; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
|
||
import ai.onnxruntime.genai.GenAIException; | ||
import ai.onnxruntime.genai.Images; | ||
|
||
public class GenAIImage { | ||
Images images = null; | ||
Bitmap bitmap = null; | ||
|
||
GenAIImage(Context context, Uri uri, final int maxWidth, final int maxHeight) throws IOException, GenAIException { | ||
Bitmap bmp = decodeUri(context, uri, maxWidth, maxHeight); | ||
String filename = context.getFilesDir() + "/multimodalinput.png"; | ||
FileOutputStream out = new FileOutputStream(filename); | ||
bmp.compress(Bitmap.CompressFormat.PNG, 100, out); // bmp is your Bitmap instance | ||
// PNG is a lossless format, the compression factor (100) is ignored | ||
images = new Images(filename); | ||
images = new Images(filename); | ||
bitmap = BitmapFactory.decodeFile(filename); | ||
} | ||
|
||
GenAIImage(Context context, Uri uri) throws IOException, GenAIException { | ||
this(context, uri, 100000, 100000); | ||
} | ||
|
||
public Images getImages() { | ||
return images; | ||
} | ||
|
||
public Bitmap getBitmap() { return bitmap; } | ||
|
||
private static Bitmap decodeUri(Context c, Uri uri, final int maxWidth, final int maxHeight) | ||
throws FileNotFoundException { | ||
BitmapFactory.Options o = new BitmapFactory.Options(); | ||
o.inJustDecodeBounds = true; | ||
BitmapFactory.decodeStream(c.getContentResolver().openInputStream(uri), null, o); | ||
|
||
int width_tmp = o.outWidth | ||
, height_tmp = o.outHeight; | ||
int scale = 1; | ||
|
||
while(width_tmp / 2 > maxWidth || height_tmp / 2 > maxHeight) { | ||
width_tmp /= 2; | ||
height_tmp /= 2; | ||
scale *= 2; | ||
} | ||
|
||
BitmapFactory.Options o2 = new BitmapFactory.Options(); | ||
o2.inSampleSize = scale; | ||
return BitmapFactory.decodeStream(c.getContentResolver().openInputStream(uri), null, o2); | ||
} | ||
} |
Oops, something went wrong.