-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
105 changed files
with
12,835 additions
and
8 deletions.
There are no files selected for viewing
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
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
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
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 @@ | ||
/build |
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,47 @@ | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'kotlin-android' | ||
apply plugin: 'kotlin-android-extensions' | ||
|
||
android { | ||
compileSdkVersion rootProject.compileSdkVersion | ||
|
||
defaultConfig { | ||
minSdkVersion rootProject.minSdkVersion | ||
targetSdkVersion rootProject.targetSdkVersion | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles "consumer-rules.pro" | ||
|
||
ndk { | ||
abiFilters 'arm64-v8a', 'armeabi-v7a' | ||
} | ||
|
||
externalNativeBuild { | ||
cmake { | ||
arguments "-DANDROID_ARM_NEON=TRUE", "-DANDROID_PLATFORM=android-24", "-DANDROID_STL=c++_shared" | ||
} | ||
} | ||
} | ||
|
||
externalNativeBuild { | ||
cmake { | ||
version "3.10.2" | ||
path "src/main/cpp/CMakeLists.txt" | ||
} | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
|
||
implementation project(path: ':common') | ||
} |
Empty file.
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,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
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,5 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="ru.gordinmitya.onnxruntime"> | ||
|
||
/ | ||
</manifest> |
File renamed without changes.
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,29 @@ | ||
cmake_minimum_required(VERSION 3.4.1) | ||
|
||
set(lib_DIR "${CMAKE_SOURCE_DIR}/../jniLibs") | ||
include_directories(${CMAKE_SOURCE_DIR}/includes) | ||
include_directories(${CMAKE_SOURCE_DIR}/includes/onnxruntime/core/session) | ||
|
||
add_library( | ||
onnxcore | ||
SHARED | ||
onnxjni.cpp onnxruntime_inference.cpp | ||
) | ||
|
||
add_library(libonnxruntime STATIC IMPORTED) | ||
set_target_properties( | ||
libonnxruntime | ||
PROPERTIES IMPORTED_LOCATION | ||
${lib_DIR}/${ANDROID_ABI}/libonnxruntime.so | ||
) | ||
|
||
find_library(log-lib log) | ||
find_library(jnigraphics-lib jnigraphics) | ||
|
||
target_link_libraries( | ||
onnxcore | ||
libonnxruntime | ||
|
||
${log-lib} | ||
${jnigraphics-lib} | ||
) |
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,105 @@ | ||
// | ||
// Created by rohith on 7/24/18. | ||
// | ||
|
||
#ifndef TFLITENATIVE_IMAGERESIZER_H | ||
#define TFLITENATIVE_IMAGERESIZER_H | ||
|
||
#include "logs.h" | ||
|
||
#include <cstdint> | ||
|
||
|
||
/** | ||
*center crop and resize the image | ||
* | ||
*/ | ||
void cropResizeImage(unsigned char *inputpixel, int w_image, int h_image ,int ch_image, uint8_t* output, int w_network, int h_network) | ||
{ | ||
LOGV("in width %d, in height %d",w_image, h_image); | ||
|
||
if(h_image >= w_image)//portrait mode | ||
{ | ||
LOGE("portrait"); | ||
const int skipheight = (h_image - w_image) / 2; | ||
LOGE("skipheight %d", skipheight); | ||
|
||
int croped_width = w_image; | ||
int croped_height = w_image; | ||
|
||
unsigned char* start_address = inputpixel + (skipheight*croped_width)*ch_image; | ||
uint8_t* rgb_in = output; | ||
|
||
for(int y =0;y<h_network; y++) | ||
{ | ||
|
||
const int in_y = y * (croped_height) / h_network; // 0 = 0x1356/224, 6 = 1x1356/224 ,12 = 2x1356/224, 18 = 3x1356/224.....1349 = 113x1356/224 [total height = 2392 ] | ||
|
||
|
||
unsigned char* in_row = start_address + in_y * w_image*ch_image; | ||
uint8_t* out_row = rgb_in+ (y*w_network*3); //ou_input + (0*224*3), (1*224*3) ,(2*224*3), (3*224*3) ....(223*224*3) | ||
|
||
for(int x=0;x<w_network;x++) | ||
{ | ||
|
||
const int in_x = (x * croped_width) / w_network; // 0 = 0x1356/224, 6 = 1x1356/224 ,12 = 2x1356/224, 18 = 3x1356/224.....1349 = 113x1356/224 [total width = 1356 ] | ||
|
||
|
||
unsigned char* inpixel = in_row +in_x*ch_image; | ||
|
||
uint8_t* out_pixel = out_row +(x*3);//out_row +(0x3), (1x3) ,(2x3), (3x3), (4x3)...(223x3) | ||
|
||
out_pixel[0] = inpixel[0]; | ||
out_pixel[1] = inpixel[1]; | ||
out_pixel[2] = inpixel[2]; | ||
|
||
} | ||
} | ||
|
||
} | ||
else | ||
{ | ||
LOGE("Landscape"); | ||
|
||
const int skipwidth = (w_image - h_image) / 2; | ||
LOGE("skipheight %d", skipwidth); | ||
|
||
int croped_width = h_image; | ||
int croped_height = h_image; | ||
|
||
|
||
unsigned char* start_address = inputpixel; | ||
|
||
uint8_t* rgb_in = output; | ||
for(int y =0;y<h_network; y++) | ||
{ | ||
|
||
const int in_y = y * (h_image) / h_network; | ||
|
||
unsigned char* in_row = start_address + in_y*w_image*ch_image; | ||
uint8_t* out_row = rgb_in+ (y*w_network*3); //ou_input + (0*224*3), (1*224*3) ,(2*224*3), (3*224*3) ....(223*224*3) | ||
|
||
for(int x=0;x<w_network;x++) | ||
{ | ||
|
||
|
||
const int in_x = (x * h_image) / w_network; | ||
|
||
unsigned char* inpixel = in_row +in_x*ch_image+skipwidth*ch_image; | ||
|
||
uint8_t* out_pixel = out_row +(x*3);//out_row +(0x3), (1x3) ,(2x3), (3x3), (4x3)...(223x3) | ||
|
||
|
||
out_pixel[0] = inpixel[0]; | ||
out_pixel[1] = inpixel[1]; | ||
out_pixel[2] = inpixel[2]; | ||
|
||
} | ||
} | ||
|
||
|
||
|
||
} | ||
} | ||
|
||
#endif //TFLITENATIVE_IMAGERESIZER_H |
57 changes: 57 additions & 0 deletions
57
onnxruntime/src/main/cpp/includes/onnxruntime/core/common/code_location.h
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,57 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#pragma once | ||
|
||
#include <sstream> | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace onnxruntime { | ||
/** | ||
CodeLocation captures information on where in the source code a message came from. | ||
*/ | ||
struct CodeLocation { | ||
/** | ||
@param file_path Usually the value of __FILE__ | ||
@param line Usually the value of __LINE__ | ||
@param func Usually the value of __PRETTY_FUNCTION__ or __FUNCTION__ | ||
*/ | ||
CodeLocation(const char* file_path, const int line, const char* func) | ||
: file_and_path{file_path}, line_num{line}, function{func} { | ||
} | ||
|
||
/** | ||
@param file_path Usually the value of __FILE__ | ||
@param line Usually the value of __LINE__ | ||
@param func Usually the value of __PRETTY_FUNCTION__ or __FUNCTION__ | ||
@param stacktrace Stacktrace from source of message. | ||
*/ | ||
CodeLocation(const char* file_path, const int line, const char* func, const std::vector<std::string>& stacktrace) | ||
: file_and_path{file_path}, line_num{line}, function{func}, stacktrace(stacktrace) { | ||
} | ||
|
||
std::string FileNoPath() const { | ||
// assuming we always have work to do, so not trying to avoid creating a new string if | ||
// no path was removed. | ||
return file_and_path.substr(file_and_path.find_last_of("/\\") + 1); | ||
} | ||
|
||
enum Format { | ||
kFilename, | ||
kFilenameAndPath | ||
}; | ||
|
||
std::string ToString(Format format = Format::kFilename) const { | ||
std::ostringstream out; | ||
out << (format == Format::kFilename ? FileNoPath() : file_and_path) << ":" << line_num << " " << function; | ||
return out.str(); | ||
} | ||
|
||
const std::string file_and_path; | ||
const int line_num; | ||
const std::string function; | ||
const std::vector<std::string> stacktrace; | ||
}; | ||
|
||
} // namespace onnxruntime |
Oops, something went wrong.