Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ntabris committed Jun 26, 2020
2 parents de0ed9a + 46e60e0 commit e3846f9
Show file tree
Hide file tree
Showing 40 changed files with 2,865 additions and 595 deletions.
2 changes: 1 addition & 1 deletion .conda/bld.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ rem # this out myself, ughhh.
set PIP_NO_INDEX=False
set PIP_NO_DEPENDENCIES=False
set PIP_IGNORE_INSTALLED=False
pip install cattrs==1.0.0rc0 opencv-python-headless==4.2.0.34 "PySide2>=5.12.0,<=5.14.1" imgaug==0.3.0 qimage2ndarray==1.8 imgstore==0.2.9 jsmin seaborn scikit-video
pip install scipy==1.4.1 cattrs==1.0.0rc0 opencv-python-headless==4.2.0.34 "PySide2>=5.12.0,<=5.14.1" imgaug==0.3.0 qimage2ndarray==1.8 imgstore==0.2.9 jsmin seaborn scikit-video pykalman==0.9.5
pip install

rem # Use and update environment.yml call to install pip dependencies. This is slick.
Expand Down
2 changes: 1 addition & 1 deletion .conda/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export PIP_NO_INDEX=False
export PIP_NO_DEPENDENCIES=False
export PIP_IGNORE_INSTALLED=False

pip install cattrs==1.0.0rc0 opencv-python-headless==4.2.0.34 "PySide2>=5.12.0,<=5.14.1" imgaug==0.3.0 qimage2ndarray==1.8 imgstore==0.2.9 jsmin seaborn scikit-video
pip install scipy==1.4.1 cattrs==1.0.0rc0 opencv-python-headless==4.2.0.34 "PySide2>=5.12.0,<=5.14.1" imgaug==0.3.0 qimage2ndarray==1.8 imgstore==0.2.9 jsmin seaborn scikit-video pykalman==0.9.5
#pip install tensorflow==2.1

pip install setuptools-scm
Expand Down
1 change: 1 addition & 0 deletions .conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ requirements:
run:
- python=3.6
- numpy>=1.16
- scipy<=1.4.1
- attrs=19.3
- jsonpickle=1.2
- networkx
Expand Down
2 changes: 2 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies:
- python-rapidjson
- pip
- pip:
- scipy==1.4.1
- opencv-python-headless==4.2.0.34
- PySide2>=5.12.0,<=5.14.1
- imgaug==0.3.0
Expand All @@ -28,5 +29,6 @@ dependencies:
- jsmin
- seaborn
- scikit-video
- pykalman==0.9.5
- "--editable=./"
- "--requirement=./dev_requirements.txt"
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ PySide2>=5.12.0,<=5.14.1
pyzmq
pyyaml
imgaug==0.3.0
scipy<=1.4.1
scikit-image
scikit-learn
scikit-video
imgstore==0.2.9
qimage2ndarray==1.8
jsmin
seaborn
pykalman==0.9.5
2 changes: 1 addition & 1 deletion sleap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Import submodules we want available at top-level
from sleap.io.dataset import Labels
from sleap.io.video import Video
from sleap.instance import LabeledFrame, Instance, PredictedInstance
from sleap.instance import LabeledFrame, Instance, PredictedInstance, Track
from sleap.skeleton import Skeleton
import sleap.nn

Expand Down
96 changes: 88 additions & 8 deletions sleap/config/pipeline_form.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,28 @@ inference:
none:

flow:
- type: text
text: '<b>Pre-tracker data cleaning</b>:'
- name: tracking.target_instance_count
label: Target Number of Instances Per Frame
type: optional_int
none_label: No target
default_disabled: true
range: 1,10
default: 1
- name: tracking.pre_cull_to_target
label: Cull to Target Instance Count
type: bool
default: false
- name: tracking.pre_cull_iou_threshold
label: Cull using IoU Threshold
type: double
default: 0.8
- type: text
text: '<b>Tracking with optical flow</b>:<br />
This tracker "shifts" instances from previous frames using optical flow
before matching instances in each frame to the <i>shifted</i> instances from
prior frames.'
- name: tracking.similarity
label: Similarity Method
type: list
Expand All @@ -249,12 +271,50 @@ inference:
label: Elapsed Frame Window
type: int
default: 5
- name: tracking.clean_instance_count
label: Target Number of Tracks (0 for all)
type: int
default: 0
- type: text
text: '<b>Kalman filter-based tracking</b>:<br />
Uses the above tracking options to track instances for an initial
number of frames, then initializes Kalman filters which are used to track
instances on subsequent frames.'
- name: tracking.kf_init_frame_count
label: Enable Filters after Initial Frames
type: optional_int
none_label: Don't use filters
default_disabled: true
default: 10
- name: tracking.kf_node_indices
label: Nodes to use for Tracking
type: string
default: 0,1,2
- type: text
text: '<b>Post-tracker data cleaning</b>:'
- name: tracking.post_connect_single_breaks
label: Connect Single Track Breaks
type: bool
default: false

simple:
- type: text
text: '<b>Pre-tracker data cleaning</b>:'
- name: tracking.target_instance_count
label: Target Number of Instances Per Frame
type: optional_int
none_label: No target
default_disabled: true
range: 1,10
default: 1
- name: tracking.pre_cull_to_target
label: Cull to Target Instance Count
type: bool
default: false
- name: tracking.pre_cull_iou_threshold
label: Cull using IoU Threshold
type: double
default: 0.8
- type: text
text: '<b>Tracking</b>:<br />
This tracker assigns track identities by matching instances from prior
frames to instances on subsequent frames.'
- name: tracking.similarity
label: Similarity Method
type: list
Expand All @@ -269,10 +329,30 @@ inference:
label: Elapsed Frame Window
type: int
default: 5
- name: tracking.clean_instance_count
label: Target Number of Tracks (0 for all)
type: int
default: 0
- type: text
text: '<b>Kalman filter-based tracking</b>:<br />
Uses the above tracking options to track instances for an initial
number of frames, then initializes Kalman filters which are used to track
instances on subsequent frames.'
- name: tracking.kf_init_frame_count
label: Enable Filters after Initial Frames
type: optional_int
none_label: Don't use filters
default_disabled: true
default: 10
- name: tracking.kf_node_indices
label: Nodes to use for Tracking
type: string
default: 0,1,2
- type: text
text: '<b>Post-tracker data cleaning</b>:'
- name: tracking.post_connect_single_breaks
label: Connect Single Track Breaks
type: bool
default: false




- name: _predict_frames
label: Predict On
Expand Down
17 changes: 11 additions & 6 deletions sleap/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import os
import random

from typing import Callable, List, Optional
from typing import Callable, List, Optional, Tuple

from PySide2 import QtCore, QtGui
from PySide2.QtCore import Qt, QEvent
Expand Down Expand Up @@ -104,7 +104,8 @@ def setWindowTitle(self, value):
"""Sets window title (if value is not None)."""
if value is not None:
super(MainWindow, self).setWindowTitle(
f"{value} - SLEAP Label v{sleap.version.__version__}")
f"{value} - SLEAP Label v{sleap.version.__version__}"
)

def event(self, e: QEvent) -> bool:
"""Custom event handler.
Expand Down Expand Up @@ -433,6 +434,7 @@ def prev_vid():
"Point Score (sum)",
"Point Score (min)",
"Number of predicted points",
"Min Centroid Proximity",
)

add_submenu_choices(
Expand Down Expand Up @@ -1186,6 +1188,7 @@ def setSeekbarHeader(self, graph_name):
"Point Score (sum)": data_obj.get_point_score_series,
"Point Score (min)": data_obj.get_point_score_series,
"Number of predicted points": data_obj.get_point_count_series,
"Min Centroid Proximity": data_obj.get_min_centroid_proximity_series,
}

if graph_name == "None":
Expand Down Expand Up @@ -1228,11 +1231,13 @@ def remove_user_labeled(video, frame_idxs):

# Use negative number in list for range (i.e., "0,-123" means "0-123")
# The ranges should be [X, Y) like standard Python ranges
def encode_range(a: int, b: int) -> Tuple[int, int]:
return a, -b

clip_range = self.state.get("frame_range", default=(0, 0))
if clip_range[1] > 0:
clip_range = (clip_range[0], -clip_range[1])
selection["clip"] = {current_video: clip_range}
selection["video"] = {current_video: (0, -current_video.num_frames)}

selection["clip"] = {current_video: encode_range(*clip_range)}
selection["video"] = {current_video: encode_range(0, current_video.num_frames)}

selection["suggestions"] = {
video: remove_user_labeled(video, self.labels.get_video_suggestions(video))
Expand Down
12 changes: 9 additions & 3 deletions sleap/gui/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from sleap.util import get_config_file
from sleap.instance import Instance, Track, Node
from sleap.io.dataset import Labels
from sleap.prefs import prefs


class ColorManager(object):
Expand Down Expand Up @@ -36,9 +37,14 @@ def __init__(self, labels: Labels = None, palette: str = "standard"):
self.set_palette(palette)

self.uncolored_prediction_color = (250, 250, 10)
self.default_pen_width = 1
self.medium_pen_width = 1.5
self.thick_pen_width = 3

if prefs["bold lines"]:
self.thick_pen_width = 6
else:
self.thick_pen_width = 3

self.medium_pen_width = self.thick_pen_width // 2
self.default_pen_width = max(1, self.thick_pen_width // 4)

@property
def labels(self):
Expand Down
10 changes: 9 additions & 1 deletion sleap/gui/dialogs/formbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,11 @@ def add_item(self, item: Dict[str, Any]):
elif item["default"] is not None and item["default"] > 100:
min, max = 0, item["default"] * 10
field.setRange(min, max)

field.setValue(item["default"])
if item.get("default_disabled", False):
field.setToNone()

field.valueChanged.connect(lambda: self.valueChanged.emit())

# bool: show checkbox
Expand Down Expand Up @@ -684,15 +688,19 @@ def isNoneVal(self, val) -> bool:
return True
return False

@property
def noneVal(self):
if self.none_string.lower() in ("", "none"):
return None
else:
return self.none_string

def setToNone(self):
self.setValue(self.noneVal)

def value(self):
if self.check_widget.isChecked():
return self.noneVal()
return self.noneVal
return self.spin_widget.value()

def setValue(self, val):
Expand Down
Loading

0 comments on commit e3846f9

Please sign in to comment.