Worked on Custom tensor flow model and had programmed it and had found that it would always be over 75% sure that there was always a steve even if the cone was out of frame and it would occasionally look and find that there was the team banner image from the website. but then i tested it with the pre programmed tensors and it could easily figure out which image was being shown. must train the computer better with different images as well that are even more distinctable. but i succesfully trained it something and implemented it, so partial success

This commit is contained in:
SpencerPiha
2022-10-09 17:08:44 -05:00
parent cf89b53e90
commit 100b06610c
8 changed files with 103 additions and 5 deletions

View File

@@ -17,9 +17,14 @@ apply from: '../build.dependencies.gradle'
android {
namespace = 'org.firstinspires.ftc.teamcode'
buildFeatures {
mlModelBinding true
}
}
dependencies {
implementation project(':FtcRobotController')
implementation 'org.tensorflow:tensorflow-lite-metadata:0.1.0'
implementation 'org.tensorflow:tensorflow-lite-gpu:2.3.0'
annotationProcessor files('lib/OpModeAnnotationProcessor.jar')
}

View File

@@ -0,0 +1,11 @@
package org.timecrafters.testing.engine;
import org.cyberarm.engine.V2.CyberarmEngine;
public class CameraTestEngine extends CyberarmEngine {
@Override
public void setup() {
}
}

View File

@@ -0,0 +1,59 @@
package org.timecrafters.testing.states;
import org.cyberarm.engine.V2.CyberarmEngine;
import org.firstinspires.ftc.robotcore.external.tfod.Recognition;
import org.firstinspires.ftc.robotcore.external.tfod.TFObjectDetector;
import java.util.ArrayList;
import java.util.List;
public class CameraTestCommon {
private static final String TENSORFLOW_MODEL_ASSET = "";
private static final String[] TENSORFLOW_MODEL_LABELS = {
"1 dalek",
"2 steve",
"3 banner"
};
public TFObjectDetector tensorflow;
private List<Recognition> tensorflowRecognitions = new ArrayList<>();
private final CyberarmEngine engine;
public CameraTestCommon(CyberarmEngine engine) {
this.engine = engine;
initTensorflow();
}
private void initTensorflow() {
int tfodMonitorViewId = engine.hardwareMap.appContext.getResources().getIdentifier(
"tfodMonitorViewId", "id", engine.hardwareMap.appContext.getPackageName());
TFObjectDetector.Parameters parameters = new TFObjectDetector.Parameters(tfodMonitorViewId);
parameters.minResultConfidence = 0.8f;
parameters.isModelTensorFlow2 = true;
parameters.inputSize = 320;
tensorflow.loadModelFromAsset(TENSORFLOW_MODEL_ASSET, TENSORFLOW_MODEL_LABELS);
}
public void activateTensorflow() {
tensorflow.activate();
}
public List<Recognition> tensorflowDetections() {
List<Recognition> updateRecognitions = tensorflow.getUpdatedRecognitions();
if (updateRecognitions != null) {
tensorflowRecognitions = updateRecognitions;
}
return tensorflowRecognitions;
}
public void deactivateTensorflow() {
tensorflow.deactivate();
}
}

View File

@@ -0,0 +1,13 @@
package org.timecrafters.testing.states;
import org.cyberarm.engine.V2.CyberarmState;
public class CameraTestState extends CyberarmState {
@Override
public void exec() {
}
}