Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DLC2Action project GUI #10

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,4 @@ dmypy.json

#data
last_action_choice.pickle
/config.yaml
dlc2action_annotation/config.yaml
33 changes: 0 additions & 33 deletions AnnotationGUI.yaml

This file was deleted.

7 changes: 4 additions & 3 deletions dev-tools/update_license_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
Thanks @stes - https://github.com/DeepLabCut/DeepLabCut/blob/master/tools/update_license_headers.py
"""

import tempfile
import glob
import yaml
import fnmatch
import glob
import subprocess
import tempfile

import yaml


def load_config(filename):
Expand Down
65 changes: 46 additions & 19 deletions annotator.py → dlc2action_annotation/annotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from typing import Optional

import click
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtCore import pyqtSignal, Qt
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import (
QAction,
Expand All @@ -22,11 +22,16 @@
QStatusBar,
)

from utils import get_settings, read_settings, read_video
from widgets.core.backup import BackupManager
from widgets.dialog import Form
from widgets.settings import SettingsWindow
from widgets.viewer import Viewer as Viewer
from dlc2action_annotation.utils import (
get_library_path,
get_settings,
read_settings,
read_video,
)
from dlc2action_annotation.widgets.core.backup import BackupManager
from dlc2action_annotation.widgets.dialog import Form
from dlc2action_annotation.widgets.settings import SettingsWindow
from dlc2action_annotation.widgets.viewer import Viewer as Viewer


class MainWindow(QMainWindow):
Expand All @@ -39,7 +44,7 @@ def __init__(
dev=False,
active_learning=False,
show_settings=False,
config_file="config.yaml",
config_file=None,
al_points_dictionary=None,
clustering_parameters=None,
skeleton_files=None,
Expand All @@ -50,6 +55,8 @@ def __init__(
backup_interval: int = 30,
):
super(MainWindow, self).__init__()
if config_file is None:
config_file = os.path.join(get_library_path(), "config.yaml")
self.toolbar = None
self.menubar = None
self.viewer: Optional[Viewer] = None
Expand Down Expand Up @@ -256,7 +263,9 @@ def run_viewer(

if self.backup_dir is None:
default_video_path = Path(self.videos[0])
backup_path = default_video_path.with_name(default_video_path.stem + "_backups")
backup_path = default_video_path.with_name(
default_video_path.stem + "_backups"
)
else:
backup_path = Path(self.backup_dir)
self.backup_manager = BackupManager(
Expand Down Expand Up @@ -335,39 +344,40 @@ def load_data(self, type):

def _createActions(self):
# File actions
icons_path = os.path.join(get_library_path(), "img")
self.play_action = QAction(self)
self.play_action.setText("Play / Stop")
self.play_action.setIcon(QIcon("icons/pause-button.png"))
self.play_action.setIcon(QIcon(os.path.join(icons_path, "pause-button.png")))
self.play_action.triggered.connect(lambda: self.viewer.on_play())
self.move_action = QAction(self, checkable=True)
self.move_action.setChecked(True)
self.move_action.setText("Move")
self.move_action.setShortcut("Ctrl+M")
self.move_action.setIcon(QIcon("icons/hand.png"))
self.move_action.setIcon(QIcon(os.path.join(icons_path, "hand.png")))
self.move_action.triggered.connect(self.viewer.set_move_mode)
self.remove_action = QAction(self, checkable=True)
self.remove_action.setText("Remove")
self.remove_action.setIcon(QIcon("icons/trash.png"))
self.remove_action.setIcon(QIcon(os.path.join(icons_path, "trash.png")))
self.remove_action.triggered.connect(self.viewer.set_remove_mode)
self.remove_action.setShortcut("Ctrl+R")
self.new_action = QAction(self, checkable=True)
self.new_action.setText("New")
self.new_action.triggered.connect(self.viewer.set_new_mode)
self.new_action.setShortcut("Ctrl+N")
self.new_action.setIcon(QIcon("icons/plus.png"))
self.new_action.setIcon(QIcon(os.path.join(icons_path, "plus.png")))
self.cut_action = QAction(self, checkable=True)
self.cut_action.setText("Cut")
self.cut_action.setIcon(QIcon("icons/scissors.png"))
self.cut_action.setIcon(QIcon(os.path.join(icons_path, "scissors.png")))
self.cut_action.triggered.connect(self.viewer.set_cut_mode)
self.cut_action.setShortcut("Ctrl+C")
self.ass_action = QAction(self, checkable=True)
self.ass_action.setText("Assign")
self.ass_action.setIcon(QIcon("icons/pantone.png"))
self.ass_action.setIcon(QIcon(os.path.join(icons_path, "pantone.png")))
self.ass_action.triggered.connect(self.viewer.set_ass_mode)
self.ass_action.setShortcut("Ctrl+A")
self.amb_action = QAction(self, checkable=True)
self.amb_action.setText("Ambiguous")
self.amb_action.setIcon(QIcon("icons/transparency.png"))
self.amb_action.setIcon(QIcon(os.path.join(icons_path, "transparency.png")))
self.amb_action.triggered.connect(self.viewer.set_amb_mode)
self.amb_action.setShortcut("Ctrl+B")

Expand Down Expand Up @@ -580,11 +590,28 @@ def set_settings(self, event):
)
@click.option("--active_learning", "-a", is_flag=True, help="Active learning mode")
@click.option("--open-settings", "-s", is_flag=True, help="Open settings window")
@click.option("--config_file", "-c", default="config.yaml", help="The config file path")
@click.option("--backup-dir", "-b", default=None, help="The directory where backups are saved")
@click.option("--backup-interval", default=30, type=int, help="The interval between backups, in minutes")
def main(video, multiview, dev, active_learning, open_settings, config_file, backup_dir, backup_interval):
@click.option("--config_file", "-c", default=None, help="The config file path")
@click.option(
"--backup-dir", "-b", default=None, help="The directory where backups are saved"
)
@click.option(
"--backup-interval",
default=30,
type=int,
help="The interval between backups, in minutes",
)
def main(
video,
multiview,
dev,
active_learning,
open_settings,
config_file,
backup_dir,
backup_interval,
):
app = QApplication(sys.argv)
app.setAttribute(Qt.AA_UseHighDpiPixmaps)

window = MainWindow(
videos=video,
Expand Down
12 changes: 9 additions & 3 deletions cluster.py → dlc2action_annotation/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from itertools import groupby
from typing import Iterable

import annotator
import click
import numpy as np
import pyqtgraph as pg
Expand All @@ -36,16 +37,21 @@
)
from sklearn import datasets, decomposition, manifold
from vispy.scene import SceneCanvas

import annotator
from utils import get_color, get_settings, read_skeleton, read_stack, read_video
from widgets.dialog import (
EpisodeParamsSelector,
EpisodeSelector,
SuggestionParamsSelector,
)
from widgets.viewbox import VideoViewBox

from dlc2action_annotation.utils import (
get_color,
get_settings,
read_skeleton,
read_stack,
read_video,
)


class Annotation:
def __init__(self, filename):
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
#
import os
import pickle
import click
from collections import defaultdict

import click
from matplotlib import pyplot as plt


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
#
# This project and all its files are licensed under GNU AGPLv3 or later version. A copy is included in https://github.com/AlexEMG/DLC2action/LICENSE.AGPL.
#
from PIL import Image
import numpy as np
import pickle
from collections import defaultdict

import click
import dask.array as da
import numpy as np
from dask import delayed
from pims import PyAVReaderIndexed
import click
from collections import defaultdict
from matplotlib import pyplot as plt
from PIL import Image
from pims import PyAVReaderIndexed


def load_labels(labels_file):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
#
# This project and all its files are licensed under GNU AGPLv3 or later version. A copy is included in https://github.com/AlexEMG/DLC2action/LICENSE.AGPL.
#
import os
import pickle
import pandas as pd

import click
import numpy as np
import os
import pandas as pd
from tqdm import tqdm
import click


class FileTransformer:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
#
# This project and all its files are licensed under GNU AGPLv3 or later version. A copy is included in https://github.com/AlexEMG/DLC2action/LICENSE.AGPL.
#
import re
import math
import pandas as pd
import re
from optparse import OptionParser

import pandas as pd

"""This script can be used to split and downsample larger videos into smaller files that
are loaded faster"""

length_regexp = "Duration: (\d{2}):(\d{2}):(\d{2})\.\d+,"
re_length = re.compile(length_regexp)

from subprocess import check_call, PIPE, Popen
import shlex
from subprocess import PIPE, Popen, check_call


def main():
Expand Down Expand Up @@ -130,7 +131,6 @@ def parse_options():
options.skeleton_file = None

if options.filename and options.split_size and options.ds and options.fps:

return (
options.filename,
options.split_size,
Expand Down
File renamed without changes
Binary file added dlc2action_annotation/img/horizontal_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading