コード例 #1
0
    def __init__(self,
                 input_size=416,
                 config_file='Models/yolo-tiny-onecls/yolov3-tiny-onecls.cfg',
                 weight_file='Models/yolo-tiny-onecls/best-model.pth',
                 nms=0.2,
                 conf_thres=0.45,
                 device='cuda'):
        self.input_size = input_size
        self.model = Darknet(config_file).to(device)
        self.model.load_state_dict(torch.load(weight_file))
        self.model.eval()
        self.device = device

        self.nms = nms
        self.conf_thres = conf_thres

        self.resize_fn = ResizePadding(input_size, input_size)
        self.transf_fn = transforms.ToTensor()
コード例 #2
0
    def __init__(self, master: tk.Tk):
        self.master = master
        self.master.title('Human Falling Detection')
        self.master.protocol('WM_DELETE_WINDOW', self._on_closing)
        self.main_screen = get_monitor_from_coord(master.winfo_x(),
                                                  master.winfo_y())

        self.width = int(self.main_screen.width * .85)
        self.height = int(self.main_screen.height * .85)
        self.master.geometry('{}x{}'.format(self.width, self.height + 15))

        self.cam = None
        self.canvas = tk.Canvas(master,
                                width=int(self.width * .65),
                                height=self.height)
        self.canvas.grid(row=0, column=0, padx=5, pady=5, sticky=tk.NSEW)

        fig = plt.Figure(figsize=(6, 8), dpi=100)
        fig.suptitle('Actions')
        self.ax = fig.add_subplot(111)
        self.fig_canvas = FigureCanvasTkAgg(fig, self.master)
        self.fig_canvas.get_tk_widget().grid(row=0,
                                             column=1,
                                             padx=5,
                                             pady=5,
                                             sticky=tk.NSEW)

        # Load Models
        self.resize_fn = ResizePadding(416, 416)
        self.models = Models()

        self.actions_graph()

        self.delay = 15
        self.load_cam('../Data/falldata/Home/Videos/video (1).avi')
        self.update()
    # POSE MODEL.
    inp_pose = args.pose_input_size.split('x')
    inp_pose = (int(inp_pose[0]), int(inp_pose[1]))
    pose_model = SPPE_FastPose(args.pose_backbone,
                               inp_pose[0],
                               inp_pose[1],
                               device=device)

    # Tracker.
    max_age = 30
    tracker = Tracker(max_age=max_age, n_init=3)

    # Actions Estimate.
    action_model = TSSTG()

    resize_fn = ResizePadding(inp_dets, inp_dets)

    cam_source = args.camera
    if type(cam_source) is str and os.path.isfile(cam_source):
        # Use loader thread with Q for video file.
        cam = CamLoader_Q(cam_source, queue_size=1000,
                          preprocess=preproc).start()
    else:
        # Use normal thread loader for webcam.
        cam = CamLoader(
            int(cam_source) if cam_source.isdigit() else cam_source,
            preprocess=preproc).start()

    #frame_size = cam.frame_size
    #scf = torch.min(inp_size / torch.FloatTensor([frame_size]), 1)[0]