Commit c8817849 authored by lucas_miranda's avatar lucas_miranda
Browse files

refactored some functions

parent 3e5b4070
Pipeline #83324 canceled with stage
in 17 minutes and 9 seconds
......@@ -680,6 +680,7 @@ class coordinates:
path=os.path.join(self._path, "Videos"),
hparams=hparams,
)
pbar.update(1)
if type(video_output) == list:
vid_idxs = video_output
......@@ -690,9 +691,11 @@ class coordinates:
"Video output must be either 'all' or a list with the names of the videos to render"
)
njobs = cpu_count(logical=True)
njobs = cpu_count(logical=False)
pbar = tqdm(total=len(vid_idxs))
with parallel_backend("threading", n_jobs=njobs):
Parallel()(delayed(output_video)(key) for key in vid_idxs)
pbar.close()
return table_dict(
tag_dict, typ="rule-based", arena=self._arena, arena_dims=self._arena_dims
......
......@@ -18,7 +18,6 @@ import regex as re
import seaborn as sns
from itertools import combinations
from scipy import stats
from tqdm import tqdm
from typing import Any, List, NewType
Coordinates = NewType("Coordinates", Any)
......@@ -716,7 +715,6 @@ def rule_based_video(
)
# Loop over the frames in the video
pbar = tqdm(total=min(coords.shape[0] - recog_limit, frame_limit))
while cap.isOpened() and fnum < frame_limit:
ret, frame = cap.read()
......@@ -766,8 +764,6 @@ def rule_based_video(
)
writer.write(frame)
pbar.update(1)
fnum += 1
cap.release()
......
......@@ -74,7 +74,7 @@ def test_project_properties():
prun.subset_condition = "testing"
assert prun.subset_condition == "testing"
assert prun.distances == "All"
assert prun.distances == "all"
prun.distances = "testing"
assert prun.distances == "testing"
......@@ -94,7 +94,7 @@ def test_project_properties():
)
def test_get_distances(nodes, ego):
nodes = ["All", ["Center", "Nose", "Tail_base"]][nodes]
nodes = ["all", ["Center", "Nose", "Tail_base"]][nodes]
ego = [False, "Center", "Nose"][ego]
prun = deepof.data.project(
......@@ -118,7 +118,7 @@ def test_get_distances(nodes, ego):
)
def test_get_angles(nodes, ego):
nodes = ["All", ["Center", "Nose", "Tail_base"]][nodes]
nodes = ["all", ["Center", "Nose", "Tail_base"]][nodes]
ego = [False, "Center", "Nose"][ego]
prun = deepof.data.project(
......@@ -143,7 +143,7 @@ def test_get_angles(nodes, ego):
)
def test_run(nodes, ego):
nodes = ["All", ["Center", "Nose", "Tail_base"]][nodes]
nodes = ["all", ["Center", "Nose", "Tail_base"]][nodes]
ego = [False, "Center", "Nose"][ego]
prun = deepof.data.project(
......@@ -185,7 +185,7 @@ def test_get_rule_based_annotation():
)
def test_get_table_dicts(nodes, ego, sampler):
nodes = ["All", ["Center", "Nose", "Tail_base"]][nodes]
nodes = ["all", ["Center", "Nose", "Tail_base"]][nodes]
ego = [False, "Center", "Nose"][ego]
prun = deepof.data.project(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment