-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
37 lines (24 loc) · 1.17 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import numpy as np
from PIL import Image
from sklearn.preprocessing import LabelEncoder
from tensorflow.keras.models import load_model
def getPrediction(filename):
classes = ['Actinic keratoses', 'Basal cell carcinoma',
'Benign keratosis-like lesions', 'Dermatofibroma', 'Melanoma',
'Melanocytic nevi', 'Vascular lesions']
le = LabelEncoder()
le.fit(classes)
le.inverse_transform([2])
#Load model
my_model=load_model("/workspaces/Classification-of-Dermatoscopic-Images/models/model.h5")
SIZE = 32 #Resize to same size as training images
img_path = '/workspaces/Classification-of-Dermatoscopic-Images/static/images/'+filename
img = np.asarray(Image.open(img_path).resize((SIZE,SIZE)))
img = img/255. #Scale pixel values
img = np.expand_dims(img, axis=0) #Get it tready as input to the network
pred = my_model.predict(img) #Predict
#Convert prediction to class name
pred_class = le.inverse_transform([np.argmax(pred)])[0]
print("Diagnosis is:", pred_class)
return pred_class
#test_prediction =getPrediction('download.jfif')