BAB V PENUTUP
B. Saran
Model yang telah dikembangkan dalam penelitian ini perlu diintegrasikan ke perangkat embedded terlebih dahulu jika ingin digunakan untuk memantau kondisi kebersihan lingkungan pada seluruh area atau lingkungan universitas. Selain itu untuk meningkatkan performa sistem, diperlukan data atau sampel gambar lingkungan yang lebih banyak dan lebih variatif misalnya kondisi lingkungan dengan berbagai jenis sampah seperti sampah plastik, kertas dan lain-lain.
PUSTAKA ACUAN
Amrizal, V., & Aini, Q. (2013). Kecerdasan Buatan. Halaman Moeka Publishing.
Arafat. (2016). SISTEM PENGAMANAN PINTU RUMAH BERBASIS Internet Of Things ( IoT ) Dengan ESP8266. Jurnal Ilmiah Fakultas Teknik “Technologia,” 7(4), 262–268.
Dewanto, I. J. (2004). System Development Life Cycle Dengan Beberapa Pendekatan. Jurnal FASILKOM, 2(1).
Efendi, Y. (2018). Internet Of Things (IoT) Sistem Pengendalian Lampu Menggunakan Raspberry Pi Berbasis Mobile. Jurnal Ilmiah Ilmu Komputer, 4(19–26).
Faisal. (2017). APLIKASI SMART TRASH CAN DALAM MENGATASI PERSOALAN SAMPAH SECARA MOBILE BERBASIS ANDROID. Informatika Sains Dan Teknologi, 2(2), 1–
10.
Fei, T. P., Kasim, S., Hassan, R., Ismail, M. N., Salikon, M. Z. M., Ruslai, H., Jahidin, K., & Arshad, M. S. (2017). SWM: Smart waste management for green environment. 2017 6th ICT International Student Project Conference (ICT-ISPC), 1–5.
https://doi.org/10.1109/ICT-ISPC.2017.8075303
Galina, M., & Umar, U. D. (2016). Smart Trash Bin With Solar Cell.
Journal of Electrical and Electronics Engineering, 1(2), 46–51.
Howard, A. G., Zhu, M., Chen, B., Kalenichenko, D., Wang, W., Weyand, T., Andreetto, M., & Adam, H. (2017). MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications.
Peraturan Presiden Republik Indonesia Nomor 59 Tahun 2017 Tentang Pelaksanaan Pencapaian Tujuan Pembangunan Berkelanjutan, (2017).
Keerthana B, Raghavendran, S. M., Kalyani S, Suja P, & Kalaiselvi, V. K.
G. (2017). Internet of Bins: Trash Management in India. 2017 2nd International Conference on Computing and Communications
Technologies (ICCCT), 248–251.
https://doi.org/10.1109/ICCCT2.2017.7972277 Keras. (n.d.). https://keras.io/
Lecun, Y., Bengio, Y., & Hinton, G. (2015). Deep Learning. Macmillan Publishers Limited.
Riyanto, V., Rosyida, S., Ariyati, I., & Ridwansyah. (2019). Smart Trash Early Warning System Based on Internet of Things. 2019 7th International Conference on Cyber and IT Service Management
(CITSM), 7, 1–5.
https://doi.org/10.1109/CITSM47753.2019.8965365
Romero, M., Interian, Y., Solberg, T., & Valdes, G. (2020). Targeted transfer learning to improve performance in small medical physics datasets. Medical Physics, 47(12), 6246–6256.
https://doi.org/10.1002/mp.14507
Russell, S. J., & Norvig, P. (2016). Artificial Intelligence A Modern Approach: Third Edition.
Sandler, M., Howard, A., Zhu, M., Zhmoginov, A., & Chen, L.-C. (2019).
MobileNetV2: Inverted Residuals and Linear Bottlenecks.
TensorFlow Lite. (2021). https://www.tensorflow.org/lite/guide
Weiss, K., Khoshgoftaar, T. M., & Wang, D. (2016). A survey of transfer learning. Journal of Big Data, 3(1), 9.
https://doi.org/10.1186/s40537-016-0043-6
LAMPIRAN
Lampiran 1: Dataset Kategori: Lingkungan Bersih
Kondisi Lingkungan Kurang Bersih
Kondisi Lingkungan Kurang Kotor
Lampiran 2: Arsitektur Jaringan MobileNet
Lampiran 3: Kode Program Pengembangan Model (Menggunakan Google Colab)
# Load the Drive helper and mount from google.colab import drive
# This will prompt for authorization.
drive.mount('/content/drive/')
from keras.preprocessing.image import ImageDataGenerator from tensorflow.keras.optimizers import Adam
from keras.preprocessing.image import img_to_array from keras.preprocessing.image import load_img from sklearn.preprocessing import LabelBinarizer from sklearn.model_selection import train_test_split import matplotlib.pyplot as plt
import numpy as np import argparse
return list_files(basePath, validExts=(".jpg",
".jpeg", ".png", ".bmp", ".tif", ".tiff"), contains=contains)
def list_files(basePath, validExts=(".jpg", ".jpeg",
".png", ".bmp", ".tif", ".tiff"), contains=None):
# loop over the directory structure filename does not contain
# the supplied string, then ignore the file filename).replace(" ", "\\ ")
yield imagePath import cv2
import numpy as np from skimage import io
from skimage.transform import rotate, AffineTransform, warp
import matplotlib.pyplot as plt import random
from skimage import img_as_ubyte import os
from skimage.util import random_noise import os, re, glob, cv2, numpy as np
for i in dirs: #loop all directory
count = 0
for pic in glob.glob('/content/drive/My
Drive/UINAM/Penelitian/Deteksi_Sampah_2/Dataset2/Trainin g/'+i+'/*'):
im = cv2.imread(pic)
im = cv2.cvtColor(im,cv2.COLOR_BGR2RGB) im = cv2.resize(im,(224,224))
print("Jumlah "+str(i)+" : "+str(count)) label = label + 1
lb_arr.append(i) X = np.array(X)/255 y = np.array(y)
from sklearn.model_selection import train_test_split from tensorflow.keras.utils import to_categorical from sklearn.preprocessing import LabelBinarizer lb = LabelBinarizer()
y = lb.fit_transform(y)
X_train, X_test, y_train, y_test =
train_test_split(X,y,test_size=0.20, stratify=y, random_state = 24)
from keras.models import Sequential
from keras.layers import Conv2D, AveragePooling2D, Dropout, Flatten, Dense, Input
from keras.models import Model
from keras.preprocessing.image import ImageDataGenerator from keras.applications.mobilenet_v2 import MobileNetV2
baseModel = MobileNetV2(weights="imagenet",
include_top=False, input_tensor=Input(shape=(224, 224, 3)))
model = baseModel.output
model = AveragePooling2D(pool_size = (4,4))(model) model = Flatten(name = 'flatten')(model)
model = Dense(128, activation = 'relu')(model) model = Dropout(0.5)(model)
model = Dense(64, activation = 'relu')(model) model = Dropout(0.2)(model)
model = Dense(3, activation = 'softmax')(model) model = Model(inputs=baseModel.input, outputs=model)
for layer in baseModel.layers:
layer.trainable = False
from keras.preprocessing.image import ImageDataGenerator
trainAug = ImageDataGenerator(
rotation_range=15, fill_mode="nearest")
from tensorflow.keras.optimizers import Adam from tensorflow.keras.optimizers import SGD from keras.callbacks import ModelCheckpoint
init_lr = 0.0001 epoch = 35
BS = 8
opt = Adam(lr=init_lr, decay=init_lr / epoch) model.compile(loss="categorical_crossentropy",
history = model.fit_generator(
trainAug.flow(X_train, y_train, batch_size=BS), steps_per_epoch=len(X_train) // BS,
validation_data=(X_test, y_test), callbacks=[save_model],
epochs=epoch)
from sklearn.metrics import classification_report from keras.models import load_model
best_model = load_model('/content/drive/My
Drive/UINAM/Penelitian/Deteksi_Sampah_2/MobileNett_25.hd f5')
predIdxs = best_model.predict(X_test, batch_size=BS) predIdxs = np.argmax(predIdxs, axis=1)
print(classification_report(y_test.argmax(axis=1), predIdxs))
import matplotlib.pyplot as plt N = epoch plt.title("Training Loss and Accuracy")
plt.xlabel("Epoch #")
plt.ylabel("Loss/Accuracy") plt.legend(loc="lower left")
import tensorflow as tf
model2 = tf.keras.models.load_model('/content/drive/My Drive/UINAM/Penelitian/Deteksi_Sampah_2/MobileNett_25.hd f5')
converter =
tf.lite.TFLiteConverter.from_keras_model(model2)
tflmodel = converter.convert()
file = open( 'MobileNet.tflite' , 'wb' ) file.write( tflmodel )
Lampiran 4: Kode Program (Android)
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
====================================================
==========================*/
package org.tensorflow.lite.examples.classification.tflite;
import android.app.Activity;
import java.io.IOException;
/** This TensorFlowLite classifier works with the float MobileNet model.
*/
public class ClassifierFloatMobileNet extends Classifier {
/** MobileNet requires additional normalization of the used input. */
private static final float IMAGE_MEAN = 127.5f;
private static final float IMAGE_STD = 127.5f;
/**
* An array to hold inference results, to be feed into Tensorflow Lite as outputs. This isn't part
* of the super class, because we need a primitive array here.
*/
private float[][] labelProbArray = null;
/**
* Initializes a {@code ClassifierFloatMobileNet}.
*
* @param activity */
public ClassifierFloatMobileNet(Activity activity, Device device, int numThreads)
throws IOException {
super(activity, device, numThreads);
labelProbArray = new float[1][getNumLabels()];
}
@Override
public int getImageSizeX() { return 224;
}
@Override
public int getImageSizeY() { return 224;
}
@Override
protected String getModelPath() { // you can download this file from
// see build.gradle for where to obtain this file. It should be auto // downloaded into assets.
return "model.tflite";
}
@Override
protected String getLabelPath() { return "labels.txt";
}
@Override
protected int getNumBytesPerChannel() { return 4; // Float.SIZE / Byte.SIZE;
}
@Override
protected void addPixelValue(int pixelValue) {
imgData.putFloat((((pixelValue >> 16) & 0xFF) - IMAGE_MEAN) / IMAGE_STD);
imgData.putFloat((((pixelValue >> 8) & 0xFF) - IMAGE_MEAN) / IMAGE_STD);
imgData.putFloat(((pixelValue & 0xFF) - IMAGE_MEAN) / IMAGE_STD);
}
@Override
protected float getProbability(int labelIndex) { return labelProbArray[0][labelIndex];
}
@Override
protected void setProbability(int labelIndex, Number value) { labelProbArray[0][labelIndex] = value.floatValue();
}
@Override
protected float getNormalizedProbability(int labelIndex) { return labelProbArray[0][labelIndex];
}
@Override
protected void runInference() { tflite.run(imgData, labelProbArray);
} }