Closed zerodohero closed 3 years ago
Also, I'm going to command the following, and I'm going to make sure that the path is correct
Above is due to mismatch between 2 saving formats. Old version portion
pred_info = sio.loadmat(os.path.join(pred_dir, basename + ".mat"))
# dont squeeze, may be 1 instance exist
pred_centroid = (pred_info["inst_centroid"]).astype("float32")
pred_inst_type = (pred_info["inst_type"]).astype("int32")
if pred_centroid.shape[0] != 0:
pred_inst_type = pred_inst_type[:, 0]
else: # no instance at all
pred_centroid = np.array([[0, 0]])
pred_inst_type = np.array([0])
will match with this
with open('%s/%s.json' % (pred_dir, base_name), "r") as handle:
pred_info = json.load(handle)['nuc']
pred_centroid = np.array([v['centroid'] for v in pred_info.values()]).astype(np.float32)
pred_inst_type = np.array([v['type'] for v in pred_info.values()]).astype(np.int32)
del pred_info
if pred_centroid.shape[0] != 0:
pred_inst_type = pred_inst_type[:, 0]
else: # no instance at all
pred_centroid = np.array([[0, 0]])
pred_inst_type = np.array([0])
ok , However, I don't see it in the code with open('%s/%s.json' % (pred_dir, base_name), "r") as handle: pred_info = json.load(handle)['nuc'] pred_centroid = np.array([v['centroid'] for v in pred_info.values()]).astype(np.float32) pred_inst_type = np.array([v['type'] for v in pred_info.values()]).astype(np.int32) del pred_info
if pred_centroid.shape[0] != 0:
pred_inst_type = pred_inst_type[:, 0]
else: # no instance at all
pred_centroid = np.array([[0, 0]])
pred_inst_type = np.array([0])
To emphasize, I am using tiles, not WSI, and the code you mentioned is not in the latest version of compute_stats.py with open('%s/%s.json' % (pred_dir, base_name), "r") as handle: pred_info = json.load(handle)['nuc'] pred_centroid = np.array([v['centroid'] for v in pred_info.values()]).astype(np.float32) pred_inst_type = np.array([v['type'] for v in pred_info.values()]).astype(np.int32) del pred_info
if pred_centroid.shape[0] != 0:
pred_inst_type = pred_inst_type[:, 0]
else: # no instance at all
pred_centroid = np.array([[0, 0]])
pred_inst_type = np.array([0])
And I'm just replacing the block of code that you pointed out, so I get an error.I got an error after changing the path to JSON, because it was one-dimensional, but this code gave it a two-dimensional one.
Change
if pred_centroid.shape[0] != 0:
pred_inst_type = pred_inst_type[:, 0]
else: # no instance at all
pred_centroid = np.array([[0, 0]])
pred_inst_type = np.array([0])
to
# no instance at all
if pred_centroid.shape[0] == 0:
pred_centroid = np.array([[0, 0]])
pred_inst_type = np.array([0])
This portion is mainly for sanity check.
Close due to inactivity.
In compute_stats.py, there is the following code
true_centroid = (true_info["inst_centroid"]).astype("float32") true_inst_type = (true_info["inst_type"]).astype("int32") But there is no ["inst_centroid"] property in the predicted generated.mat file
So I ran compute_stats.py with the following error How do you fix the code??