def annotate(self, img_folder): total_num = img_count(img_folder) for img in img_folder: SendToQt(img) record_annot_info() write_annot() SENDTOQt("Finish annotation [X/total_num]")
def visualize(self, img_path, model_path=None): img_mat = cv2.imread(img_path) if not os.path.exists(model_path): return -1 pred = model(img_mat) result_img = plot_vis_det(pred, self.label) SendToQt(plot_img) return 0
def visualize_webcam(self, model_path=None): model = load_model(self.model_path) while True: img_mat = capture(0) pred = model(img_mat) result_img = plot_vis_pose(pred, self.threshold) SendToQt(plot_img) if stop: break return 0
def visualize(self, img_path, model_path=None): if self.level < 0: return -1 img_mat = cv2.imread(img_path) if model_path: model = load_model(model_path) else: model = load_model(self.model_path[self.level]) pred = model(img_mat) result_img = plot_vis_det(pred, self.label) SendToQt(plot_img)
def visualize_webcam(self, model_path=None): self.stop = False if not os.path.exists(model_path): return -1 while True: img_mat = cv2.VideoCapture(0) pred = model(img_mat) result_img = plot_vis_det(pred, self.label) SendToQt(plot_img) if self.stop: break return 0
def visualize_webcam(self, model_path=None): self.stop = False if not os.path.exists(model_path): return -1 # try: while True: img_mat = capture(0) pred = model(img_mat) result_img = plot_vis_cls(pred, self.label) SendToQt(plot_img) if self.stop: break # except: # return -2 return 0
def visualize_webcam(self, model_path=None): self.stop = False if self.level < 0: return -1 if model_path: model = load_model(model_path) else: model = load_model(self.model_path[self.level]) while True: img_mat = capture(0) pred = model(img_mat) result_img = plot_vis_det(pred, self.label) SendToQt(plot_img) if self.stop: break return 0
def train(self, epochs, img_path, model_path=None): self.training_log = {"training acc": [], "training loss": [], "validation acc": [], "validation loss": []} if not check_format_cls(img_path): return -3 img_num = img_count(img_path) self.level = determine_level(img_num * epochs) for epoch in epochs: SendToQt("Training loss: XXX, Training acc: XXX") self.training_log["training acc"].append(acc) self.training_log["training loss"].append(acc) ......... if model_path: move_model(model_path, self.level)
def train(self, epochs, img_path, model_path=None): self.training_log = {"ave classification loss": [], "ave objectness loss": [], "ave iou loss": []} if not check_format_det(img_path): return -3 img_num = img_count(img_path) self.level = determine_level(img_num * epochs) for epoch in epochs: SendToQt("ave classification loss: XXX, ave objectness loss: XXX, ave iou loss: XXX") self.training_log["ave classification loss"].append(cls_loss) self.training_log["ave objectness loss"].append(obj_loss) self.training_log["ave iou loss"].append(iou_loss) ......... if model_path: move_model(model_path, self.level)
def train(self, epochs, img_path, model_path=None): self.training_log = {"loss": [], "PCK": [], "PCKH": [], "mse": []} if not check_format_pose(img_path): return -3 img_num = img_count(img_path) self.threshold = determine_threshold(img_num * epochs) for epoch in epochs: SendToQt("Epoch: epoch [X/X], loss: XXX, PCK: XXX, PCKH: XXX, mse: XXX") self.training_log["loss"].append(loss) self.training_log["PCK"].append(PCK) self.training_log["mse"].append(mse) self.training_log["PCKH"].append(PCKH) ......... if model_path: save(model_path)
def train(self, epochs, img_path, model_path="model.pth"): if not check_format_det(img_path): return -3 img_num = img_count(img_path) load_model() load_data() self.label = load_label() self.training_results = {"ave classification loss": [], "ave objectness loss": [], "ave iou loss": []} for epoch in epochs: for inputs, labels in data_loader: SendToQt("ave classification loss: XXX, ave objectness loss: XXX, ave iou loss: XXX") self.training_results["ave classification loss"].append(cls_loss) self.training_results["ave objectness loss"].append(obj_loss) self.training_results["ave iou loss"].append(iou_loss) ......... save(model_path)
def train(self, epochs, img_path, model_path=None): if not check_format_cls(img_path): return -3 load_model() train_val_split(0.2) load_data() self.label = load_label() self.training_log = {"training acc": [], "training loss": [], "validation acc": [], "validation loss": []} for epoch in epochs: for inputs, labels in data_loader: SendToQt("Training loss: XXX, Training acc: XXX") time.sleep() self.training_log["training acc"].append(acc) self.training_log["training loss"].append(acc) ......... save(model_path) return 0
def plot(self): plot_img = plot_graph(self.training_results) SendToQt(plot_img)
def plot(self): if not os.path.exists(self.default_path): return -1 plot_img = plot_graph(self.training_results) SendToQt(plot_img) return 0
def plot(self): plot_img = plot_graph_det(self.training_log) SendToQt(plot_img)
def visualize(self, img_path, model_path=None): img_mat = cv2.imread(img_path) model = load_model(self.model_path) pred = model(img_mat) result_img = plot_vis_pose(pred, self.threshold) SendToQt(plot_img)