AI
AI
import tkinter.messagebox
from PIL import ImageTk, Image
import cv2
import wget
from tkinter import filedialog
img_path = ""
#select image
def fileselector():
global img_path
main_win = tkinter.Tk()
main_win.withdraw()
main_win.overrideredirect(True)
main_win.geometry('0x0+0+0')
main_win.deiconify()
main_win.lift()
main_win.focus_force()
img_path = main_win.sourceFile
print(img_path)
tkinter.messagebox.showinfo("Image Selected","Click on Detect Button. \nTo get the
COVID Prediction")
def predict():
if(img_path==""):
tkinter.messagebox.showinfo("Image Not Selected","Please Select X-Ray Image \nTo
get the COVID Prediction")
else:
print("[INFO] loading network...")
model =load_model('./covid_pypower.h5')
roi_gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
roi_gray = cv2.resize(frame,(224,224))
roi = roi_gray.astype('float')/255.0
roi = img_to_array(roi)
roi = np.expand_dims(roi,axis=0)
preds = model.predict(roi)[0]
#print(preds)
#print(preds.argmax())
label=labels[preds.argmax()]
if(label=='Covid'):
image = cv2.rectangle(frame, start_point, end_point, (0,0,255), thickness)
cv2.putText(image,label,(30,60),cv2.FONT_HERSHEY_SIMPLEX,2,(255,255,255),3)
else:
image = cv2.rectangle(frame, start_point, end_point, (0,255,0), thickness)
cv2.putText(image,label,(30,60),cv2.FONT_HERSHEY_SIMPLEX,1.6,(0,0,0),3)
cv2.imshow('COVID Detector',frame)
root = Tk()
root.title("GUI : COVID Detection")
root.geometry("880x530")
root.configure(background = 'white')
Tops = Frame(root,bg = 'blue',pady = 1, width =1750, height = 90, relief = "ridge")
Tops.grid(row=0,column=0)
img = cv2.imread("./Picture1.png")
img = cv2.resize(img,(420,200))
cv2.imwrite('Picture1.png',img)
img = ImageTk.PhotoImage(Image.open("Picture1.png"))
panel = Label(MainFrame, image = img).grid(row=4,column=0,sticky=E)
img1 = cv2.imread("./Picture3.png")
img1 = cv2.resize(img1,(170,170))
cv2.imwrite('Picture3.png',img1)
img1 = ImageTk.PhotoImage(Image.open("Picture3.png"))
panel = Label(MainFrame, image = img1).grid(row=4,column=1,sticky=E)
root.mainloop()