./test.sh: line 26: python: command not found (build.sh has succeed) ¶
By: junma on March 7, 2022, 2:56 p.m.
Dear grand-challenge,
Thanks for the awesome platform.
I encounter the following error when testing the evaluation docker sudo ./test.sh
/home/evaluator/.local/lib/python3.9/site-packages/evalutils/evalutils.py:589: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
self._case_results = self._case_results.append(
/home/evaluator/.local/lib/python3.9/site-packages/evalutils/evalutils.py:589: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
self._case_results = self._case_results.append(
/home/evaluator/.local/lib/python3.9/site-packages/evalutils/evalutils.py:589: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
self._case_results = self._case_results.append(
/home/evaluator/.local/lib/python3.9/site-packages/evalutils/evalutils.py:589: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
self._case_results = self._case_results.append(
Could not serialize freq: 1 as json, so converting 1 to int.
Could not serialize count: 100 as json, so converting 100 to int.
Could not serialize freq: 1 as json, so converting 1 to int.
Could not serialize count: 100 as json, so converting 100 to int.
./test.sh: line 26: python: command not found
write /dev/stdout: broken pipe
Error response from daemon: remove fullysupplayground-output-003e399a443aa7a64df0a6a62c19a538: volume is in use - [d8754619242a1d117c2833f5dc2b153b857afd3ddb68ac4639eddf0216595d4b]
This is the evaluation.py
import SimpleITK
import numpy as np
import scipy.ndimage
from evalutils import ClassificationEvaluation
from evalutils.io import SimpleITKLoader
from evalutils.validators import (
NumberOfCasesValidator, UniquePathIndicesValidator, UniqueImagesValidator
)
def compute_dice_coefficient(mask_gt, mask_pred):
volume_sum = mask_gt.sum() + mask_pred.sum()
if volume_sum == 0:
return np.NaN
volume_intersect = (mask_gt & mask_pred).sum()
return 2 * volume_intersect / volume_sum
class fullysupplayground(ClassificationEvaluation):
def __init__(self):
super().__init__(
file_loader=SimpleITKLoader(),
validators=(
NumberOfCasesValidator(num_cases=100),
UniquePathIndicesValidator(),
UniqueImagesValidator(),
),
)
def score_case(self, *, idx, case):
gt_path = case["path_ground_truth"]
pred_path = case["path_prediction"]
# Load the images for this case
gt = self._file_loader.load_image(gt_path)
pred = self._file_loader.load_image(pred_path)
# Check that they're the right images
if (self._file_loader.hash_image(gt) != case["hash_ground_truth"] or
self._file_loader.hash_image(pred) != case["hash_prediction"]):
raise RuntimeError("Images do not match")
gt_data = SimpleITK.GetArrayFromImage(gt).transpose(2, 1, 0)
gt_data = np.uint8(gt_data)
pred_data = SimpleITK.GetArrayFromImage(pred).transpose(2, 1, 0)
pred_data = np.uint8(pred_data)
# Score the case
DSCs = list()
for i in range(1, 5):
if np.sum(gt_data == i) == 0 and np.sum(pred_data == i) == 0:
DSC_i = 1
elif np.sum(gt_data == i) == 0 and np.sum(pred_data == i) > 0:
DSC_i = 0
else:
DSC_i = compute_dice_coefficient(gt_data == i, pred_data == i)
DSCs.append(DSC_i)
return {
'MeanDSC': np.mean(DSCs),
'LiverDSC': DSCs[0],
'KidneyDSC': DSCs[1],
'SpleenDSC': DSCs[2],
'PancreasDSC': DSCs[3],
'pred_fname': pred_path.name,
'gt_fname': gt_path.name,
}
if __name__ == "__main__":
fullysupplayground().evaluate()
and test.sh
#!/usr/bin/env bash
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
./build.sh
VOLUME_SUFFIX=$(dd if=/dev/urandom bs=32 count=1 | md5sum | cut --delimiter=' ' --fields=1)
docker volume create fullysupplayground-output-$VOLUME_SUFFIX
# Do not change any of the parameters to docker run, these are fixed
docker run --rm \
--memory="4g" \
--memory-swap="4g" \
--network="none" \
--cap-drop="ALL" \
--security-opt="no-new-privileges" \
--shm-size="128m" \
--pids-limit="256" \
-v $SCRIPTPATH/test/:/input/ \
-v fullysupplayground-output-$VOLUME_SUFFIX:/output/ \
fullysupplayground
docker run --rm \
-v fullysupplayground-output-$VOLUME_SUFFIX:/output/ \
python:3.9-slim cat /output/metrics.json | python -m json.tool
docker volume rm fullysupplayground-output-$VOLUME_SUFFIX
How can I fix this error? Any comments would be highly appreciated.