-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
b80997c
commit 76a0d00
Showing
18 changed files
with
150 additions
and
145 deletions.
There are no files selected for viewing
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
74 changes: 0 additions & 74 deletions
74
app/src/main/java/com/example/minhduc0711/indoorlocalization/PredictiveModel.java
This file was deleted.
Oops, something went wrong.
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
5 changes: 5 additions & 0 deletions
5
app/src/main/java/com/example/minhduc0711/indoorlocalization/models/PredictiveModel.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,5 @@ | ||
package com.example.minhduc0711.indoorlocalization.models; | ||
|
||
public interface PredictiveModel { | ||
float[] predict(float[] input); | ||
} |
49 changes: 49 additions & 0 deletions
49
app/src/main/java/com/example/minhduc0711/indoorlocalization/models/ScikitModel.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,49 @@ | ||
package com.example.minhduc0711.indoorlocalization.models; | ||
|
||
import android.content.Context; | ||
|
||
import org.dmg.pmml.FieldName; | ||
import org.jpmml.android.EvaluatorUtil; | ||
import org.jpmml.evaluator.FieldValue; | ||
import org.jpmml.evaluator.InputField; | ||
import org.jpmml.evaluator.ModelEvaluator; | ||
|
||
import java.io.InputStream; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class ScikitModel implements PredictiveModel { | ||
private ModelEvaluator<?> mEvaluatorX; | ||
private ModelEvaluator<?> mEvaluatorY; | ||
|
||
public ScikitModel(String fileNameX, String fileNameY, Context context) { | ||
try { | ||
InputStream is = context.getAssets().open(fileNameX); | ||
mEvaluatorX = (ModelEvaluator<?>) EvaluatorUtil.createEvaluator(is); | ||
is = context.getAssets().open(fileNameY); | ||
mEvaluatorY = (ModelEvaluator<?>) EvaluatorUtil.createEvaluator(is); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
@Override | ||
public float[] predict(float[] input) { | ||
float[] output = new float[2]; | ||
|
||
int i = 0; | ||
Map<FieldName, FieldValue> inputMap = new HashMap<>(); | ||
for (InputField inputField : mEvaluatorX.getInputFields()) { | ||
FieldName fieldName = inputField.getName(); | ||
Object rawValue = input[i++]; | ||
FieldValue fieldValue = inputField.prepare(rawValue); | ||
inputMap.put(fieldName, fieldValue); | ||
} | ||
Map<String, ?> resultsX = org.jpmml.evaluator.EvaluatorUtil.decode(mEvaluatorX.evaluate(inputMap)); | ||
Map<String, ?> resultsY = org.jpmml.evaluator.EvaluatorUtil.decode(mEvaluatorY.evaluate(inputMap)); | ||
output[0] = ((Double) resultsX.get("y")).floatValue(); | ||
output[1] = ((Double) resultsY.get("y")).floatValue(); | ||
|
||
return output; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
app/src/main/java/com/example/minhduc0711/indoorlocalization/models/TensorflowModel.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,25 @@ | ||
package com.example.minhduc0711.indoorlocalization.models; | ||
|
||
import android.content.Context; | ||
|
||
import org.tensorflow.contrib.android.TensorFlowInferenceInterface; | ||
|
||
public class TensorflowModel implements PredictiveModel { | ||
private TensorFlowInferenceInterface mInferenceInterface; | ||
|
||
public TensorflowModel(String fileName, Context context) { | ||
mInferenceInterface = new TensorFlowInferenceInterface(context.getAssets(), fileName); | ||
} | ||
|
||
@Override | ||
public float[] predict(float[] input) { | ||
float[] output = new float[2]; | ||
|
||
String[] outputNames = {"output_node0"}; | ||
mInferenceInterface.feed("dense_55_input", input, 1, input.length); | ||
mInferenceInterface.run(outputNames); | ||
mInferenceInterface.fetch(outputNames[0], output); | ||
|
||
return output; | ||
} | ||
} |
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
Oops, something went wrong.