Skip to content

Commit

Permalink
change colors, add back x86_64 .so
Browse files Browse the repository at this point in the history
  • Loading branch information
fionabos committed Aug 3, 2024
1 parent bd1a91c commit 4370918
Show file tree
Hide file tree
Showing 41 changed files with 715 additions and 126 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
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 not shown.
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 not shown.
Binary file not shown.
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());
}
}
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);
}
}
Loading

0 comments on commit 4370918

Please sign in to comment.