Пример #1
0
    def __init__(self, master):

        # sets the image repository and the user labeled data
        self.dictionaryLocation = "PreLabeledTrainingData/women/"
        
        self.autoLabels = "AutoLabeledData/labels.csv"
        self.autoImageLocation = "AutoLabeledData/"
        self.autoFaceLocation = "AutoLabeledData/Faces/"
        
        self.newImageLocation = "UserTrainingData/"
        self.labelLocation = "UserTrainingData/womenlabels.csv"
        #self.newImageLocation = "AutoLabeledData/"
        #self.labelLocation = "AutoLabeledData/labels.csv"
        
        self.userPredictor = userPredictor.UserPredictor("Models/", '/home/testing32/Downloads/word2vec/trunk/vectors.bin', "user_")

        self.images = None
        self.currentImage = None
        self.currentUser = None
        self.matches = []
        self.master = master

        # set the title
        master.wm_title("Automatic Tinder")

        # binds the frame and the key events
        button_frame = Frame(master)
        button_frame.bind_all("<Key>", self.key_press)
        button_frame.pack()

        # default menu value
        variable = StringVar(button_frame)
        variable.set("Local") 
        
        # set up the drop down menu for switching between Local images and Tinder images
        w = OptionMenu(button_frame, variable, "Local", "Tinder", command=self.menu_change)
        w.pack(side=LEFT)
        
        # create the "No" button
        self.no_btn = Button(button_frame, text="NO (1)", fg="red", command=self.no)
        self.no_btn.pack(side=LEFT)

        # create the "Yes" button
        self.yes_btn = Button(button_frame, text="YES (2)", fg="blue", command=self.yes)
        self.yes_btn.pack(side=LEFT)
        
        # create the "Automate" button
        self.auto_btn = Button(button_frame, text="Automate", fg="brown", command=self.auto)
        self.auto_btn.pack(side=LEFT)
        
        # create the "Previous Image" button
        self.prev_img_btn = Button(button_frame, text="Previous Image", fg="black", command=self.showPreviousImage)
        self.prev_img_btn.pack(side=LEFT)
        
        # create the "Next Image" button
        self.next_img_btn = Button(button_frame, text="Next Image", fg="black", command=self.showNextImage)
        self.next_img_btn.pack(side=LEFT)
        
        # create the "Matches" button
        self.matches_text = StringVar(value="Matches (0)")
        self.matches_btn = Button(button_frame, textvariable=self.matches_text, command=self.openMatches)
        self.matches_btn.pack(side=BOTTOM)
        
        # Setting up the profile text area
        profile_frame = Frame(master)
        profile_frame.pack()
        
        self.profile_text = StringVar(value="")
        self.profile_lbl = Label(profile_frame, textvariable=self.profile_text, width=60,wraplength=475)
        self.profile_lbl.pack(side=BOTTOM)
        
        # Setting up the image area
        image_frame = Frame(master)
        image_frame.pack()
        
        # load the image
        self.pic = Label()
        self.pic.pack(side=BOTTOM)
        
        # create the interface to our data
        """
        self.imgInterface = AutoDataWrapper(
            self.dictionaryLocation, 
            self.labelLocation)
        """
        self.imgInterface = LocalDataWrapper(
            self.dictionaryLocation, 
            self.labelLocation)
        
        # Load the next user from the image interface
        self.loadUser(self.imgInterface.getNextUser())
Пример #2
0
    def __init__(self):
        def onresize(event):
            data_canvas.configure(scrollregion=data_canvas.bbox("all"))
            self.root.update_idletasks()

        def on_mousewheel(event):
            data_canvas.yview_scroll(-1 * (event.delta / 120), "units")
            self.root.update_idletasks()

        self.root = Tk()
        self.root.wm_title("Micro-Tensile Testing Machine")
        self.root.state("zoomed")

########################################################################################################################
        # Title
        header = Frame(self.root)
        Label(header, text="Micro-Tensile Testing Machine", font=("Helvetica", 40, "bold"), bg="green", relief=RAISED).grid(row=0)
        header.columnconfigure(0, weight=1)
        header.grid(row=0, sticky=E + W)
########################################################################################################################
        # Parameters
        par_frame = Frame(self.root)
        choice_frame = Frame(par_frame, bd=2, relief=RAISED)
        self.choice = IntVar()
        self.choice.set(1)
        Radiobutton(choice_frame, text="ELONGATION", font=("Courier", 15),
                    variable=self.choice, value=1).grid(row=0, column=0, padx=50)
        Radiobutton(choice_frame, text="BENDING", font=("Courier", 15),
                    variable=self.choice, value=2).grid(row=1, column=0, padx=50)
        choice_frame.grid(row=0, column=0, sticky=W)

        spec_frame = Frame(par_frame, bd=2, relief=RAISED)
        Label(spec_frame, text="Specimen\nDimensions", font=("arial", 15)).grid(row=0, column=0, rowspan=2)
        Label(spec_frame, text="LENGTH(mm)", font=("Courier", 15),
              relief=SUNKEN, bg="yellow", fg="brown").grid(row=0, column=1, ipadx=5, ipady=1)
        self.L = Entry(spec_frame, fg="blue", font=("Courier", 15), width=7)
        self.L.insert(0, 25.4)
        self.L.grid(row=0, column=2)
        Label(spec_frame, text="Area(mm^2)", font=("Courier", 15),
              relief=SUNKEN, bg="yellow", fg="brown").grid(row=1, column=1, ipadx=5, ipady=1)
        self.area_box = Entry(spec_frame, fg="blue", font=("Courier", 15), width=7)
        self.area_box.insert(0, 40.3765)
        self.area_box.grid(row=1, column=2)
        spec_frame.grid(row=0, column=1, rowspan=2, sticky=E)
        par_frame.grid_columnconfigure(1, weight=1)
        par_frame.grid(row=1, sticky=E + W)
########################################################################################################################
        # Main Frame containing Curve and data display
        curve = Frame(self.root)

        self.no_reading = 0
        # Stress, Strain value arrays
        self.stress = np.array([0.0])
        self.strain = np.array([0.0])

        # Figure

        main_curve = plot.figure(figsize=(18.5, 10))
        gs = gridspec.GridSpec(1, 2, width_ratios=[3, 2])

        ###################################################################
        # # Live diagram
        live_plot = main_curve.add_subplot(gs[0, 0])
        live_plot.set_title("Live Diagram")
        live_plot.grid(True)
        live_plot.set_xlabel("in mm")
        live_plot.set_xlim([0, float(self.L.get())])
        live_plot.set_ylim([0, 50.0])  # Set y axis limits for live diagram

        self.lines = live_plot.plot([0.0], [0.0], 'b-', [0.0], [0.0], 'r--')
        self.live_plot = live_plot
        ###################################################################
        # # Stress-Strain Curve
        curve_plot = main_curve.add_subplot(gs[0, 1])
        curve_plot.set_title("Curve")
        curve_plot.grid(True)
        curve_plot.set_xlim([0.0, 0.01])
        curve_plot.set_ylim([0.0, 100.0])
        curve_plot.set_xlabel("")
        curve_plot.set_ylabel("")

        self.points = curve_plot.plot(self.strain, self.stress, 'k-')
        self.curve_plot = curve_plot
        ###################################################################
        # # Save and show Figure
        main_curve.tight_layout()
        self.main_curve = main_curve
        self.canvas_main = FigureCanvasTkAgg(self.main_curve, master=curve)
        self.canvas_main.show()
        self.canvas_main.get_tk_widget().grid(row=0, column=0, sticky=N + S + E + W)

        # Displaying data
        disp_data = Frame(curve, relief=RAISED, bd=2)
        yscrollbar = AutoScrollbar(disp_data)
        yscrollbar.grid(row=0, column=1, rowspan=4, sticky=N + S)
        xscrollbar = AutoScrollbar(disp_data, orient=HORIZONTAL)
        xscrollbar.grid(row=2, column=0, sticky=E + W)
        data_canvas = Canvas(disp_data, yscrollcommand=yscrollbar.set, xscrollcommand=xscrollbar.set)
        data_canvas.grid(row=0, column=0, rowspan=4, sticky=N + S + W + E)
        yscrollbar.config(command=data_canvas.yview)
        xscrollbar.config(command=data_canvas.xview)
        label_frame = Frame(disp_data)
        Label(label_frame, text="DATA\nS.No  Load(N)  Elongation(mm)\n",
              font=("COMIC SANS MS", 17, "bold")).grid(row=0, column=0, sticky=N + S + W + E)
        self.data = StringVar()
        self.data_str = ""
        self.data.set(self.data_str)
        Label(label_frame, textvariable=self.data,
              font=("Helvetica", 16, "italic")).grid(row=1, column=0, sticky=N + S + W + E)
        data_canvas.create_window(0, 0, window=label_frame)
        label_frame.bind("<Configure>", onresize)
        label_frame.bind_all("<MouseWheel>", on_mousewheel)

        disp_data.rowconfigure(1, weight=1)
        disp_data.columnconfigure(0, weight=1)
        disp_data.columnconfigure(1, weight=1)

        disp_data.grid(row=0, column=1, sticky=N + S + W + E)

        curve.columnconfigure(0, weight=1)
        curve.grid(row=2, sticky=N + S + E + W)
########################################################################################################################
        footer = Frame(self.root)
        Button(footer, text="Run", font=('Comic Sans MS', 25, "bold italic"),
               command=self.run_program).grid(row=0, column=0)
        footer.columnconfigure(0, weight=1)
        footer.grid(row=3, sticky=N + S + E + W)

        self.root.mainloop()