Skip to content

Commit

Permalink
update file
Browse files Browse the repository at this point in the history
  • Loading branch information
fendy07 committed Jul 25, 2024
1 parent 538c494 commit 8997228
Show file tree
Hide file tree
Showing 28 changed files with 2,114 additions and 279 deletions.
321 changes: 214 additions & 107 deletions Cirebon_Mask_clf.ipynb

Large diffs are not rendered by default.

1,183 changes: 1,183 additions & 0 deletions KNN_Cirebon.ipynb

Large diffs are not rendered by default.

344 changes: 252 additions & 92 deletions MLP_Cirebon.ipynb

Large diffs are not rendered by default.

475 changes: 399 additions & 76 deletions SVM_Cirebon.ipynb

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import os
import cv2
import numpy as np
from PIL import Image
import streamlit as st
import tensorflow as tf
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing.image import img_to_array

# Load model
model = load_model('model/model-mask.h5', include_optimizer=True)
model.compile(loss = 'categorical_crossentropy', optimizer = tf.keras.optimizers.AdamW(learning_rate=0.001, weight_decay=0.004), metrics = ['accuracy'])

# Class names sesuai dengan dataset Anda
class_names = ['Klana', 'Pamindo', 'Panji', 'Rumyang', 'Tumenggung']

# Setup Streamlit
st.title('Image Classification - Topeng Cirebon')
st.write("Upload gambar topeng untuk diklasifikasikan:")

uploaded_file = st.file_uploader("Pilih file gambar...", type=["jpg", "jpeg", "png"])

if uploaded_file is not None:
# Convert the uploaded image to a PIL image
image = Image.open(uploaded_file)

# Resize the image to the model input size
image = image.resize((100, 100))

# Convert the image to a numpy array
image_array = img_to_array(image)

# Add a batch dimension to the image
image_array = np.expand_dims(image_array, axis=0)

# Make predictions using the model
predictions = model.predict(image_array)

# Get the predicted class indices
predicted_class_indices = np.argmax(predictions, axis=1)

# Get the predicted class names
predicted_class_names = []
for i in predicted_class_indices:
if 0 <= i < len(class_names):
predicted_class_names.append(class_names[i])
else:
predicted_class_names.append("Unknown")

# Display the predicted class names
st.write("Predicted class:", predicted_class_names[0])

# Display the uploaded image
st.image(image, caption="Uploaded image")
2 changes: 1 addition & 1 deletion data/hasil_model.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Model,Data Train,Data Test,Epochs,Batch Size,Loss,Accuracy
<keras.src.engine.sequential.Sequential object at 0x000001F0A93A76D0>,"(800, 28, 1)","(200, 28, 1)",30,32,0.01797403395175934,0.9950000047683716
<keras.src.engine.sequential.Sequential object at 0x0000025D7305EE90>,"(800, 28, 1)","(200, 28, 1)",30,32,0.015860186889767647,0.9950000047683716
2 changes: 1 addition & 1 deletion data/hasil_model_NN.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Model,Data Train,Data Test,Epochs,Batch Size,Loss,Accuracy
<keras.src.engine.sequential.Sequential object at 0x0000022028123FD0>,"(800, 28, 1)","(200, 28, 1)",20,64,0.06803662329912186,0.9850000143051147
<keras.src.engine.sequential.Sequential object at 0x000002EF9A331550>,"(800, 28, 1)","(200, 28, 1)",20,64,0.06901808828115463,0.9850000143051147
2 changes: 1 addition & 1 deletion model/base_model.json/fingerprint.pb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
����ъ�m��у�Ж�#��������� �������W(�����ӊ�2
��������T��у�Ж�#��������� �������W(����ր��R2
Binary file modified model/base_model.json/saved_model.pb
Binary file not shown.
Binary file modified model/base_model.json/variables/variables.data-00000-of-00001
Binary file not shown.
Binary file modified model/base_model.json/variables/variables.index
Binary file not shown.
Binary file added model/knn-mask.pkl
Binary file not shown.
Binary file added model/knn-tuning.pkl
Binary file not shown.
Empty file added model/mlp_mask.pkl
Empty file.
Binary file added model/model-cnn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added model/model-mask.h5
Binary file not shown.
Binary file modified model/model_nn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions model/nn_model.json/fingerprint.pb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
�؋�������پ�ȁ�٧��������] ����֛�&(���ۗ���&2
7 changes: 7 additions & 0 deletions model/nn_model.json/keras_metadata.pb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

�#root"_tf_keras_sequential*�#{"name": "sequential_2", "trainable": true, "expects_training_arg": true, "dtype": "float32", "batch_input_shape": null, "must_restore_from_config": false, "preserve_input_structure_in_config": false, "autocast": false, "class_name": "Sequential", "config": {"name": "sequential_2", "layers": [{"class_name": "InputLayer", "config": {"batch_input_shape": {"class_name": "__tuple__", "items": [null, 28]}, "dtype": "float32", "sparse": false, "ragged": false, "name": "dense_6_input"}}, {"class_name": "Dense", "config": {"name": "dense_6", "trainable": true, "dtype": "float32", "batch_input_shape": {"class_name": "__tuple__", "items": [null, 28]}, "units": 64, "activation": "relu", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "Dropout", "config": {"name": "dropout_4", "trainable": true, "dtype": "float32", "rate": 0.4, "noise_shape": null, "seed": null}}, {"class_name": "Dense", "config": {"name": "dense_7", "trainable": true, "dtype": "float32", "units": 5, "activation": "softmax", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}]}, "shared_object_id": 8, "input_spec": [{"class_name": "InputSpec", "config": {"dtype": null, "shape": {"class_name": "__tuple__", "items": [null, 28]}, "ndim": 2, "max_ndim": null, "min_ndim": null, "axes": {}}}], "build_input_shape": {"class_name": "TensorShape", "items": [null, 28]}, "is_graph_network": true, "full_save_spec": {"class_name": "__tuple__", "items": [[{"class_name": "TypeSpec", "type_spec": "tf.TensorSpec", "serialized": [{"class_name": "TensorShape", "items": [null, 28]}, "float32", "dense_6_input"]}], {}]}, "save_spec": {"class_name": "TypeSpec", "type_spec": "tf.TensorSpec", "serialized": [{"class_name": "TensorShape", "items": [null, 28]}, "float32", "dense_6_input"]}, "keras_version": "2.15.0", "backend": "tensorflow", "model_config": {"class_name": "Sequential", "config": {"name": "sequential_2", "layers": [{"class_name": "InputLayer", "config": {"batch_input_shape": {"class_name": "__tuple__", "items": [null, 28]}, "dtype": "float32", "sparse": false, "ragged": false, "name": "dense_6_input"}, "shared_object_id": 0}, {"class_name": "Dense", "config": {"name": "dense_6", "trainable": true, "dtype": "float32", "batch_input_shape": {"class_name": "__tuple__", "items": [null, 28]}, "units": 64, "activation": "relu", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 1}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 2}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 3}, {"class_name": "Dropout", "config": {"name": "dropout_4", "trainable": true, "dtype": "float32", "rate": 0.4, "noise_shape": null, "seed": null}, "shared_object_id": 4}, {"class_name": "Dense", "config": {"name": "dense_7", "trainable": true, "dtype": "float32", "units": 5, "activation": "softmax", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 5}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 6}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 7}]}}, "training_config": {"loss": "categorical_crossentropy", "metrics": [[{"class_name": "MeanMetricWrapper", "config": {"name": "accuracy", "dtype": "float32", "fn": "categorical_accuracy"}, "shared_object_id": 10}]], "weighted_metrics": null, "loss_weights": null, "optimizer_config": {"class_name": "Custom>Adam", "config": {"name": "Adam", "weight_decay": null, "clipnorm": null, "global_clipnorm": null, "clipvalue": null, "use_ema": false, "ema_momentum": 0.99, "ema_overwrite_frequency": null, "jit_compile": false, "is_legacy_optimizer": false, "learning_rate": 0.0010000000474974513, "beta_1": 0.9, "beta_2": 0.999, "epsilon": 1e-07, "amsgrad": false}}}}2
�root.layer_with_weights-0"_tf_keras_layer*�{"name": "dense_6", "trainable": true, "expects_training_arg": false, "dtype": "float32", "batch_input_shape": {"class_name": "__tuple__", "items": [null, 28]}, "stateful": false, "must_restore_from_config": false, "preserve_input_structure_in_config": false, "autocast": true, "class_name": "Dense", "config": {"name": "dense_6", "trainable": true, "dtype": "float32", "batch_input_shape": {"class_name": "__tuple__", "items": [null, 28]}, "units": 64, "activation": "relu", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 1}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 2}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 3, "input_spec": {"class_name": "InputSpec", "config": {"dtype": null, "shape": null, "ndim": null, "max_ndim": null, "min_ndim": 2, "axes": {"-1": 28}}, "shared_object_id": 11}, "build_input_shape": {"class_name": "TensorShape", "items": [null, 28]}}2
� root.layer-1"_tf_keras_layer*�{"name": "dropout_4", "trainable": true, "expects_training_arg": true, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "preserve_input_structure_in_config": false, "autocast": true, "class_name": "Dropout", "config": {"name": "dropout_4", "trainable": true, "dtype": "float32", "rate": 0.4, "noise_shape": null, "seed": null}, "shared_object_id": 4, "build_input_shape": {"class_name": "TensorShape", "items": [null, 64]}}2
�root.layer_with_weights-1"_tf_keras_layer*�{"name": "dense_7", "trainable": true, "expects_training_arg": false, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "preserve_input_structure_in_config": false, "autocast": true, "class_name": "Dense", "config": {"name": "dense_7", "trainable": true, "dtype": "float32", "units": 5, "activation": "softmax", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 5}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 6}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 7, "input_spec": {"class_name": "InputSpec", "config": {"dtype": null, "shape": null, "ndim": null, "max_ndim": null, "min_ndim": 2, "axes": {"-1": 64}}, "shared_object_id": 12}, "build_input_shape": {"class_name": "TensorShape", "items": [null, 64]}}2
�Lroot.keras_api.metrics.0"_tf_keras_metric*�{"class_name": "Mean", "name": "loss", "dtype": "float32", "config": {"name": "loss", "dtype": "float32"}, "shared_object_id": 13}2
�Mroot.keras_api.metrics.1"_tf_keras_metric*�{"class_name": "MeanMetricWrapper", "name": "accuracy", "dtype": "float32", "config": {"name": "accuracy", "dtype": "float32", "fn": "categorical_accuracy"}, "shared_object_id": 10}2
Binary file added model/nn_model.json/saved_model.pb
Binary file not shown.
Binary file not shown.
Binary file added model/nn_model.json/variables/variables.index
Binary file not shown.
2 changes: 1 addition & 1 deletion model/saved_model/fingerprint.pb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
���ą��p��у�Ж�#��������� �������W(�����ӊ�2
��㭒ى�[��у�Ж�#��������� �������W(����ր��R2
Binary file modified model/saved_model/saved_model.pb
Binary file not shown.
Binary file modified model/saved_model/variables/variables.data-00000-of-00001
Binary file not shown.
Binary file modified model/saved_model/variables/variables.index
Binary file not shown.
Binary file modified model/svm_mask.pkl
Binary file not shown.
Binary file modified model/svm_tuning.sav
Binary file not shown.

0 comments on commit 8997228

Please sign in to comment.