ilhamstoked commited on
Commit
0385851
1 Parent(s): a6361a1

Upload 5 files

Browse files
InceptionResNetV2Skripsi.tflite ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2ce9b335d23bb9811adffe070040def6a0b8feecff69e345c0d1c16364804bfb
3
+ size 56233680
PythonApplication2.pyproj ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
2
+ <PropertyGroup>
3
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4
+ <SchemaVersion>2.0</SchemaVersion>
5
+ <ProjectGuid>cb57c127-7b42-46f1-a142-114ef4703e1f</ProjectGuid>
6
+ <ProjectHome>.</ProjectHome>
7
+ <StartupFile>PythonApplication2.py</StartupFile>
8
+ <SearchPath>
9
+ </SearchPath>
10
+ <WorkingDirectory>.</WorkingDirectory>
11
+ <OutputPath>.</OutputPath>
12
+ <Name>PythonApplication2</Name>
13
+ <RootNamespace>PythonApplication2</RootNamespace>
14
+ </PropertyGroup>
15
+ <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
16
+ <DebugSymbols>true</DebugSymbols>
17
+ <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
18
+ </PropertyGroup>
19
+ <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
20
+ <DebugSymbols>true</DebugSymbols>
21
+ <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
22
+ </PropertyGroup>
23
+ <ItemGroup>
24
+ <Compile Include="app.py" />
25
+ </ItemGroup>
26
+ <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
27
+ <!-- Uncomment the CoreCompile target to enable the Build command in
28
+ Visual Studio and specify your pre- and post-build commands in
29
+ the BeforeBuild and AfterBuild targets below. -->
30
+ <!--<Target Name="CoreCompile" />-->
31
+ <Target Name="BeforeBuild">
32
+ </Target>
33
+ <Target Name="AfterBuild">
34
+ </Target>
35
+ </Project>
PythonApplication2.sln ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 
2
+ Microsoft Visual Studio Solution File, Format Version 12.00
3
+ # Visual Studio Version 17
4
+ VisualStudioVersion = 17.2.32526.322
5
+ MinimumVisualStudioVersion = 10.0.40219.1
6
+ Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "PythonApplication2", "PythonApplication2.pyproj", "{CB57C127-7B42-46F1-A142-114EF4703E1F}"
7
+ EndProject
8
+ Global
9
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
10
+ Debug|Any CPU = Debug|Any CPU
11
+ Release|Any CPU = Release|Any CPU
12
+ EndGlobalSection
13
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
14
+ {CB57C127-7B42-46F1-A142-114EF4703E1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15
+ {CB57C127-7B42-46F1-A142-114EF4703E1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
16
+ EndGlobalSection
17
+ GlobalSection(SolutionProperties) = preSolution
18
+ HideSolutionNode = FALSE
19
+ EndGlobalSection
20
+ GlobalSection(ExtensibilityGlobals) = postSolution
21
+ SolutionGuid = {A738FEDC-1393-4DFF-8634-ADAD6A2203CA}
22
+ EndGlobalSection
23
+ EndGlobal
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