MohamedSherif commited on
Commit
427a239
1 Parent(s): cb672e0

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -52
app.py DELETED
@@ -1,52 +0,0 @@
1
- import gradio as gr
2
- import numpy as np
3
- from skimage.transform import resize
4
- from tensorflow.keras.models import Sequential, load_model
5
- from tensorflow.keras.layers import Conv2D, MaxPool2D, Dropout, Dense, Flatten, BatchNormalization
6
-
7
- class SkinCancer :
8
- def __init__ (self):
9
- self.model = self.load_model()
10
-
11
- def build_model () :
12
- model = Sequential()
13
- model.add(Conv2D(filters = 128, kernel_size = (4,4), input_shape = (32, 32, 3), activation = 'relu'))
14
- model.add(MaxPool2D(pool_size = (4,4)))
15
- model.add(Conv2D(filters = 64, kernel_size = (2,2), activation = 'relu'))
16
- model.add(MaxPool2D(pool_size = (2,2)))
17
- model.add(BatchNormalization())
18
- #model.add(GlobalAveragePooling2D())
19
-
20
- model.add(Flatten())
21
- model.add(Dense(128, activation = 'relu'))
22
- model.add(Dropout(0.2))
23
- model.add(Dense(2, activation = 'sigmoid')) # sigmoid is better for binary classification
24
-
25
- model.summary()
26
- return model
27
- def load_model(self):
28
- model = self.build_model()
29
- model = load_model("Normal_skin_cancer_model.h5")
30
- return model
31
-
32
- def preprocess_image(self,img):
33
- img = resize(img, (64,64))
34
- img = img.reshape(1,64,64,3)
35
- return img
36
-
37
- def predict(self,img):
38
- real_labels = ["benign", "malignant"]
39
- img = self.preprocess_image(img)
40
- res = np.argmax(self.model.predict(img))
41
- return real_labels[res]
42
-
43
- def Test(img):
44
- model_new = SkinCancer()
45
- res = model_new.predict(img)
46
- return res
47
- #interface
48
- interface = gr.Interface(fn = Test,
49
- inputs = gr.inputs.Image(shape=(200,200)),
50
- outputs=["text"],
51
- title="Skin Cancer detection")
52
- interface.launch()