ilhamstoked commited on
Commit
fba395c
1 Parent(s): 0983138

Upload 4 files

Browse files
Files changed (4) hide show
  1. InceptionResNetV2Skripsi.tflite +3 -0
  2. README.md +2 -0
  3. app1.py +84 -0
  4. requirements.txt +4 -0
InceptionResNetV2Skripsi.tflite ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2ce9b335d23bb9811adffe070040def6a0b8feecff69e345c0d1c16364804bfb
3
+ size 56233680
README.md ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ # SkripsiStreamlit
2
+
app1.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ import tensorflow as tf
4
+ from tcp_latency import measure_latency
5
+
6
+ # Measure Latency
7
+ latency = measure_latency(host='35.201.127.49', port=443)
8
+ #35.201.127.49:443
9
+ #192.168.18.6:8501
10
+
11
+ # Load TensorFlow Lite model
12
+ interpreter = tf.lite.Interpreter(model_path="InceptionResNetV2Skripsi.tflite")
13
+ interpreter.allocate_tensors()
14
+
15
+ # Get input and output tensors
16
+ input_details = interpreter.get_input_details()
17
+ output_details = interpreter.get_output_details()
18
+
19
+ # Define a function to resize the input image
20
+ def resize_image(image):
21
+ # Resize the image to 150x150 pixels
22
+ resized_image = tf.image.resize(image, [150, 150])
23
+ return resized_image.numpy()
24
+
25
+ # Define a function to run inference on the TensorFlow Lite model
26
+ def classify_image(image):
27
+ # Pre-process the input image
28
+ resized_image = resize_image(image)
29
+ input_data = np.expand_dims(resized_image, axis=0).astype(np.float32)
30
+ interpreter.set_tensor(input_details[0]['index'], input_data)
31
+
32
+ # Run inference
33
+ with st.spinner('Classifying...'):
34
+ interpreter.invoke()
35
+
36
+ # Get the output probabilities
37
+ output_data = interpreter.get_tensor(output_details[0]['index'])
38
+ return output_data[0]
39
+
40
+ # Define the labels for the 7 classes
41
+ labels = ['akiec', 'bcc', 'bkl', 'df', 'mel', 'nv', 'vasc']
42
+
43
+ from PIL import Image
44
+ # Define the main Streamlit app
45
+ def main():
46
+ st.title("Skin Cancer Classification")
47
+
48
+ st.write("The application allows users to quickly and easily check for signs of skin cancer from the comfort of their own homes. It's important to note that the application is not a substitute for medical advice, but rather a tool to help users identify potential skin issues and seek professional help if necessary. Heres the overview:")
49
+ st.write("1. The user is prompted to upload an image of a skin lesion.")
50
+ st.write("2. Once the user uploads an image, it is displayed on the screen and the application runs the image through a machine learning model.")
51
+ st.write("3. The model outputs the top 3 predictions for the type of skin cancer (out of 7 classes) that the lesion may be, along with the confidence level for each prediction.")
52
+ st.write("4. The user is shown the top 3 predictions and their confidence levels.")
53
+ st.write("5. If the model's confidence level is less than 70%, the application informs the user that the skin is either healthy or the input image is unclear. It is also recommended that the user consults a dermatologist for any skin concerns.")
54
+ st.write ("6. The application also measures the latency or response time for the model to classify the image, and displays it to the user.")
55
+ st.write("Please note that this model still has room for academic revision as it can only classify the following 7 classes")
56
+ st.write("- ['akiec'](https://en.wikipedia.org/wiki/Squamous-cell_carcinoma) - squamous cell carcinoma (actinic keratoses dan intraepithelial carcinoma),")
57
+ st.write("- ['bcc'](https://en.wikipedia.org/wiki/Basal-cell_carcinoma) - basal cell carcinoma,")
58
+ st.write("- ['bkl'](https://en.wikipedia.org/wiki/Seborrheic_keratosis) - benign keratosis (serborrheic keratosis),")
59
+ st.write("- ['df'](https://en.wikipedia.org/wiki/Dermatofibroma) - dermatofibroma, ")
60
+ st.write("- ['nv'](https://en.wikipedia.org/wiki/Melanocytic_nevus) - melanocytic nevus, ")
61
+ st.write("- ['mel'](https://en.wikipedia.org/wiki/Melanoma) - melanoma,")
62
+ st.write("- ['vasc'](https://en.wikipedia.org/wiki/Vascular_anomaly) - vascular skin (Cherry Angiomas, Angiokeratomas, Pyogenic Granulomas.)")
63
+ st.write("Due to imperfection of the model and a room of improvement for the future, if the probabilities shown are less than 70%, the skin is either healthy or the input image is unclear. This means that the model can be the first diagnostic of your skin illness. As precautions for your skin illness, it is better to do consultation with dermatologist. ")
64
+ st.write(latency[0])
65
+
66
+ # Get the input image from the user
67
+ image = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
68
+
69
+ # Show the input image
70
+ if image is not None:
71
+ image = np.array(Image.open(image))
72
+ st.image(image, width=150)
73
+
74
+ # Run inference on the input image
75
+ probs = classify_image(image)
76
+
77
+ # Display the top 3 predictions
78
+ top_3_indices = np.argsort(probs)[::-1][:3]
79
+ st.write("Top 3 predictions:")
80
+ for i in range(3):
81
+ st.write("%d. %s (%.2f%%)" % (i + 1, labels[top_3_indices[i]], probs[top_3_indices[i]] * 100))
82
+
83
+ if __name__ == '__main__':
84
+ main()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ streamlit
2
+ tensorflow
3
+ numpy
4
+ tcp_latency