Skip to content

Commit

Permalink
DLC 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexEMG committed Oct 6, 2019
1 parent e3cb6a9 commit ca93b3e
Show file tree
Hide file tree
Showing 74 changed files with 5,385 additions and 938 deletions.
14 changes: 12 additions & 2 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ E Insafutdinov and co-authors of DeeperCut (see README) for feature detectors: h
was adapted from: https://github.com/eldar/pose-tensorflow

Products:
DeepLabCut: markerless pose estimation of user-defined body parts with deep learning. Nature Neuroscience 2018. DOI
DeepLabCut: markerless pose estimation of user-defined body parts with deep learning. Nature Neuroscience, 2018.
https://doi.org/10.1038/s41593-018-0209-y
A. Mathis, P. Mamidanna, K.M. Cury, T. Abe, V.N. Murthy, M.W. Mathis* & M. Bethge*

Expand All @@ -40,7 +40,8 @@ T Nath, [email protected] | https://github.com/meet10may
M Mathis, [email protected] | https://github.com/MMathisLab

Products:
Using DeepLabCut for 3D markerless pose estimation across species and behaviors. Nature Protocols, 2019 (in press)
Using DeepLabCut for 3D markerless pose estimation across species and behaviors. Nature Protocols, 2019.
https://www.nature.com/articles/s41596-019-0176-0
T. Nath*, A. Mathis*, AC. Chen, A. Patel, M. Bethge, M. Mathis

Contributions:
Expand All @@ -52,3 +53,12 @@ Formal analysis: ACC, AM and AP analyzed the cheetah data.
Writing: MWM, AM and TN with inputs from all authors.

############################################################################################################

DeepLabCut 2.1 additions
A Mathis, [email protected] | https://github.com/AlexEMG/DeepLabCut
T Nath, [email protected] | https://github.com/meet10may
M Mathis, [email protected] | https://github.com/MMathisLab

Preprint:
Pretraining boosts out-of-domain robustness for pose estimation
A. Mathis, M. Yüksekgönül, B. Rogers, M. Bethge, M. Mathis
54 changes: 33 additions & 21 deletions README.md

Large diffs are not rendered by default.

174 changes: 8 additions & 166 deletions conda-environments/dlc-ubuntu-GPU.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,174 +15,16 @@

name: dlc-ubuntu-GPU
channels:
- conda-forge
- anaconda-fusion
- defaults
dependencies:
- _tflow_select=2.1.0=gpu
- absl-py=0.7.1=py36_0
- asn1crypto=0.24.0=py36_1003
- astor=0.7.1=py_0
- atk=2.32.0=haf93ef1_0
- backcall=0.1.0=py_0
- blas=1.1=openblas
- blosc=1.16.3=he1b5a44_1
- bzip2=1.0.6=h14c3975_1002
- c-ares=1.15.0=h14c3975_1001
- ca-certificates=2019.6.16=hecc5488_0
- cairo=1.16.0=h18b612c_1001
- certifi=2019.6.16=py36_0
- cffi=1.12.3=py36h8022711_0
- chardet=3.0.4=py36_1003
- click=7.0=py_0
- cloudpickle=1.2.1=py_0
- cryptography=2.5=py36hb7f436b_1
- cudatoolkit=10.0.130=0
- cudnn=7.6.0=cuda10.0_0
- cupti=10.0.130=0
- cycler=0.10.0=py_1
- cytoolz=0.9.0.1=py36h14c3975_1001
- dask-core=2.0.0=py_0
- dbus=1.13.6=he372182_0
- decorator=4.4.0=py_0
- easydict=1.9=py_0
- expat=2.2.5=he1b5a44_1003
- ffmpeg=4.1.3=h167e202_0
- fontconfig=2.13.1=he4413a7_1000
- freetype=2.10.0=he983fc9_0
- gast=0.2.2=py_0
- gdk-pixbuf=2.36.12=h7a26e22_1003
- gettext=0.19.8.1=hc5be6a0_1002
- glib=2.58.3=h6f030ca_1001
- gmp=6.1.2=hf484d3e_1000
- gnutls=3.6.5=hd3a4fd2_1002
- gobject-introspection=1.58.2=py36h5503ade_1001
- graphite2=1.3.13=hf484d3e_1000
- grpcio=1.16.0=py36h4f00d22_1000
- gst-plugins-base=1.14.5=h0935bb2_0
- gstreamer=1.14.5=h36ae1b5_0
- gtk2=2.24.31=h4934977_1002
- h5py=2.9.0=nompi_py36hf008753_1102
- harfbuzz=2.4.0=h37c48d4_1
- hdf5=1.10.4=nompi_h3c11f04_1106
- icu=58.2=hf484d3e_1000
- idna=2.8=py36_1000
- imageio=2.3.0=py_1
- ipython_genutils=0.2.0=py_1
- jedi=0.14.0=py36_0
- jpeg=9c=h14c3975_1001
- keras-applications=1.0.7=py_1
- keras-preprocessing=1.0.9=py_1
- kiwisolver=1.1.0=py36hc9558a2_0
- lame=3.100=h14c3975_1001
- libblas=3.8.0=5_h6e990d7_netlib
- libcblas=3.8.0=5_h6e990d7_netlib
- libedit=3.1.20170329=hf8c457e_1001
- libffi=3.2.1=he1b5a44_1006
- libgcc-ng=9.1.0=hdf63c60_0
- libgfortran=3.0.0=1
- libgfortran-ng=7.3.0=hdf63c60_0
- libglu=9.0.0=hf484d3e_1000
- libiconv=1.15=h516909a_1005
- liblapack=3.8.0=5_h6e990d7_netlib
- libopenblas=0.2.20=h9ac9557_7
- libpng=1.6.37=hed695b0_0
- libprotobuf=3.8.0=h8b12597_0
- libstdcxx-ng=9.1.0=hdf63c60_0
- libtiff=4.0.10=h57b8799_1003
- libuuid=2.32.1=h14c3975_1000
- libxcb=1.13=h14c3975_1002
- libxml2=2.9.9=h13577e0_0
- lz4-c=1.8.3=he1b5a44_1001
- lzo=2.10=h14c3975_1000
- markdown=2.6.11=py_0
- matplotlib=3.0.3=py36_1
- matplotlib-base=3.0.3=py36h5f35d83_1
- mock=3.0.5=py36_0
- moviepy=0.2.3.5=py_0
- ncurses=6.1=hf484d3e_1002
- nettle=3.4.1=h1bed415_1002
- networkx=2.3=py_0
- numexpr=2.6.9=py36h637b7d7_1000
- numpy=1.14.5=py36_blas_openblashd3ea46f_202
- numpy-base=1.14.3=py36h2b20989_0
- olefile=0.46=py_0
- openblas=0.2.20=8
- openh264=1.8.0=hdbcaa40_1000
- openssl=1.0.2r=h14c3975_0
- pandas=0.21.0=py36_0
- pango=1.40.14=he7ab937_1005
- parso=0.5.0=py_0
- pathlib2=2.3.4=py36_0
- patsy=0.5.1=py_0
- pcre=8.41=hf484d3e_1003
- pexpect=4.7.0=py36_0
- pickleshare=0.7.5=py36_1000
- pillow=6.0.0=py36he7afcd5_0
- pip=19.1.1=py36_0
- pixman=0.38.0=h516909a_1003
- prompt_toolkit=1.0.15=py_1
- protobuf=3.8.0=py36he1b5a44_1
- pthread-stubs=0.4=h14c3975_1001
- ptyprocess=0.6.0=py_1001
- pycparser=2.19=py36_1
- pygments=2.4.2=py_0
- pyopenssl=19.0.0=py36_0
- pyparsing=2.4.0=py_0
- pypubsub=4.0.3=py_0
- pyqt=5.6.0=py36h13b7fb3_1008
- pysocks=1.7.0=py36_0
- pytables=3.5.1=py36h442f067_1
- python=3.6.7=hd21baee_1002
- python-dateutil=2.7.3=py_0
- pytz=2019.1=py_0
- pywavelets=1.0.3=py36hd352d35_1
- pyyaml=5.1.1=py36h516909a_0
- qt=5.6.2=hce4f676_1013
- readline=7.0=hf8c457e_1001
- requests=2.22.0=py36_0
- ruamel.yaml=0.15.0=py36_0
- scikit-image=0.14.2=py36hf484d3e_1
- scikit-learn=0.19.2=py36_blas_openblasha84fab4_201
- scipy=1.1.0=py36_blas_openblash7943236_201
- setuptools=41.0.1=py36_0
- simplegeneric=0.8.1=py_1
- sip=4.18.1=py36hf484d3e_1000
- six=1.11.0=py36_1001
- sqlite=3.28.0=h8b20d00_0
- statsmodels=0.9.0=py36h3010b51_1000
- tensorboard=1.13.1=py36_0
- tensorflow=1.13.1=gpu_py36h3991807_0
- tensorflow-base=1.13.1=gpu_py36h8d69cac_0
- tensorflow-estimator=1.13.0=py_0
- tensorflow-gpu=1.13.1=h0d30ee6_0
- termcolor=1.1.0=py_2
- tk=8.6.9=hed695b0_1002
- toolz=0.9.0=py_1
- tornado=6.0.3=py36h516909a_0
- tqdm=4.32.2=py_0
- traitlets=4.3.2=py36_1000
- urllib3=1.24.3=py36_0
- wcwidth=0.1.7=py_1
- werkzeug=0.15.4=py_0
- wheel=0.31.1=py36_1001
- wxpython=4.0.6=py36h812d2d3_0
- x264=1!152.20180806=h14c3975_0
- xorg-kbproto=1.0.7=h14c3975_1002
- xorg-libice=1.0.9=h516909a_1004
- xorg-libsm=1.2.3=h84519dc_1000
- xorg-libx11=1.6.7=h14c3975_1000
- xorg-libxau=1.0.9=h14c3975_0
- xorg-libxdmcp=1.1.3=h516909a_0
- xorg-libxext=1.3.4=h516909a_0
- xorg-libxrender=0.9.10=h516909a_1002
- xorg-libxt=1.2.0=h516909a_0
- xorg-renderproto=0.11.1=h14c3975_1002
- xorg-xextproto=7.3.0=h14c3975_1002
- xorg-xproto=7.0.31=h14c3975_1007
- xz=5.2.4=h14c3975_1001
- yaml=0.1.7=h14c3975_1001
- zlib=1.2.11=h14c3975_1004
- zstd=1.4.0=h3b9ef0a_0
- pip
- python=3.6.8
- pip:
- opencv-python==3.4.5.20
- deeplabcut
- matplotlib==3.0.3
- tables==3.4.3
- tensorflow-gpu==1.13.1
- imgaug
- https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-18.04/wxPython-4.0.3-cp36-cp36m-linux_x86_64.whl
5 changes: 4 additions & 1 deletion conda-environments/dlc-windowsCPU.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ dependencies:
- nb_conda
- tensorflow==1.12
- wxpython
- pytables==3.4.4
- pytables==3.4.3
- Shapely
- pip:
- numpy==1.17.2
- imgaug
- deeplabcut
5 changes: 4 additions & 1 deletion conda-environments/dlc-windowsGPU.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ dependencies:
- wxpython
- jupyter
- nb_conda
- pytables==3.4.4
- pytables==3.4.3
- Shapely
- pip:
- numpy==1.17.2
- deeplabcut
- imgaug
5 changes: 3 additions & 2 deletions deeplabcut/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from deeplabcut.generate_training_dataset import label_frames, dropannotationfileentriesduetodeletedimages, comparevideolistsanddatafolders, dropimagesduetolackofannotation
from deeplabcut.generate_training_dataset import multiple_individual_labeling_toolbox
from deeplabcut.generate_training_dataset import adddatasetstovideolistandviceversa, dropduplicatesinannotatinfiles
from deeplabcut.gui.launch_script import launch_dlc

from deeplabcut.refine_training_dataset import refine_labels
from deeplabcut.utils import select_crop_parameters
Expand All @@ -43,15 +44,15 @@


# Train, evaluate & predict functions / require TF
from deeplabcut.pose_estimation_tensorflow import train_network
from deeplabcut.pose_estimation_tensorflow import train_network, return_train_network_path
from deeplabcut.pose_estimation_tensorflow import evaluate_network
from deeplabcut.pose_estimation_tensorflow import analyze_videos, analyze_time_lapse_frames

from deeplabcut.pose_estimation_3d import calibrate_cameras,check_undistortion,triangulate,create_labeled_video_3d

from deeplabcut.create_project import create_new_project, create_new_project_3d, add_new_videos, load_demo_data, create_pretrained_human_project
from deeplabcut.generate_training_dataset import extract_frames
from deeplabcut.generate_training_dataset import check_labels,create_training_dataset, mergeandsplit
from deeplabcut.generate_training_dataset import check_labels,create_training_dataset, mergeandsplit, create_training_model_comparison
from deeplabcut.utils import create_labeled_video,plot_trajectories, auxiliaryfunctions, convertcsv2h5, analyze_videos_converth5_to_csv, auxfun_videos
from deeplabcut.utils.auxfun_videos import ShortenVideo, DownSampleVideo

Expand Down
36 changes: 19 additions & 17 deletions deeplabcut/create_project/human_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,62 +64,63 @@ def create_pretrained_human_project(project,experimenter,videos,working_director
copy_videos : bool, optional
If this is set to True, the videos are copied to the ``videos`` directory. If it is False,symlink of the videos are copied to the project/videos directory. The default is ``False``; if provided it must be either
``True`` or ``False``.
analyzevideo " bool, optional
If true, then the video is analzyed and a labeled video is created. If false, then only the project will be created and the weights downloaded. You can then access them
analyzevideo " bool, optional
If true, then the video is analzyed and a labeled video is created. If false, then only the project will be created and the weights downloaded. You can then access them
Example
--------
Linux/MacOs
>>> deeplabcut.create_pretrained_human_project('human','Linus',['/data/videos/mouse1.avi'],'/analysis/project/',copy_videos=False)
Windows:
>>> deeplabcut.create_pretrained_human_project('human','Bill',[r'C:\yourusername\rig-95\Videos\reachingvideo1.avi'],r'C:\yourusername\analysis\project' copy_videos=False)
Users must format paths with either: r'C:\ OR 'C:\\ <- i.e. a double backslash \ \ )
--------
"""

cfg=deeplabcut.create_new_project(project,experimenter,videos,working_directory,copy_videos,videotype)

config = auxiliaryfunctions.read_config(cfg)
config['bodyparts'] = ['ankle1','knee1','hip1','hip2','knee2','ankle2','wrist1','elbow1','shoulder1','shoulder2','elbow2','wrist2','chin','forehead']
config['skeleton'] = [['ankle1', 'knee1'],['ankle2', 'knee2'],['knee1', 'hip1'],['knee2', 'hip2'],['hip1', 'hip2'], ['shoulder1', 'shoulder2'], ['shoulder1', 'hip1'], ['shoulder2', 'hip2'], ['shoulder1', 'elbow1'], ['shoulder2', 'elbow2'], ['chin', 'forehead'], ['elbow1', 'wrist1'], ['elbow2', 'wrist2']]
config['default_net_type']='resnet_101'
auxiliaryfunctions.write_config(cfg,config)
config = auxiliaryfunctions.read_config(cfg)

train_dir = Path(os.path.join(config['project_path'],str(auxiliaryfunctions.GetModelFolder(trainFraction=config['TrainingFraction'][0],shuffle=1,cfg=config)),'train'))
test_dir = Path(os.path.join(config['project_path'],str(auxiliaryfunctions.GetModelFolder(trainFraction=config['TrainingFraction'][0],shuffle=1,cfg=config)),'test'))
# Create the model directory

# Create the model directory
train_dir.mkdir(parents=True,exist_ok=True)
test_dir.mkdir(parents=True,exist_ok=True)

modelfoldername=auxiliaryfunctions.GetModelFolder(trainFraction=config['TrainingFraction'][0],shuffle=1,cfg=config)

path_train_config = str(os.path.join(config['project_path'],Path(modelfoldername),'train','pose_cfg.yaml'))
path_test_config = str(os.path.join(config['project_path'],Path(modelfoldername),'test','pose_cfg.yaml'))



# Download the weights and put then in appropriate directory
cwd = os.getcwd()
os.chdir(train_dir)
print("Checking if the weights are already available, otherwise I will download them!")
weightfilename=auxfun_models.download_mpii_weigths(train_dir)
os.chdir(cwd)
# create the pose_config.yaml files

# Create the pose_config.yaml files
parent_path = Path(os.path.dirname(deeplabcut.__file__))
defaultconfigfile = str(parent_path / 'pose_cfg.yaml')
trainingsetfolder = auxiliaryfunctions.GetTrainingSetFolder(config)
datafilename,metadatafilename=auxiliaryfunctions.GetDataandMetaDataFilenames(trainingsetfolder,trainFraction=config['TrainingFraction'][0],shuffle=1,cfg=config)
bodyparts = config['bodyparts']
net_type ='resnet_101'#'resnet_'+str(config['resnet'])
net_type ='resnet_101'
num_shuffles= 1
model_path,num_shuffles=auxfun_models.Check4weights(net_type,parent_path,num_shuffles)
items2change = {"dataset": 'dataset-test.mat',#datafilename,
"metadataset": metadatafilename,
"num_joints": len(bodyparts),
"all_joints": [[i] for i in range(len(bodyparts))],
"all_joints_names": [str(bpt) for bpt in bodyparts],
"init_weights": weightfilename, #'models/mpii/snapshot-1030000',
"init_weights": weightfilename.split('.index')[0], #'models/mpii/snapshot-1030000',
"project_path": str(config['project_path']),
"net_type": net_type,
"dataset_type": "default"
Expand All @@ -130,12 +131,13 @@ def create_pretrained_human_project(project,experimenter,videos,working_director
"net_type", 'init_weights', 'global_scale', 'location_refinement',
'locref_stdev']
MakeTest_pose_yaml(trainingdata, keys2save,path_test_config)

video_dir = os.path.join(config['project_path'],'videos')

if analyzevideo==True:
# Analyze the videos
deeplabcut.analyze_videos(cfg,[video_dir],videotype,save_as_csv=True)
if createlabeledvideo==True:
deeplabcut.create_labeled_video(cfg,[video_dir],videotype, draw_skeleton=True)
deeplabcut.plot_trajectories(cfg,[video_dir],videotype)
return cfg, path_train_config
8 changes: 5 additions & 3 deletions deeplabcut/create_project/new.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def create_new_project(project, experimenter, videos, working_directory=None, co
for p in [video_path, data_path, shuffles_path, results_path]:
p.mkdir(parents=True, exist_ok=DEBUG)
print('Created "{}"'.format(p))

# Add all videos in the folder. Multiple folders can be passed in a list, similar to the video files. Folders and video files can also be passed!
vids = []
for i in videos:
Expand Down Expand Up @@ -142,7 +142,7 @@ def create_new_project(project, experimenter, videos, working_directory=None, co

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

# adds the video list to the config.yaml file
video_sets = {}
for video in videos:
Expand Down Expand Up @@ -177,7 +177,9 @@ def create_new_project(project, experimenter, videos, working_directory=None, co
cfg_file['numframes2pick']=20
cfg_file['TrainingFraction']=[0.95]
cfg_file['iteration']=0
cfg_file['resnet']=50
#cfg_file['resnet']=50
cfg_file['default_net_type']='resnet_50'
cfg_file['default_augmenter']='default'
cfg_file['snapshotindex']=-1
cfg_file['x1']=0
cfg_file['x2']=640
Expand Down
Loading

0 comments on commit ca93b3e

Please sign in to comment.