Skip to content

NilsSomm/deeplabcut_wrapper_dna

Repository files navigation

deeplabcut_wrapper_dna

Python version 3.7.9 was used for this

Install Cuda (technically optional, but training will be slow otherwise)

https://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/index.html

Also, this is only if your machine has an Nvidia gpu. If it prompts you that no version of vsCode is found and that you won’t have full functionality without it, make sure you download vsCode and try to reinstall with it finding vsCode.

Install pytorch

https://pytorch.org/get-started/locally/

The “start locally” command is important after you've installed Cuda.

showing the command to run on the pytorch "get started" page

You’ll want to confirm that cuda and pytorch are connected. Run something like the code below in python:

import torch
torch.cuda.is_available()

This should return true. Also once you create your DEEPLABCUT environment you should run it again inside to confirm.

Install imageMagick (optional)

https://imagemagick.org/index.php

Only needed if you want to batch convert .tif files to .png, I find this useful when doing analysis of TEM image crops using the imageJ macro Michael N. made https://github.com/MNeuhoff/Crop-and-Collage-Tools

Install deeplabcut

https://deeplabcut.github.io/DeepLabCut/docs/installation.html

I used the conda installation process, specifically step 2 is the important one, where you download the yaml file and create the virtual environment.

Download Bulk Rename Utility (optional)

https://www.bulkrenameutility.co.uk/Download.php This is to rename files in bulk, which can be handy if we are creating a large training set with files that might have the same name at first.

First, let's make a folder of our training data. Both sections below (ImageMagick and Bulk Rename Utility) might be useful for this

Batch converting .tif to .png with ImageMagick:

  1. Create a folder with all of your .tif files
  2. Inside this folder, create another folder called “png_files”.
  3. In a windows terminal, navigate to the folder containing the .tif files and the other folder
  4. Run the command: for %f in (*.tif) do magick "%f" "png_files%~nf.png"
  5. You will see that “png_files” contains your converted png files, which will work in deeplabcut

Using Bulk Rename Utility

  1. Launch Bulk Rename Utility, just search it on the windows bar. There will be a lot going on but only a few things are relevant for what we want to do.
  2. Navigate to the folder with the images you want to rename.
  3. On the tab “Name (2)”, select “Fixed” for the dropdown “Name”, and below enter your filename.
  4. On the tab “Numbering (10)”, select “Suffix” for “Mode”
  5. On the tab “Numbering (10)”, change padding such that each of your files can get a unique file name (ie. for <=100 files, padding is 3, for >100 and <=1000 padding is 4, etc.)
  6. Select all files in your folder you want to rename (ctrl+A to select all)
  7. Press “Rename” at the bottom right and press OK.
  8. Your files should now be renamed with an appropriate suffix.

Using deeplabcut

Now you're ready to begin using the code!

  1. Create a new folder in which you want to contain your projects.
  2. Download all .ipynb files and paste them into the folder.
  3. If you're starting a new project, begin with deeplabcut_project_creation_and_training.ipynb and follow the instructions in the notebook

Using the napari labeler

If they didn't open automatically, open your config as a file and your folder of interest as a folder. You should then have 1 layer of collected data and one layer of images.

To label, select the collected data layer, and under layer controls at the very top you can select whether you want to create, delete, or move points. On the right you should be able to see your bodyparts you selected. You can also change your point size, and checking the display text checkbox will write the name of your bodyparts over their respective points, which can be useful for double checking things. You can also use the right and left arrows to change between images, which helps when labeling a lot of data. When you are done labeling, press ctrl+s while the collected data layer is selected, then a .csv and .h5 file should be created in the directory of the data you were labeling.

Checks/Troubleshooting

  • Try running the check if cuda is available in your DEEPLABCUT environment as well
  • When you are training the network, check your gpu in task manager, and see if its memory is being used.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors