Visitar URL original
DLC 2.0.5! · sachaker/DeepLabCut@857cb1f · GitHub
Skip to content

Commit 857cb1f

Browse files
committed
DLC 2.0.5!
1 parent 7bcf276 commit 857cb1f

28 files changed

Lines changed: 1776 additions & 335 deletions

‎README.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Please check out [www.mousemotorlab.org/deeplabcut](https://www.mousemotorlab.or
3434
</p>
3535

3636
# [DEMO the code](/examples)
37-
- We provide several Jupyter Notebooks: one that walks you through a demo dataset to test your installation, and another Notebook to run DeepLabCut from the begining on your own data. We also show you how to use the code in Docker, and on Google Colab. Please also read the [user-guide] prepint!(https://www.biorxiv.org/content/early/2018/11/24/476531)
37+
- We provide several Jupyter Notebooks: one that walks you through a demo dataset to test your installation, and another Notebook to run DeepLabCut from the begining on your own data. We also show you how to use the code in Docker, and on Google Colab. Please also read the [user-guide preprint!](https://www.biorxiv.org/content/early/2018/11/24/476531)
3838

3939
# News (and in the news):
4040

@@ -71,13 +71,13 @@ importing a project into the new data format for DLC 2.0
7171

7272
## Code contributors:
7373

74-
[Alexander Mathis](https://github.com/AlexEMG), [Tanmay Nath](http://www.mousemotorlab.org/team), [Mackenzie Mathis](https://github.com/MMathisLab), and especially the authors of DeeperCut authors for the feature detector code. The feature detector code is based on Eldar Insafutdinov's TensorFlow implementation of [DeeperCut](https://github.com/eldar/pose-tensorflow). DeepLabCut is an open-source tool and has benefited from suggestions and edits by many individuals including Richard Warren, Ronny Eichler, Jonas Rauber, Hao Wu, Federico Claudi, Taiga Abe, and Jonny Saunders as well as the [contributors](https://github.com/AlexEMG/DeepLabCut/graphs/contributors). In particular, the authors thank Ronny Eichler for input on the modularized version. We are also grateful to all the beta testers!
74+
[Alexander Mathis](https://github.com/AlexEMG), [Tanmay Nath](http://www.mousemotorlab.org/team), [Mackenzie Mathis](https://github.com/MMathisLab). The feature detector code is based on Eldar Insafutdinov's TensorFlow implementation of [DeeperCut](https://github.com/eldar/pose-tensorflow). DeepLabCut is an open-source tool and has benefited from suggestions and edits by many individuals including Richard Warren, Ronny Eichler, Jonas Rauber, Hao Wu, Federico Claudi, Gary Kane, Taiga Abe, and Jonny Saunders as well as the [contributors](https://github.com/AlexEMG/DeepLabCut/graphs/contributors). In particular, the authors thank Ronny Eichler for input on the modularized version.
7575

76-
This is an actively developed package and we welcome community development and involvement!
76+
This is an actively developed package and we welcome community development and involvement.
7777

78-
For **help and questions that don't fit a GitHub code issue,** we ask you to post in https://forum.image.sc/
78+
For **help and questions that don't fit a GitHub code issue,** we ask you to post them here: https://forum.image.sc/
7979

80-
If you would like to join the [development community](https://deeplabcut.slack.com), please drop us a note to be invited by emailing: mackenzie@post.harvard.edu
80+
If you would like to join the [code development community](https://deeplabcut.slack.com), please drop us a note to be invited by emailing: mackenzie@post.harvard.edu
8181

8282
Please check out the following references for more details:
8383

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# dlc-macOS-CPU.yaml
2+
#
3+
# DeepLabCut environment for MacOS (tested on Mojave)
4+
#
5+
# install: conda env create -f dlc-macOS-CPU.yaml
6+
# update: conda env update -f dlc-macOS-CPU.yaml
7+
8+
9+
name: dlc-macOS-CPU
10+
channels:
11+
- defaults
12+
dependencies:
13+
- _tflow_select=2.3.0=mkl
14+
- absl-py=0.7.0=py36_0
15+
- astor=0.7.1=py36_0
16+
- blas=1.0=mkl
17+
- c-ares=1.15.0=h1de35cc_1
18+
- ca-certificates=2018.12.5=0
19+
- certifi=2018.11.29=py36_0
20+
- gast=0.2.2=py36_0
21+
- grpcio=1.16.1=py36h044775b_1
22+
- h5py=2.9.0=py36h3134771_0
23+
- hdf5=1.10.4=hfa1e0ec_0
24+
- intel-openmp=2019.1=144
25+
- keras-applications=1.0.6=py36_0
26+
- keras-preprocessing=1.0.5=py36_0
27+
- libcxx=4.0.1=hcfea43d_1
28+
- libcxxabi=4.0.1=hcfea43d_1
29+
- libedit=3.1.20181209=hb402a30_0
30+
- libffi=3.2.1=h475c297_4
31+
- libgfortran=3.0.1=h93005f0_2
32+
- libprotobuf=3.6.1=hd9629dc_0
33+
- markdown=3.0.1=py36_0
34+
- mkl=2019.1=144
35+
- mkl_fft=1.0.10=py36h5e564d8_0
36+
- mkl_random=1.0.2=py36h27c97d8_0
37+
- ncurses=6.1=h0a44026_1
38+
- numpy=1.15.4=py36hacdab7b_0
39+
- numpy-base=1.15.4=py36h6575580_0
40+
- openssl=1.1.1a=h1de35cc_0
41+
- pip=18.1=py36_0
42+
- protobuf=3.6.1=py36h0a44026_0
43+
- python=3.6.8=haf84260_0
44+
- python.app=2=py36_9
45+
- readline=7.0=h1de35cc_5
46+
- scipy=1.2.0=py36h1410ff5_0
47+
- setuptools=40.6.3=py36_0
48+
- six=1.12.0=py36_0
49+
- sqlite=3.26.0=ha441bb4_0
50+
- tensorboard=1.12.2=py36haf313ee_0
51+
- tensorflow=1.12.0=mkl_py36h2b2bbaf_0
52+
- tensorflow-base=1.12.0=mkl_py36h70e0e9a_0
53+
- termcolor=1.1.0=py36_1
54+
- tk=8.6.8=ha441bb4_0
55+
- werkzeug=0.14.1=py36_0
56+
- wheel=0.32.3=py36_0
57+
- xz=5.2.4=h1de35cc_4
58+
- zlib=1.2.11=h1de35cc_3
59+
- pip:
60+
- appnope==0.1.0
61+
- chardet==3.0.4
62+
- click==7.0
63+
- cloudpickle==0.7.0
64+
- cycler==0.10.0
65+
- dask==1.1.0
66+
- decorator==4.3.2
67+
- deeplabcut
68+
- easydict==1.9
69+
- idna==2.8
70+
- imageio==2.3.0
71+
- ipython==6.0.0
72+
- ipython-genutils==0.2.0
73+
- jedi==0.13.2
74+
- kiwisolver==1.0.1
75+
- matplotlib
76+
- mock==2.0.0
77+
- moviepy==0.2.3.5
78+
- networkx==2.2
79+
- numexpr==2.6.9
80+
- opencv-python==3.4.5.20
81+
- pandas==0.20.3
82+
- parso==0.3.2
83+
- patsy==0.5.1
84+
- pbr==5.1.1
85+
- pexpect==4.6.0
86+
- pickleshare==0.7.5
87+
- pillow==5.4.1
88+
- prompt-toolkit==1.0.15
89+
- ptyprocess==0.6.0
90+
- pygments==2.3.1
91+
- pyparsing==2.3.1
92+
- python-dateutil==2.7.3
93+
- pytz==2018.9
94+
- pywavelets==1.0.1
95+
- pyyaml==4.2b4
96+
- requests==2.21.0
97+
- ruamel.yaml==0.15.0
98+
- scikit-image==0.14.2
99+
- scikit-learn==0.19.2
100+
- simplegeneric==0.8.1
101+
- statsmodels==0.9.0
102+
- tables==3.4.3
103+
- toolz==0.9.0
104+
- tqdm==4.30.0
105+
- traitlets==4.3.2
106+
- urllib3==1.24.1
107+
- wcwidth==0.1.7
108+
- wxpython==4.0.4
109+
prefix: /anaconda3/envs/dlc-macOS-CPU
110+

‎conda-environments/dlc-windowsCPU.yaml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
name: dlc-windowsCPU
99
dependencies:
1010
- python=3.6
11+
- msvc_runtime
12+
- jupyter
1113
- tensorflow==1.12
1214
- wxpython
13-
- jupyter
1415
- pytables==3.4.3 #problem with 3.4.4
1516
- pip:
1617
- deeplabcut

‎conda-environments/dlc-windowsGPU.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
name: dlc-windowsGPU
1111
dependencies:
1212
- python=3.6
13+
- msvc_runtime
1314
- tensorflow-gpu==1.12
1415
- cudnn=7
1516
- wxpython

‎deeplabcut/__init__.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"""
1010

1111
import os
12+
import platform
1213
# Supress tensorflow warning messages
1314
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
1415

@@ -20,6 +21,13 @@
2021
if os.environ.get('DLClight', default=False) == 'True':
2122
mpl.use('AGG') #anti-grain geometry engine #https://matplotlib.org/faq/usage_faq.html
2223
pass
24+
elif platform.system() == 'Darwin':
25+
mpl.use('WXAgg')
26+
from deeplabcut import generate_training_dataset
27+
from deeplabcut import refine_training_dataset
28+
# Direct import for convenience
29+
from deeplabcut.generate_training_dataset import label_frames, dropannotationfileentriesduetodeletedimages, comparevideolistsanddatafolders, adddatasetstovideolistandviceversa, dropduplicatesinannotatinfiles
30+
from deeplabcut.refine_training_dataset import refine_labels
2331
else:
2432
mpl.use('TkAgg')
2533
from deeplabcut import generate_training_dataset

‎deeplabcut/create_project/add.py‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,21 @@ def add_new_videos(config,videos,copy_videos=False,coords=None):
6262

6363
destinations = [video_path.joinpath(vp.name) for vp in videos]
6464
if copy_videos==True:
65-
print("Copying the videos")
6665
for src, dst in zip(videos, destinations):
67-
shutil.copy(os.fspath(src),os.fspath(dst))
66+
if dst.exists():
67+
pass
68+
else:
69+
print("Copying the videos")
70+
shutil.copy(os.fspath(src),os.fspath(dst))
6871
else:
69-
print("Creating the symbolic link of the video")
7072
for src, dst in zip(videos, destinations):
71-
if dst.exists() and not DEBUG:
72-
raise FileExistsError('Video {} exists already!'.format(dst))
73-
try:
73+
if dst.exists():
74+
pass
75+
else:
76+
print("Creating the symbolic link of the video")
7477
src = str(src)
7578
dst = str(dst)
7679
os.symlink(src, dst)
77-
except shutil.SameFileError:
78-
if not DEBUG:
79-
raise
8080

8181
if copy_videos==True:
8282
videos=destinations # in this case the *new* location should be added to the config file

‎deeplabcut/create_project/new.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def create_new_project(project, experimenter, videos, working_directory=None, co
170170
cfg_file['pcutoff']=0.1
171171
cfg_file['dotsize']=12 #for plots size of dots
172172
cfg_file['alphavalue']=0.7 #for plots transparency of markers
173-
cfg_file['colormap']='hsv' #for plots type of colormap
173+
cfg_file['colormap']='jet' #for plots type of colormap
174174

175175
projconfigfile=os.path.join(str(project_path),'config.yaml')
176176
# Write dictionary to yaml config file

‎deeplabcut/generate_training_dataset/auxfun_drag_label.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ def on_press(self, event):
6565
To remove a predicted label. Internally, the coordinates of the selected predicted label is replaced with nan. The user needs to right click for the event.After right
6666
click the data point is removed from the plot.
6767
"""
68-
msg = wx.MessageBox('Do you want to remove %s ? You cannot undo this step!'%self.bodyParts, 'Remove!', wx.YES_NO | wx.ICON_WARNING)
68+
msg = wx.MessageBox('Do you want to remove the label %s ?'%self.bodyParts, 'Remove!', wx.YES_NO | wx.ICON_WARNING)
6969
if msg == 2:
7070
self.press = None
7171
DraggablePoint.lock = None
7272
self.point.set_animated(False)
7373
self.background = None
74-
self.final_point = (np.nan,np.nan)
74+
self.final_point = (np.nan,np.nan,self.bodyParts)
7575
self.point.center = (np.nan,np.nan)
7676
self.coords.append(self.final_point)
7777
self.point.figure.canvas.draw()
@@ -121,6 +121,7 @@ def on_hover(self,event):
121121
if contains:
122122
self.annot.xy = (self.point.center[0],self.point.center[1])
123123
text = str(self.bodyParts)
124+
# text = str(self.individual_names+','+self.bodyParts)
124125
self.annot.set_text(text)
125126
self.annot.get_bbox_patch().set_alpha(0.4)
126127
self.annot.set_visible(True)
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
"""
2+
DeepLabCut2.0 Toolbox
3+
https://github.com/AlexEMG/DeepLabCut
4+
A Mathis, alexander.mathis@bethgelab.org
5+
T Nath, nath@rowland.harvard.edu
6+
M Mathis, mackenzie@post.harvard.edu
7+
8+
"""
9+
10+
"""
11+
Class to drag,annotate and remove the data points. Use left click to drag the data points
12+
around. Use right click to remove any unwanted data points. Internally the corresponding data
13+
point is set to nan. When the user hovers the mouse over any data point, each data point is annotated with the labels and its corresponding likelihood. These annotations also move with the drag!
14+
"""
15+
16+
17+
import numpy as np
18+
import wx
19+
20+
class DraggablePoint:
21+
lock = None #only one can be animated at a time
22+
def __init__(self, point,individual_names,bodyParts):
23+
# def __init__(self, point,bodyParts):
24+
self.point = point
25+
self.bodyParts = bodyParts
26+
self.individual_names = individual_names
27+
# self.likelihood = likelihood
28+
self.press = None
29+
self.background = None
30+
self.final_point = (0.0, 0.0)
31+
self.annot = self.point.axes.annotate("", xy=(0,0), xytext=(20,20),textcoords="offset points",bbox=dict(boxstyle="round", fc="w"),arrowprops=dict(arrowstyle="->"))
32+
self.annot.set_visible(False)
33+
self.coords = []
34+
35+
36+
def connect(self):
37+
'connect to all the events we need'
38+
# self.coords = [0,0]
39+
self.cidpress = self.point.figure.canvas.mpl_connect('button_press_event', self.on_press)
40+
self.cidrelease = self.point.figure.canvas.mpl_connect('button_release_event', self.on_release)
41+
self.cidmotion = self.point.figure.canvas.mpl_connect('motion_notify_event', self.on_motion)
42+
self.cidhover = self.point.figure.canvas.mpl_connect("motion_notify_event", self.on_hover)
43+
44+
def on_press(self, event):
45+
"""
46+
Define the event for the button press!
47+
"""
48+
if event.inaxes != self.point.axes: return
49+
if DraggablePoint.lock is not None: return
50+
contains, attrd = self.point.contains(event)
51+
if not contains: return
52+
if event.button == 1:
53+
"""
54+
This button press corresponds to the left click
55+
"""
56+
self.press = (self.point.center), event.xdata, event.ydata
57+
DraggablePoint.lock = self
58+
canvas = self.point.figure.canvas
59+
axes = self.point.axes
60+
self.point.set_animated(True)
61+
canvas.draw()
62+
self.background = canvas.copy_from_bbox(self.point.axes.bbox)
63+
axes.draw_artist(self.point)
64+
canvas.blit(axes.bbox)
65+
elif event.button == 2:
66+
"""
67+
To remove a predicted label. Internally, the coordinates of the selected predicted label is replaced with nan. The user needs to right click for the event.After right
68+
click the data point is removed from the plot.
69+
"""
70+
msg = wx.MessageBox('Do you want to remove the label %s ?'%self.bodyParts, 'Remove!', wx.YES_NO | wx.ICON_WARNING)
71+
if msg == 2:
72+
self.press = None
73+
DraggablePoint.lock = None
74+
self.point.set_animated(False)
75+
self.background = None
76+
self.final_point = (np.nan,np.nan,self.individual_names,self.bodyParts)
77+
self.point.center = (np.nan,np.nan)
78+
self.coords.append(self.final_point)
79+
self.point.figure.canvas.draw()
80+
81+
82+
def on_motion(self, event):
83+
"""
84+
During the drag!
85+
"""
86+
if DraggablePoint.lock is not self:
87+
return
88+
if event.inaxes != self.point.axes: return
89+
90+
if event.button == 1:
91+
self.point.center, xpress, ypress = self.press
92+
dx = event.xdata - xpress
93+
dy = event.ydata - ypress
94+
self.point.center = (self.point.center[0]+dx, self.point.center[1]+dy)
95+
canvas = self.point.figure.canvas
96+
axes = self.point.axes
97+
# restore the background region
98+
canvas.restore_region(self.background)
99+
axes.draw_artist(self.point)
100+
canvas.blit(axes.bbox)
101+
102+
def on_release(self, event):
103+
'on release we reset the press data'
104+
if DraggablePoint.lock is not self:
105+
return
106+
if event.button == 1:
107+
self.press = None
108+
DraggablePoint.lock = None
109+
self.point.set_animated(False)
110+
self.background = None
111+
self.point.figure.canvas.draw()
112+
self.final_point = (event.xdata, event.ydata,self.individual_names,self.bodyParts)
113+
self.coords.append(self.final_point)
114+
115+
def on_hover(self,event):
116+
"""
117+
Annotate the lables and likelihood when the user hovers over the data points.
118+
"""
119+
vis = self.annot.get_visible()
120+
121+
if event.inaxes == self.point.axes:
122+
contains, attrd = self.point.contains(event)
123+
if contains:
124+
self.annot.xy = (self.point.center[0],self.point.center[1])
125+
# text = str(self.bodyParts)
126+
text = str(self.individual_names+','+self.bodyParts)
127+
self.annot.set_text(text)
128+
self.annot.get_bbox_patch().set_alpha(0.4)
129+
self.annot.set_visible(True)
130+
self.point.figure.canvas.draw_idle()
131+
else:
132+
if vis:
133+
self.annot.set_visible(False)
134+
135+
136+
def disconnect(self):
137+
'disconnect all the stored connection ids'
138+
self.point.figure.canvas.mpl_disconnect(self.cidpress)
139+
self.point.figure.canvas.mpl_disconnect(self.cidrelease)
140+
self.point.figure.canvas.mpl_disconnect(self.cidmotion)
141+
self.point.figure.canvas.mpl_disconnect(self.cidhover)
142+
self.point.figure.canvas.mpl_disconnect(self.cidkey)

0 commit comments

Comments
 (0)