diqitalize commited on
Commit
394a4c7
1 Parent(s): f130a7a
Files changed (5) hide show
  1. Procfile +1 -0
  2. app.py +55 -0
  3. kerang_model_trained.h5 +3 -0
  4. requirements.txt +4 -0
  5. setup.sh +11 -0
Procfile ADDED
@@ -0,0 +1 @@
 
 
1
+ web: sh setup.sh && streamlit run diabetes_app.py
app.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import tensorflow as tf
3
+ import numpy as np
4
+ from PIL import Image
5
+
6
+
7
+ st.set_option('deprecation.showfileUploaderEncoding', False)
8
+
9
+ @st.cache(allow_output_mutation=True)
10
+ def load_model():
11
+ model = tf.keras.models.load_weights('kerang_model_trained.h5')
12
+ return model
13
+
14
+
15
+ def predict_class(image, model):
16
+
17
+ image = tf.cast(image, tf.float32)
18
+ image = tf.image.resize(image, [180, 180])
19
+
20
+ image = np.expand_dims(image, axis = 0)
21
+
22
+ prediction = model.predict(image)
23
+
24
+ return prediction
25
+
26
+
27
+ model = load_model()
28
+ st.title('Kerang Classifier')
29
+
30
+ file = st.file_uploader("Upload an image of a kerang", type=["jpg", "png"])
31
+
32
+
33
+ if file is None:
34
+ st.text('Waiting for upload....')
35
+
36
+ else:
37
+ slot = st.empty()
38
+ slot.text('Running inference....')
39
+
40
+ test_image = Image.open(file)
41
+
42
+ st.image(test_image, caption="Input Image", width = 400)
43
+
44
+ pred = predict_class(np.asarray(test_image), model)
45
+
46
+ class_names = ['kerang bulu', 'kerang darah']
47
+
48
+ result = class_names[np.argmax(pred)]
49
+
50
+ output = 'The image is a ' + result
51
+
52
+ slot.text('Done')
53
+
54
+ st.success(output)
55
+
kerang_model_trained.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a1d50a67f82ea63f883d0d5a32de88fb5393380b30758d133a1568f341c3cdf8
3
+ size 15980944
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ numpy==1.23.1
2
+ Pillow==9.3.0
3
+ streamlit==1.12.0
4
+ tensorflow==2.9.1
setup.sh ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ mkdir -p ~/.streamlit/
2
+ echo "\
3
+ [general]\n\
4
+ email = \"your-email@domain.com\"\n\
5
+ " > ~/.streamlit/credentials.toml
6
+ echo "\
7
+ [server]\n\
8
+ headless = true\n\
9
+ enableCORS=false\n\
10
+ port = $PORT\n\
11
+ " > ~/.streamlit/config.toml