Click here to Skip to main content
15,867,756 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I upload an image at GUI was non demented but the output at GUI become mild demented 4 times. This is the output that i get at my GUI (Predicted output for uploaded Image: ['MildDemented' 'MildDemented' 'MildDemented' 'MildDemented'). What i need at output is (Predicted output for uploaded Image: ['NonDemented'])

Can anyone suggest what can be solve

I think my problem at
def predict():
disease = model.predict(img4)
prediction = disease[0]
prediction_name = mapping[[int(x) for x in prediction]]
text.insert(END,"Predicted output for uploaded Image: "+str(prediction_name)+"\n")


What I have tried:

Python
from tkinter import messagebox
from tkinter import *
from tkinter import simpledialog
import tkinter
from tkinter import filedialog
from tkinter.filedialog import askopenfilename
import numpy
import keras
import cv2
import matplotlib.pyplot as plt
from keras.models import load_model
from keras import models
from keras import layers
from tensorflow.keras import optimizers
main = tkinter.Tk()
main.title("Alzeimer's prediction")
main.geometry("1024x768")
mapping = numpy.array(['MildDemented', 'ModerateDemented', 'NonDemented', 'VeryMildDemented'])
def load():
global model
model = load_model('model_final.h5')
model.summary()
model.compile(loss='categorical_crossentropy',
optimizer=optimizers.RMSprop(learning_rate=1e-4),
metrics=['acc'])

def upload():
text.delete('1.0',END)
global filename
filename = askopenfilename()
text.insert(END,"File Uploaded: "+str(filename)+"\n")

def imagepreprocess():
global img4
img3 = cv2.imread(filename)
img3 = cv2.cvtColor(img3, cv2.COLOR_BGR2RGB)
img3 = cv2.resize(img3,(224,224))
img4 = numpy.reshape(img3,[1,224,224,3])

def predict():
disease = model.predict(img4)
prediction = disease[0]
prediction_name = mapping[[int(x) for x in prediction]]
text.insert(END,"Predicted output for uploaded Image: "+str(prediction_name)+"\n")
Posted
Updated 21-May-22 22:00pm
v5
Comments
Richard MacCutchan 22-May-22 3:52am    
Ypou need to fix the indentation of your code, and explain exactly what the problem is and where it occurs.
Mohamad Farid Asnawi 22-May-22 3:59am    
done update my problem
Richard MacCutchan 22-May-22 4:09am    
OK, so you think the problem is in that code. What are the values in the variables as that runs, what is the expected result, and what is the actual result?
Mohamad Farid Asnawi 22-May-22 4:11am    
expected result should be nondemented if i upload image nondemented same goes to if i upload image milddemented expected result should be mildemented
Richard MacCutchan 22-May-22 4:17am    
You have not answered my question? We cannot guess what data that function is processing.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900