Skip to content

Commit 09c01ee

Browse files
committed
2 parents 014eb22 + aab5609 commit 09c01ee

File tree

2 files changed

+66
-4
lines changed

2 files changed

+66
-4
lines changed

README.md

+64-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,64 @@
1-
# DeepLabCutLive
2-
GUI to run DeepLabCut on live video feed
1+
# DeepLabCut-Live! GUI<img src="https://images.squarespace-cdn.com/content/v1/57f6d51c9f74566f55ecf271/1596193544929-NHMVMXPVEYZ6R4I45DSR/ke17ZwdGBToddI8pDm48kOHwsIwndRGCkvek0XAcW4ZZw-zPPgdn4jUwVcJE1ZvWEtT5uBSRWt4vQZAgTJucoTqqXjS3CfNDSuuf31e0tVH0wqgmu6zkAOZ3crWCtkmLcPIuzHaxU8QRzZwtrVtHupu3E9Ef3XsXP1C_826c-iU/DLCLIVEGUI_LOGO.png?format=750w" width="350" title="DLC-live GUI" alt="DLC LIVE! GUI" align="right" vspace = "50">
2+
GUI to run DeepLabCut-live video feed, record videos, and record external timestamps.
3+
4+
## Install
5+
6+
Launch **console**:
7+
```bash
8+
conda create -n dlc_live
9+
conda activate dlc_live
10+
conda install python=3.7 tensorflow-GPU==1.13.1
11+
```
12+
13+
**Install** DLC-Live! GUI **package**:
14+
```bash
15+
pip install deeplabcut-live-gui
16+
```
17+
**Run dlc live gui**:
18+
```bash
19+
dlclivegui
20+
```
21+
22+
## Getting Started
23+
24+
<img src= https://imagizer.imageshack.com/img923/2419/QQKyMH.png align="right">
25+
26+
#### Configurations
27+
28+
First, create a configuration file: select the drop down menu labeled `Config`, and click `Create New Config`. All settings, such as details about cameras, DLC networks, and DLC-live Processors, will be saved into configuration files so that you can close and reopen the GUI without losing all of these details. You can create multiple configuration files on the same system, so that different users can save different camera options, etc on the same computer. To load previous settings from a configuration file, please just select the file from the drop-down menu. Configuration files are stored at `$HOME/Documents/DeepLabCut-live-GUI/config`. These files do not need to be edited manually, they can be entirely created and edited automatically within the GUI.
29+
30+
#### Set Up Cameras <img src= https://imagizer.imageshack.com/img924/626/acJhWD.png align="right">
31+
32+
To setup a new camera, select `Add Camera` from the dropdown menu, and then click `Init Cam`. This will be bring up a new window where you need to select the type of camera (see [Camera Support](docs/Camera Support.md)), input a name for the camera, and click `Add Camera`. This will initialize a new `Camera` entry in the drop down menu. Now, select your camera from the dropdown menu and click`Edit Camera Settings` to setup your camera settings (i.e. set the serial number, exposure, cropping parameters, etc; the exact settings depend on the specific type of camera). Once you have set the camera settings, click `Init Cam` to start streaming. To stop streaming data, click `Close Camera`, and to remove a camera from the dropdown menu, click `Remove Camera`.
33+
34+
35+
36+
#### Processor (optional)
37+
38+
To write custom `Processors`, please see [here](https://github.com/DeepLabCut/DeepLabCut-live/tree/master/dlclive/processor). The directory that contains your custom `Processor` should be a python module -- this directory must contain an `__init__.py` file that imports your custom `Processor`. For examples of how to structure a custom `Processor` directory, please see [here](https://github.com/DeepLabCut/DeepLabCut-live/tree/master/example_processors).
39+
40+
To use your processor in the GUI, you must first add your custom `Processor` directory to the dropdown menu: next to the `Processor Dir` label, click `Browse`, and select your custom `Processor` directory. Next, select the desired directory from the `Processor Dir` dropdown menu, then select the `Processor` you would like to use from the `Processor` menu. If you would like to edit the arguments for your processor, please select `Edit Proc Settings`, and finally, to use the processor, click `Set Proc`. If you have previously set a `Processor` and would like to clear it, click `Clear Proc`.
41+
42+
#### Configure DeepLabCut Network
43+
44+
<img src= https://imagizer.imageshack.com/img923/9730/MNzr1J.png align="right">
45+
46+
Select the `DeepLabCut` dropdown menu, and click `Add DLC`. This will bring up a new window to choose a name for the DeepLabCut configuration, choose the path to the exported DeepLabCut model, and set DeepLabCut-live settings, such as the cropping or resize parameters. Once configured, click `Update` to add this DeepLabCut configuration to the dropdown menu. You can edit the settings at any time by clicking `Edit DLC Settings`. Once configured, you can load the network and start performing inference by clicking `Start DLC`. If you would like to view the DeepLabCut pose estimation in real-time, select `Display DLC Keypoints`. You can edit the keypoint display settings (the color scheme, size of points, and the likelihood threshold for display) by selecting `Edit DLC Display Settings`.
47+
48+
If you want to stop performing inference at any time, just click `Stop DLC`, and if you want to remove a DeepLabCut configuration from the dropdown menu, click `Remove DLC`.
49+
50+
#### Set Up Session
51+
52+
Sessions are defined by the subject name, the date, and an attempt number. Within the GUI, select a `Subject` from the dropdown menu, or to add a new subject, type the new subject name in to the entry box and click `Add Subject`. Next, select an `Attempt` from the dropdown menu. Then, select the directory that you would like to save data to from the `Directory` dropdown menu. To add a new directory to the dropdown menu, click `Browse`. Finally, click `Set Up Session` to initiate a new recording. This will prepare the GUI to save data. Once you click `Set Up Session`, the `Ready` button should turn blue, indicating a session is ready to record.
53+
54+
#### Controlling Recording
55+
56+
If the `Ready` button is selected, you can now start a recording by clicking `On`. The `On` button will then turn green indicating a recording is active. To stop a recording, click `Off`. This will cause the `Ready` button to be selected again, as the GUI is prepared to restart the recording and to save the data to the same file. If you're session is complete, click `Save Video` to save all files: the video recording (as .avi file), a numpy file with timestamps for each recorded frame, the DeepLabCut poses as a pandas data frame (hdf5 file) that includes the time of each frame used for pose estimation and the time that each pose was obtained, and if applicable, files saved by the `Processor` in use. These files will be saved into a new directory at `{YOUR_SAVE_DIRECTORY}/{CAMERA NAME}_{SUBJECT}_{DATE}_{ATTEMPT}`
57+
- YOUR_SAVE_DIRECTORY : the directory chosen from the `Directory` dropdown menu.
58+
- CAMERA NAME : the name of selected camera (from the `Camera` dropdown menu).
59+
- SUBJECT : the subject chosen from the `Subject` drowdown menu.
60+
- DATE : the current date of the experiment.
61+
- ATTEMPT : the attempt number chosen from the `Attempt` dropdown.
62+
63+
If you would not like to save the data from the session, please click `Delete Video`, and all data will be discarded. After you click `Save Video` or `Delete Video`, the `Off` button will be selected, indicating you can now set up a new session.
64+

dlclivegui/processor/teensy_laser/teensy_laser.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def close_serial(self):
2222
self.ser.close()
2323

2424

25-
def stim_on(self):
25+
def stimulate_on(self):
2626

2727
# command to activate PWM signal to laser is the letter 'O' followed by three 16 bit integers -- pulse frequency, pulse width, and max stim duration
2828
if not self.stim_on:
@@ -45,7 +45,7 @@ def process(self, pose):
4545
# define criteria to stimulate (e.g. if first point is in a corner of the video)
4646
box = [[0,100],[0,100]]
4747
if (pose[0][0] > box[0][0]) and (pose[0][0] < box[0][1]) and (pose[0][1] > box[1][0]) and (pose[0][1] < box[1][1]):
48-
self.stim_on()
48+
self.stimulate_on()
4949
else:
5050
self.stim_off()
5151

0 commit comments

Comments
 (0)