Closed aytek03 closed 2 years ago
Waiting for the answer of the authors, who I thank for their work, I can tell that the error is generated by some divisions by zero while computing the coordinates of the bounding boxes. Precisely, in the function
@staticmethod
def _from_image_to_centre_bounding_box(coordinates, video_resolution):
# TODO: Better implementation
# coordinates = np.where(coordinates == 0, np.nan, coordinates)
# bounding_boxes = np.apply_along_axis(compute_bounding_box, axis=1, arr=coordinates,
# video_resolution=video_resolution)
# centre_x = (bounding_boxes[:, 0] + bounding_boxes[:, 1]) / 2
# centre_y = (bounding_boxes[:, 2] + bounding_boxes[:, 3]) / 2
for idx, kps in enumerate(coordinates):
if any(kps):
left, right, top, bottom = compute_bounding_box(kps, video_resolution=video_resolution)
centre_x, centre_y = (left + right) / 2, (top + bottom) / 2
xs, ys = np.hsplit(kps.reshape(-1, 2), indices_or_sections=2)
xs, ys = np.where(xs == 0.0, centre_x, xs) - centre_x, np.where(ys == 0.0, centre_y, ys) - centre_y
left, right, top, bottom = left - centre_x, right - centre_x, top - centre_y, bottom - centre_y
width, height = right - left, bottom - top
xs, ys = xs / width, ys / height
kps = np.hstack((xs, ys)).ravel()
coordinates[idx] = kps
return coordinates
located at line 131 of skeleton_based_anomaly_detection/tbad/autoencoder/data.py
, the division
xs, ys = xs / width, ys / height
may yield infinite results due to width==0
and/or height==0
.
A way to bypass this issue is to change the previous line to
xs = xs / width if width != 0 else np.zeros_like(xs)
ys = ys / height if height != 0 else np.zeros_like(ys)
I can't tell if this leads to the expected behaviour of the function, but at least it solves the subsequent error ValueError: Input contains infinity or a value too large for dtype('float32')
raised by the scaler on that (bad) input and lets one train the model. One may check if the model's results are meaningful afterwards.
Hi sir, @stdrr
Thank you for your answering.
I solve this problem like this code.
if(width ==0 or height==0):
continue
xs, ys = xs / width, ys / height
kps = np.hstack((xs, ys)).ravel()
Thanks a lot by the way.
When I implement train.py with 'HR-Crime' dataset (https://dataverse.nl/dataset.xhtml?persistentId=doi:10.34894/IRRDJE), I got error in training set : (Training Normal Videos)
ValueError: Input contains infinity or a value too large for dtype('float32').
I deleted and extracted some files among training set and I got no error.
Is it possible that I don't get this error without deleting any files?