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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| import tkinter as tk
fenetre = tk.Tk()
class Informations(object):
def __init__(self , fil,fig,imag):
self.fig = fig
self.imag = imag
self.fil =fil
self.nucl= tk.StringVar()
def askopenfile(self):
fil=filedialog.askopenfilename(initialdir = "/",title = "Select file",filetypes = (("xlsx files","*.xlsx"),("all files","*.*")))
return fil
def plot (self,fil):
#file ='/Users/imed/Desktop/Radionucléide/Co60/export20190430_125508.xlsx'
fil=filedialog.askopenfilename(initialdir = "/",title = "Select file",filetypes = (("xlsx files","*.xlsx"),("all files","*.*")))
xl = pd.ExcelFile(sel)
df1 = xl.parse('Spectre')
coups=df1['Coups']
energie=df1['Energie (keV)']
fig = Figure()
a = fig.add_subplot(111)
a.plot(energie,coups,'k')
a.vlines(x=energie,ymin=0,ymax=coups,color='black')
imag = io.BytesIO()
pyplot.savefig(imag, format='png')
imag.seek(0)
return(fig,imag,nucl)
def learn(self,imag):
model = load_model('/Users/imed/Desktop/new_model_200.h5')
nucleide=['Mn','U','Cs','Am','Na','Co60','Y','Sr']
img = image.load_img(imag, target_size=(128, 128))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
images = np.vstack([x])
classes = model.predict_classes(images/255)
nucl= nucleide[classes[0]]
return nucl
info = Informations(fil,fig,imag)
canvas = FigureCanvasTkAgg(info.fig, master=fenetre)
canvas.get_tk_widget().pack()
canvas.draw()
label = tk.Label(fenetre, textvariable=info.nucl)
label.pack()
button = Button (window, text="upload", command=info.askopenfile)
button.pack()
button1 = Button (window, text="plott", command=info.plot)
button2 = Button (window, text="check", command=info.nucl)
button1.pack()
fenetre.mainloop() |
Partager