Commit 9e2d390d authored by lucas_miranda's avatar lucas_miranda
Browse files

Fixed bug in csv reader, which was shuffling bodyparts if they were not in a particular order

parent 4830457d
Pipeline #92343 canceled with stage
in 1 minute and 20 seconds
......@@ -21,6 +21,7 @@ tensorflow-probability = "*"
tensorflow = "*"
tqdm = "*"
umap-learn = "*"
scikit-image = "*"
[dev-packages]
coverage = "*"
......
This diff is collapsed.
......@@ -68,7 +68,7 @@ class project:
self.table_format = table_format
if self.table_format == "autodetect":
ex = os.listdir(self.table_path)[0]
ex = [i for i in os.listdir(self.table_path) if not i.startswith(".")][0]
if ".h5" in ex:
self.table_format = ".h5"
elif ".csv" in ex:
......@@ -190,25 +190,15 @@ class project:
}
elif self.table_format == ".csv":
for tab in self.tables:
head = pd.read_csv(
deepof.utils.os.path.join(self.table_path, tab), nrows=2
)
data = pd.read_csv(
tab_dict = {
deepof.utils.re.findall("(.*)DLC", tab)[0]: pd.read_csv(
deepof.utils.os.path.join(self.table_path, tab),
skiprows=2,
index_col="coords",
dtype={"coords": int},
)
data.columns = pd.MultiIndex.from_product(
[
[head.columns[2]],
set(list(head.iloc[0])[2:]),
["x", "y", "likelihood"],
],
names=["scorer", "bodyparts", "coords"],
header=[0, 1, 2],
index_col=0,
dtype=float,
)
tab_dict[deepof.utils.re.findall("(.*)DLC", tab)[0]] = data
for tab in self.tables
}
lik_dict = defaultdict()
......
......@@ -376,7 +376,7 @@ def get_hparameters(hparams: dict = {}) -> dict:
- hparams (dict): dictionary containing hyperparameters to overwrite
Returns:
- defaults (dict): dictionary with overwriten parameters. Those not
- defaults (dict): dictionary with overwritten parameters. Those not
specified in the input retain their default values"""
defaults = {
......@@ -548,7 +548,7 @@ def rule_based_tagging(
for _id in animal_ids:
tag_dict[_id + undercond + "climbing"] = deepof.utils.smooth_boolean_array(
climb_wall(arena_type, arena, coords, w / 100, _id + undercond + "Nose")
climb_wall(arena_type, arena, coords, 1, _id + undercond + "Nose")
)
tag_dict[_id + undercond + "speed"] = speeds[_id + undercond + "Center"]
tag_dict[_id + undercond + "huddle"] = deepof.utils.smooth_boolean_array(
......@@ -578,11 +578,13 @@ def tag_rulebased_frames(
dims,
undercond,
hparams,
arena,
):
"""Helper function for rule_based_video. Annotates a given frame with on-screen information
about the recognised patterns"""
w, h = dims
arena, h, w = arena
def write_on_frame(text, pos, col=(255, 255, 255)):
"""Partial closure over cv2.putText to avoid code repetition"""
......@@ -614,7 +616,7 @@ def tag_rulebased_frames(
if len(animal_ids) > 1:
cv2.line(frame, (100, 100), (110, 100), (255, 0, 0))
cv2.circle(frame, (arena[0], arena[1]), arena[2], thickness=2, color=(0, 0, 255))
if tag_dict["nose2nose"][fnum] and not tag_dict["sidebyside"][fnum]:
write_on_frame("Nose-Nose", conditional_pos())
......@@ -775,6 +777,7 @@ def rule_based_video(
(w, h),
undercond,
hparams,
(arena, h, w)
)
if writer is None:
......
......@@ -19,6 +19,7 @@ import regex as re
from copy import deepcopy
from itertools import combinations, product
from joblib import Parallel, delayed
#from skimage.transform import hough_ellipse
from sklearn import mixture
from tqdm import tqdm
from typing import Tuple, Any, List, Union, NewType
......@@ -410,16 +411,21 @@ def circular_arena_recognition(frame: np.array) -> np.array:
gray_image = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
ret, thresh = cv2.threshold(gray_image, 50, 255, 0)
frame = cv2.medianBlur(thresh, 9)
circle = cv2.HoughCircles(
circle = hough_ellipse(
frame,
cv2.HOUGH_GRADIENT,
1,
300,
param1=50,
param2=10,
minRadius=0,
maxRadius=0,
# accuracy=20,
# threshold=250,
# min_size=frame.shape[0] // 6,
# max_size=frame.shape[0] // 2,
cv2.HOUGH_GRADIENT,
1,
300,
param1=50,
param2=10,
minRadius=0,
maxRadius=frame.shape[0] // 2,
)
result.sort(order='accumulator')
circles = []
......
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