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
import firebase from "firebase"; | |
const config = { | |
apiKey: "Minha Chave Tira o Zóio", | |
authDomain: "iplantacao-72b97.firebaseapp.com", | |
databaseURL: "https://iplantacao-72b97.firebaseio.com", | |
projectId: "iplantacao-72b97", | |
storageBucket: "iplantacao-72b97.appspot.com", | |
messagingSenderId: "Tira o Zoio" | |
}; |
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
private void savePrediction(Prediction prediction) { | |
Log.d(TAG,"savePrediction"); | |
FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance(); | |
DatabaseReference databaseReference = firebaseDatabase.getReference(); | |
databaseReference.child("prediction").child(prediction.getId()).setValue(prediction); | |
} | |
private void uploadImage(String absolutePath, final Prediction prediction) { | |
Uri file = Uri.fromFile(new File(absolutePath)); |
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
public void runModel(String absolutePath) { | |
if (mInterpreter == null) { | |
Log.e(TAG, "Image classifier has not been initialized; Skipped."); | |
return; | |
} | |
float[][][][] imgData = cropImage(absolutePath); | |
try { | |
FirebaseModelInputs inputs = new FirebaseModelInputs.Builder().add(imgData).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
private float[][][][] cropImage(String absolutePath) { | |
Mat imageRaw = Imgcodecs.imread(absolutePath); | |
float[][][][] imgData = new float [DIM_BATCH_SIZE] [DIM_IMG_SIZE_X] [DIM_IMG_SIZE_Y] [DIM_PIXEL_SIZE]; | |
int square_qtd_x = 20; | |
int square_qtd_y = 20; |
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
from __future__ import print_function | |
import keras | |
#from keras.datasets import mnist | |
from keras.models import Sequential | |
from keras.layers import Dense, Dropout, Flatten | |
from keras.layers import Conv2D, MaxPooling2D | |
from keras import backend as K | |
import numpy as np | |
import ml_bullgreen_dataset_handler | |
from sklearn import cross_validation |
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
model = Sequential() | |
model.add(Conv2D(32, kernel_size=(3, 3), | |
activation='relu', | |
input_shape=input_shape)) | |
model.add(Conv2D(64, (3, 3), activation='relu')) | |
model.add(MaxPooling2D(pool_size=(2, 2))) | |
model.add(Dropout(0.40)) #0.4 removed as it is bad of tflite # 0.25 | |
model.add(Flatten()) | |
model.add(Dense(128, activation='relu')) | |
model.add(Dropout(0.25)) #0.25 removed as it is bad of tflite # 0.5 |
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
def __create_feature_vector_raw(self, file_name, piquete_id, score, flatten=False): | |
sample_size = (self.CROP_WIDTH, self.CROP_HEIGHT, 3) | |
image_path = self.__image_files_root_folder+ str(piquete_id)+'/'+file_name | |
print(image_path) | |
image_raw = cv2.imread(image_path) | |
if image_raw is not None: | |
if not self.__check_for_bad_images(file_name, piquete_id, score): |
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
def runCrossValidation(self, farm_dataset): | |
print('start cross validation') | |
x_train, x_test, y_train, y_test = cross_validation.train_test_split( | |
farm_dataset.feature_vector,farm_dataset.target, test_size=0.15) | |
#x_train_scaled = preprocessing.scale(x_train) | |
#y_train_scaled = preprocessing.scale(y_train) | |
#x_test_scaled = preprocessing.scale(x_test) | |
#y_test_scaled = preprocessing.scale(y_test) | |
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
def __create_feature_vector_mean(self, file_name, piquete_id, score, height): | |
rgb_mean = [0] * 3 | |
image_path = self.__image_files_root_folder+ str(piquete_id)+'/'+file_name | |
image = cv2.imread(image_path) | |
print(image_path) | |
means = cv2.mean(image) | |
if means is not None: | |
#raw = image.flatten() | |
print(str(means[:3])+'\n') |
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
p{font-size: 14px} | |
article ~ p {font-size: 14px} | |
article ~ p {color:#00F;} | |
p+p {text-indent:20px;} /*pega o proximo igual*/ | |
li:first-child {font-size: 20px;} /*pega o primeiro filho*/ |