def _click_callback(self, is_positive, x, y): self.canvas.focus_set() if self.image_on_canvas is None: messagebox.showwarning("Warning", "Please, load an image first") return if self._check_entry(self): click = clicker.Click(is_positive=is_positive, coords=(y, x)) self._make_prediction_for_one_click(click) self._set_click_dependent_widgets_state() self._update_image()
def add_click(self, xcoords, ycoords, pos): for z in range(len(pos)): tmp_bool = pos[z - 1] == 1 click = clicker.Click(is_positive=tmp_bool, coords=(ycoords[z - 1], xcoords[z - 1])) # I THINK THIS LINE IS VERY IMPORTANT self.clicker.add_click(click) print(click.coords) pred = self.predictor.get_prediction(self.clicker) torch.cuda.empty_cache() if self.probs_history: self.probs_history.append((self.probs_history[-1][0], pred)) else: self.probs_history.append((np.zeros_like(pred), pred))
def add_click(self, x, y, is_positive): self.states.append({ 'clicker': self.clicker.get_state(), 'predictor': self.predictor.get_states() }) click = clicker.Click(is_positive=is_positive, coords=(y, x)) self.clicker.add_click(click) pred = self.predictor.get_prediction(self.clicker) torch.cuda.empty_cache() if self.probs_history: self.probs_history.append((self.probs_history[-1][0], pred)) else: self.probs_history.append((np.zeros_like(pred), pred)) self.update_image_callback()