Skip to content

Commit ffe923c

Browse files
committed
Fix all E501
1 parent cf8a12a commit ffe923c

9 files changed

Lines changed: 66 additions & 26 deletions

File tree

dlclive/benchmark.py

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,19 @@ def benchmark_videos(
113113
resize : int, optional
114114
resize factor. Can only use one of resize or pixels. If both are provided, will use pixels. by default None
115115
pixels : int, optional
116-
downsize image to this number of pixels, maintaining aspect ratio. Can only use one of resize or pixels. If both are provided, will use pixels. by default None
116+
downsize image to this number of pixels, maintaining aspect ratio. Can only use one of resize or pixels.
117+
If both are provided, will use pixels. by default None
117118
cropping : list of int
118119
cropping parameters in pixel number: [x1, x2, y1, y2]
119120
dynamic: triple containing (state, detectiontreshold, margin)
120-
If the state is true, then dynamic cropping will be performed. That means that if an object is detected (i.e. any body part > detectiontreshold),
121-
then object boundaries are computed according to the smallest/largest x position and smallest/largest y position of all body parts. This window is
122-
expanded by the margin and from then on only the posture within this crop is analyzed (until the object is lost, i.e. <detectiontreshold). The
123-
current position is utilized for updating the crop window for the next frame (this is why the margin is important and should be set large
124-
enough given the movement of the animal)
121+
If the state is true, then dynamic cropping will be performed.
122+
That means that if an object is detected (i.e. any body part > detectiontreshold),
123+
then object boundaries are computed according to the
124+
smallest/largest x position and smallest/largest y position of all body parts.
125+
This window is expanded by the margin and from then on only
126+
the posture within this crop is analyzed (until the object is lost, i.e. <detectiontreshold).
127+
The current position is utilized for updating the crop window for the next frame
128+
(this is why the margin is important and should be set large enough given the movement of the animal)
125129
n_frames : int, optional
126130
number of frames to run inference on, by default 1000
127131
print_rate : bool, optional
@@ -133,25 +137,32 @@ def benchmark_videos(
133137
display_radius : int, optional
134138
size (radius in pixels) of keypoint to display
135139
cmap : str, optional
136-
a string indicating the :package:`colorcet` colormap, `options here <https://colorcet.holoviz.org/>`, by default "bmy"
140+
a string indicating the :package:`colorcet` colormap, `options here <https://colorcet.holoviz.org/>`,
141+
by default "bmy"
137142
save_poses : bool, optional
138-
flag to save poses to an hdf5 file. If True, operates similar to :function:`DeepLabCut.benchmark_videos`, by default False
143+
flag to save poses to an hdf5 file. If True, operates similar to :function:`DeepLabCut.benchmark_videos`,
144+
by default False
139145
save_video : bool, optional
140-
flag to save a labeled video. If True, operates similar to :function:`DeepLabCut.create_labeled_video`, by default False
146+
flag to save a labeled video.
147+
If True, operates similar to :function:`DeepLabCut.create_labeled_video`, by default False
141148
142149
Example
143150
-------
144151
Return a vector of inference times for 10000 frames on one video or two videos:
145152
dlclive.benchmark_videos('/my/exported/model', 'my_video.avi', n_frames=10000)
146153
dlclive.benchmark_videos('/my/exported/model', ['my_video1.avi', 'my_video2.avi'], n_frames=10000)
147154
148-
Return a vector of inference times, testing full size and resizing images to half the width and height for inference, for two videos
149-
dlclive.benchmark_videos('/my/exported/model', ['my_video1.avi', 'my_video2.avi'], n_frames=10000, resize=[1.0, 0.5])
155+
Return a vector of inference times, testing full size and resizing images
156+
to half the width and height for inference, for two videos
157+
dlclive.benchmark_videos(
158+
'/my/exported/model', ['my_video1.avi', 'my_video2.avi'], n_frames=10000, resize=[1.0, 0.5]
159+
)
150160
151161
Display keypoints to check the accuracy of an exported model
152162
dlclive.benchmark_videos('/my/exported/model', 'my_video.avi', display=True)
153163
154-
Analyze a video (save poses to hdf5) and create a labeled video, similar to :function:`DeepLabCut.benchmark_videos` and :function:`create_labeled_video`
164+
Analyze a video (save poses to hdf5) and create a labeled video,
165+
similar to :function:`DeepLabCut.benchmark_videos` and :function:`create_labeled_video`
155166
dlclive.benchmark_videos('/my/exported/model', 'my_video.avi', save_poses=True, save_video=True)
156167
"""
157168
# convert video_paths to list
@@ -371,7 +382,8 @@ def benchmark(
371382
draw_keypoint_names: bool = False,
372383
):
373384
"""
374-
Analyzes a video to track keypoints using a DeepLabCut model, and optionally saves the keypoint data and the labeled video.
385+
Analyzes a video to track keypoints using a DeepLabCut model,
386+
and optionally saves the keypoint data and the labeled video.
375387
376388
Parameters
377389
----------
@@ -388,7 +400,8 @@ def benchmark(
388400
device : str
389401
Pytorch only. Device to run the model on ('cpu' or 'cuda').
390402
resize : float or None, optional
391-
Resize dimensions for video frames. e.g. if resize = 0.5, the video will be processed in half the original size. If None, no resizing is applied.
403+
Resize dimensions for video frames. e.g. if resize = 0.5,
404+
the video will be processed in half the original size. If None, no resizing is applied.
392405
pixels : int, optional
393406
downsize image to this number of pixels, maintaining aspect ratio.
394407
Can only use one of resize or pixels. If both are provided, will use pixels.
@@ -397,7 +410,14 @@ def benchmark(
397410
cropping : list of int or None, optional
398411
Cropping parameters [x1, x2, y1, y2] in pixels. If None, no cropping is applied.
399412
dynamic : tuple, optional, default=(False, 0.5, 10) (True/false), p cutoff, margin)
400-
Parameters for dynamic cropping. If the state is true, then dynamic cropping will be performed. That means that if an object is detected (i.e. any body part > detectiontreshold), then object boundaries are computed according to the smallest/largest x position and smallest/largest y position of all body parts. This window is expanded by the margin and from then on only the posture within this crop is analyzed (until the object is lost, i.e. <detection treshold). The current position is utilized for updating the crop window for the next frame (this is why the margin is important and should be set large enough given the movement of the animal).
413+
Parameters for dynamic cropping.
414+
If the state is true, then dynamic cropping will be performed.
415+
That means that if an object is detected (i.e. any body part > detectiontreshold),
416+
then object boundaries are computed according to the smallest/largest x position and smallest/largest y
417+
position of all body parts. This window is expanded by the margin and from then on only the posture within
418+
this crop is analyzed (until the object is lost, i.e. <detection treshold).
419+
The current position is utilized for updating the crop window for the next frame
420+
(this is why the margin is important and should be set large enough given the movement of the animal).
401421
n_frames : int, optional
402422
Number of frames to run inference on, by default 1000
403423
print_rate: bool, optional, default=False
@@ -498,7 +518,8 @@ def benchmark(
498518
ret, frame = cap.read()
499519
if not ret:
500520
warnings.warn(
501-
f"Did not complete {n_frames:d} frames. There probably were not enough frames in the video {video_path}.",
521+
f"Did not complete {n_frames:d} frames."
522+
" There probably were not enough frames in the video {video_path}.",
502523
stacklevel=2,
503524
)
504525
break

dlclive/check_install/check_install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def main():
8585
shutil.rmtree(tmp_dir)
8686
except PermissionError:
8787
warnings.warn(
88-
f"Could not delete temporary directory {str(tmp_dir)} due to a permissions error, but otherwise dlc-live seems to be working fine!",
88+
f"Could not delete temporary directory {str(tmp_dir)} due to a permissions error.",
8989
stacklevel=2,
9090
)
9191

dlclive/live_inference.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ def analyze_live_video(
105105
save_video=False,
106106
):
107107
"""
108-
Analyzes a video to track keypoints using a DeepLabCut model, and optionally saves the keypoint data and the labeled video.
108+
Analyzes a video to track keypoints using a DeepLabCut model,
109+
and optionally saves the keypoint data and the labeled video.
109110
110111
Parameters
111112
----------
@@ -128,11 +129,21 @@ def analyze_live_video(
128129
display_radius : int, optional, default=5
129130
Radius of circles drawn for keypoints on video frames.
130131
resize : tuple of int (width, height) or None, optional
131-
Resize dimensions for video frames. e.g. if resize = 0.5, the video will be processed in half the original size. If None, no resizing is applied.
132+
Resize dimensions for video frames. e.g. if resize = 0.5,
133+
the video will be processed in half the original size.
134+
If None, no resizing is applied.
132135
cropping : list of int or None, optional
133136
Cropping parameters [x1, x2, y1, y2] in pixels. If None, no cropping is applied.
134137
dynamic : tuple, optional, default=(False, 0.5, 10) (True/false), p cutoff, margin)
135-
Parameters for dynamic cropping. If the state is true, then dynamic cropping will be performed. That means that if an object is detected (i.e. any body part > detectiontreshold), then object boundaries are computed according to the smallest/largest x position and smallest/largest y position of all body parts. This window is expanded by the margin and from then on only the posture within this crop is analyzed (until the object is lost, i.e. <detection treshold). The current position is utilized for updating the crop window for the next frame (this is why the margin is important and should be set large enough given the movement of the animal).
138+
Parameters for dynamic cropping.
139+
If the state is true, then dynamic cropping will be performed.
140+
That means that if an object is detected (i.e. any body part > detectiontreshold),
141+
then object boundaries are computed according to the
142+
smallest/largest x position and smallest/largest y position of all body parts.
143+
This window is expanded by the margin and from then on only the posture within
144+
this crop is analyzed (until the object is lost, i.e. <detection treshold).
145+
The current position is utilized for updating the crop window for the next frame
146+
(this is why the margin is important and should be set large enough given the movement of the animal).
136147
save_poses : bool, optional, default=False
137148
Whether to save the detected poses to CSV and HDF5 files.
138149
save_dir : str, optional, default='model_predictions'

dlclive/pose_estimation_pytorch/models/modules/conv_block.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
class BaseBlock(ABC, nn.Module):
2727
"""Abstract Base class for defining custom blocks.
2828
29-
This class defines an abstract base class for creating custom blocks used in the HigherHRNet for Human Pose Estimation.
29+
This class defines an abstract base class for creating custom blocks
30+
used in the HigherHRNet for Human Pose Estimation.
3031
3132
Attributes:
3233
bn_momentum: Batch normalization momentum.

dlclive/pose_estimation_pytorch/models/necks/transformer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
class Transformer(BaseNeck):
2828
"""Transformer Neck for pose estimation.
2929
title={TokenPose: Learning Keypoint Tokens for Human Pose Estimation},
30-
author={Yanjie Li and Shoukui Zhang and Zhicheng Wang and Sen Yang and Wankou Yang and Shu-Tao Xia and Erjin Zhou},
30+
author={
31+
Yanjie Li and Shoukui Zhang and Zhicheng Wang and Sen Yang
32+
and Wankou Yang and Shu-Tao Xia and Erjin Zhou},
3133
booktitle={IEEE/CVF International Conference on Computer Vision (ICCV)},
3234
year={2021}
3335

dlclive/pose_estimation_pytorch/models/predictors/paf_predictor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ class PartAffinityFieldPredictor(BasePredictor):
3333
Args:
3434
num_animals: Number of animals in the project.
3535
num_multibodyparts: Number of animal's body parts (ignoring unique body parts).
36-
num_uniquebodyparts: Number of unique body parts. # FIXME - should not be needed here if we separate the unique bodypart head
36+
num_uniquebodyparts: Number of unique body parts.
37+
# FIXME - should not be needed here if we separate the unique bodypart head
3738
graph: Part affinity field graph edges.
3839
edges_to_keep: List of indices in `graph` of the edges to keep.
3940
locref_stdev: Standard deviation for location refinement.

dlclive/pose_estimation_tensorflow/runner.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ def init_inference(self, frame: np.ndarray, **kwargs) -> np.ndarray:
164164
elif self.model_type == "tensorrt":
165165
if trt is None:
166166
raise DLCLiveError(
167-
"TensorRT integration requires tensorflow 1.x and the tensorflow.contrib.tensorrt module, which is not available in your current environment."
167+
"TensorRT integration requires tensorflow 1.x "
168+
"and the tensorflow.contrib.tensorrt module,"
169+
" which is not available in your current environment."
168170
)
169171
graph_def = read_graph(model_file)
170172
graph = finalize_graph(graph_def)

example_processors/TeensyLaser/teensy_laser.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ def close_serial(self):
3232

3333
def turn_stim_on(self):
3434

35-
# 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
35+
# command to activate PWM signal to laser is
36+
# the letter 'O' followed by three 16 bit integers
37+
# -- pulse frequency, pulse width, and max stim duration
3638
if not self.stim_on:
3739
self.ser.write(b"O" + struct.pack("HHH", self.pulse_freq, self.pulse_width, self.max_stim_dur))
3840
self.stim_on = True

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ line-length = 120
9090
fix = true
9191
[tool.ruff.lint]
9292
select = [ "E", "F", "B", "I", "UP" ]
93-
ignore = [ "E741", "E501", "F403", "F401" ]
93+
ignore = [ "E741", "F403", "F401" ]
9494
[tool.ruff.lint.per-file-ignores]
9595
"dlclive/__init__.py" = [ "E402" ]
9696
[tool.ruff.lint.pydocstyle]

0 commit comments

Comments
 (0)