Core espiownage parts
sysinfo()
path = get_data('spnet'); path
path = get_checkpoint('segreg'); path
meta_to_img_path('annotations/06241902_proc_00023.csv')
meta_to_mask_path('annotations/06241902_proc_00023.csv')
assert meta_from_str('06241902_proc_00510_0_45_88_236_1.0.csv') == '06241902_proc_00510.csv'
assert meta_from_str('06241902_proc_00510_0_45_88_236.csv') == '06241902_proc_00510.csv'
assert meta_from_str('06241902_proc_00510.png') == '06241902_proc_00510.csv'
file_list = ['annotations_shawley/06241902_proc_00000.csv', 'annotations_shawley/06240907_proc_01001.csv', 'annotations_shawley/06241902_proc_00004.csv', 'annotations_shawley/06240907_proc_01756.csv', 'annotations_shawley/06241902_proc_00009.csv', 'annotations_shawley/06241902_proc_00013.csv']
top_loss_list = ['06241902_proc_00510_0_45_88_236_1.0', '06240907_proc_01001_0_115_187_322_2.4', '06240907_proc_01197_0_105_185_338_3.33', '06241902_proc_00986_136_73_293_214_2.0', '06241902_proc_01468_0_58_81_211_3.75', '06240907_proc_01756_0_132_158_315_1.3', '06240907_proc_01101_0_101_172_326_4.0']
print("file_list =",file_list)
print("\ntop_lost_list =",top_loss_list)
out = combine_file_and_tl_lists(file_list, top_loss_list)
print("\nout = ",out)
fix_abangle(5,10,-20)
import matplotlib.pyplot as plt
height, width = 512,384
cx, cy, a, b, angle = 157, 213, 85, 67, 45
img = np.zeros((width, height), dtype=np.uint8) # numpy w/h is "backwards" to images
img = draw_ellipse(img, (cx,cy), (a,b), angle, color=100, filled=False)
plt.imshow(img)
Let's check what "colors" are in that file, e.g. to make sure there's no anti-aliasing
print("'colors' =",set(np.array(img).flatten()))
And again, a filled version:
img = draw_ellipse(img, (cx,cy), (a,b), angle, color=100, filled=True)
print("'colors' =",set(np.array(img).flatten()))
plt.imshow(img)
bb = ellipse_to_bbox(cx, cy, a, b, angle)
print("bbox = ",bb)
img = cv2.rectangle(img, bb[0:2], bb[2:4], color=50, thickness=2)
print("'colors' =",set(np.array(img).flatten()))
plt.imshow(img)
ellipse_to_bbox(cx, cy, a, b, angle, coco=True)
ellipse_to_bbox(0, 0, 0, 0, 0) # check for (graceful handling of) errors
ring_float_to_class_int(10.5, 0.1), ring_float_to_class_int(10.5, 0.2), ring_float_to_class_int(10.5, 1)
from matplotlib.pyplot import imshow
imshow(crop_to_bbox(img, bb))
bb_bad = crop_to_bbox(img, [-100,-100,-10,10])
Hopefully we didn't crop in place and the original full-size image is still there?
plt.imshow(img)
assert is_in_box((100,100),(10,30,180,50)) == False
assert is_in_box((100,100),(10,30,180,150)) == True
Let's test this metric:
a = torch.rand(10)
b = a + torch.rand(10)
print(a)
print(b)
tol = 0.7
print( (a - b).abs() < tol)
print(acc_reg(a,b,bin_size=tol))
We'll use a few predefined intervals:
data = list(range(10))
nk = 5
for k in range(nk):
print(kfold_split(data, k))