Varsha-20052004 commited on
Commit
1e5ca27
·
verified ·
1 Parent(s): c0db850

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -30
app.py CHANGED
@@ -1,30 +1,30 @@
1
- import streamlit as st
2
- from tensorflow.keras.models import load_model
3
- from PIL import Image
4
- import numpy as np
5
-
6
- st.title("Skin Cancer Image Classification")
7
- st.write("Upload an image and let the model guess whether it is a cancer or not.")
8
-
9
- model = load_model("my_cnn_model.keras")
10
-
11
- def process_image(img):
12
- img = img.resize((170,170)) # set the size as 170 x 170 pixel
13
- img = np.array(img)
14
- img = img / 255.0 # normalized
15
- img = np.expand_dims(img, axis=0)
16
- return img
17
-
18
-
19
- file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
20
-
21
- if file is not None:
22
- img = Image.open(file)
23
- st.image(img, caption="Uploaded Image")
24
- image = process_image(img)
25
-
26
- prediction = model.predict(image)
27
- predicted_class = np.argmax(prediction)
28
-
29
- class_names = ["It is NOT Cancer!", "It is Cancer!"]
30
- st.write(class_names[predicted_class])
 
1
+ import streamlit as st
2
+ from tensorflow.keras.models import load_model
3
+ from PIL import Image
4
+ import numpy as np
5
+
6
+ st.title("Skin Cancer Image Classification")
7
+ st.write("Upload an image and let the model guess whether it is a cancer or not.")
8
+
9
+ model = load_model("my_cnn_model.keras")
10
+
11
+ def process_image(img):
12
+ img = img.resize((170,170)) # set the size as 170 x 170 pixel
13
+ img = np.array(img)
14
+ img = img / 255.0 # normalized
15
+ img = np.expand_dims(img, axis=0)
16
+ return img
17
+
18
+
19
+ file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
20
+
21
+ if file is not None:
22
+ img = Image.open(file)
23
+ st.image(img, caption="Uploaded Image")
24
+ image = process_image(img)
25
+
26
+ prediction = model.predict(image)
27
+ predicted_class = np.argmax(prediction)
28
+
29
+ class_names = ["It is NOT Cancer!", "A melanocytic nevus is usually a noncancerous condition where pigment-producing skin cells group together. It is a type of growth on the skin that contains nevus cells (a type of skin cell). "]
30
+ st.write(class_names[predicted_class])