Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
84d409e
tmp build books
maximpavliv Feb 5, 2025
d0041b2
Additional reference points
maximpavliv Feb 7, 2025
b388843
Update course.md
maximpavliv Jan 29, 2025
075ee05
Update standardDeepLabCut_UserGuide
maximpavliv Feb 3, 2025
7beee45
Update Overviewof3D
maximpavliv Feb 4, 2025
2693ab7
Update deeplabcutlive
maximpavliv Feb 4, 2025
26f277a
Update ModelZoo
maximpavliv Feb 5, 2025
01414a1
Tmp fix create_pretrained_project: create TF trainingset metadata
maximpavliv Feb 6, 2025
4219fc2
Update UsingModelZooPupil
maximpavliv Feb 6, 2025
bb4e8f7
Remove MegaDetector+DLC from TOC
maximpavliv Feb 6, 2025
1c6e45c
Update Project_gui
maximpavliv Feb 6, 2025
cbd0778
Update single_animal_quick_guide
maximpavliv Feb 6, 2025
16f990f
Update beginner-guides/manage-project
maximpavliv Feb 6, 2025
c42bafd
Update beginner-guides/labelling
maximpavliv Feb 6, 2025
1e66c0e
Update beguinner-guides/Training-Evaluation
maximpavliv Feb 6, 2025
fed789c
Update beginner-guides/video-analysis
maximpavliv Feb 6, 2025
f426233
Update convert_maDLC
maximpavliv Feb 7, 2025
c890473
Update BatchProcessing
maximpavliv Feb 7, 2025
48a1034
Update DLCMethods
maximpavliv Feb 7, 2025
e2080f8
Update ClusteringNapari
maximpavliv Feb 7, 2025
1ff49c2
Update OpenVINO
maximpavliv Feb 7, 2025
1a28105
Update pose_cfg_file_breakdown
maximpavliv Feb 7, 2025
827ad7d
Update publishing_notebooks
maximpavliv Feb 7, 2025
0f13790
Update MISSION_AND_VALUES
maximpavliv Feb 7, 2025
33d6b42
Update Governance
maximpavliv Feb 7, 2025
89f7c6c
Update roadmap
maximpavliv Feb 7, 2025
db687bf
pytorch_config.yaml: add gpus list example
maximpavliv Feb 10, 2025
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
Prev Previous commit
Next Next commit
Update BatchProcessing
  • Loading branch information
maximpavliv committed Feb 10, 2025
commit c890473081f32f5d9829e10ca31b2fa9074570eb
64 changes: 31 additions & 33 deletions docs/recipes/BatchProcessing.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@

## Tips for working with DLC networks:

- Now you have a DLC network and are happy with the performance on selected videos, you may want to run it on all your videos without hassle. If all your videos are in one folder this is easy, simply pass the foldername to `deeplabcut.analyze_videos(config,[folder])` and you are fine. What if the videos are scattered?
Now you have a DLC network and are happy with the performance on selected videos, you may want to run it on all your
videos without hassle. If all your videos are in one folder this is easy, simply pass the foldername to
`deeplabcut.analyze_videos(config,[folder])` and you are fine. What if the videos are scattered?


You could create a simply script that runs over all your video folders with the network of choice. Your "key" to this network is your config.yaml file.
You can create a simple script that runs over all your video folders with the network of choice. Your "key" to this
network is your config.yaml file.

![](https://static1.squarespace.com/static/57f6d51c9f74566f55ecf271/t/5ccc5abe0d9297405a428522/1556896461304/howtouseDLC-01.png?format=1000w)

Expand All @@ -33,18 +35,18 @@ import deeplabcut

def getsubfolders(folder):
''' returns list of subfolders '''
return [os.path.join(folder,p) for p in os.listdir(folder) if os.path.isdir(os.path.join(folder,p))]
return [os.path.join(folder, p) for p in os.listdir(folder) if os.path.isdir(os.path.join(folder, p))]

project='ComplexWheelD3-12-Fumi-2019-01-28'
project = "ComplexWheelD3-12-Fumi-2019-01-28"

shuffle=1
shuffle = 1

prefix='/home/alex/DLC-workshopRowland'
prefix = "/home/alex/DLC-workshopRowland"

projectpath=os.path.join(prefix,project)
config=os.path.join(projectpath,'config.yaml')
projectpath = os.path.join(prefix, project)
config = os.path.join(projectpath, "config.yaml")

basepath='/home/alex/BenchmarkingExperimentsJan2019' #data'
basepath = "/home/alex/BenchmarkingExperimentsJan2019"

'''

Expand All @@ -57,13 +59,13 @@ Imagine that the data (here: videos of 3 different types) are in subfolders:

'''

subfolders=getsubfolders(basepath)
subfolders = getsubfolders(basepath)
for subfolder in subfolders: #this would be January, February etc. in the upper example
print("Starting analyze data in:", subfolder)
subsubfolders=getsubfolders(subfolder)
print("Starting analyze data in: ", subfolder)
subsubfolders = getsubfolders(subfolder)
for subsubfolder in subsubfolders: #this would be Febuary1, etc. in the upper example...
print("Starting analyze data in:", subsubfolder)
for vtype in ['.mp4','.m4v','.mpg']:
print("Starting analyze data in: ", subsubfolder)
for vtype in [".mp4", ".m4v", ".mpg"]:
deeplabcut.analyze_videos(config,[subsubfolder],shuffle=shuffle,videotype=vtype,save_as_csv=True)

```
Expand All @@ -90,48 +92,44 @@ import os

import deeplabcut

Maxiter=int(1.5*10**5)
epochs = 200

model=int(sys.argv[1])

Projects=[['project1-phoenix-2019-01-28'],['ComplexWheelD3-12-Fumi-2019-01-28', 'maze-ariel-2019-01-28'], ['TBI-BvA-2019-01-28','group-eli-2019-01-28']]
Projects=[["project1-phoenix-2019-01-28"], ["ComplexWheelD3-12-Fumi-2019-01-28", "maze-ariel-2019-01-28"], ["TBI-BvA-2019-01-28", "group-eli-2019-01-28"]]

shuffle=1

prefix='/home/alex/DLC-workshopRowland'
prefix = "/home/alex/DLC-workshopRowland"

for project in Projects[model]:
projectpath=os.path.join(prefix,project)
config=os.path.join(projectpath,'config.yaml')
projectpath = os.path.join(prefix, project)
config = os.path.join(projectpath, "config.yaml")

cfg=deeplabcut.auxiliaryfunctions.read_config(config)
previous_path=cfg['project_path']
cfg = deeplabcut.auxiliaryfunctions.read_config(config)
previous_path = cfg["project_path"]

cfg['project_path']=projectpath
deeplabcut.auxiliaryfunctions.write_config(config,cfg)
cfg["project_path"]=projectpath
deeplabcut.auxiliaryfunctions.write_config(config, cfg)

print("This is the name of the script: ", sys.argv[0])
print("Shuffle: ", shuffle)
print("config: ", config)

deeplabcut.create_training_dataset(config, Shuffles=[shuffle])

deeplabcut.train_network(config, shuffle=shuffle, max_snapshots_to_keep=5, maxiters=Maxiter)
deeplabcut.train_network(config, shuffle=shuffle, max_snapshots_to_keep=5, epochs=epochs)
print("Evaluating...")
deeplabcut.evaluate_network(config, Shuffles=[shuffle],plotting=True)
deeplabcut.evaluate_network(config, Shuffles=[shuffle], plotting=True)

print("Analyzing videos..., switching to last snapshot...")
#cfg=deeplabcut.auxiliaryfunctions.read_config(config)
#cfg['snapshotindex']=-1
#deeplabcut.auxiliaryfunctions.write_config(config,cfg)

for vtype in ['.mp4','.m4v','.mpg']:
try:
deeplabcut.analyze_videos(config,[str(os.path.join(projectpath,'videos'))],shuffle=shuffle,videotype=vtype,save_as_csv=True)
deeplabcut.analyze_videos(config, [str(os.path.join(projectpath, "videos"))], shuffle=shuffle, videotype=vtype, save_as_csv=True)
except:
pass

print("DONE WITH ", project," resetting to original path")
cfg['project_path']=previous_path
deeplabcut.auxiliaryfunctions.write_config(config,cfg)
cfg["project_path"] = previous_path
deeplabcut.auxiliaryfunctions.write_config(config, cfg)
```