<jupyter_start><jupyter_text>path for Dataset<jupyter_code>seed = 42
random_seed(seed,True)

path = Path('./')
path_img = Path('./img(random)_10000_3ch')
path_lbl = Path('./gt(random)_10000_3ch')
fnames = get_image_files(path_img)
lbl_names = get_image_files(path_lbl)

print(f"fnames : {fnames[:3]}, label names : {lbl_names[:3]}")<jupyter_output><empty_output><jupyter_text>Checking Data<jupyter_code>img_f = fnames[0]
img = open_image(img_f)
img.show(figsize=(5,5), cmap='gray')
get_y_fn = lambda x: path_lbl/f'{x.stem}_P{x.suffix}'
mask = open_mask(get_y_fn(img_f))
mask.show(figsize=(5,5), alpha=1)

src_size = np.array(mask.shape[1:])
print(f"image size : {src_size}")<jupyter_output><empty_output><jupyter_text>Label Codes<jupyter_code>codes = np.array(['Void', 'Fat', 'Muscle', 'Visceral_fat'], dtype=str); codes
name2id = {v:k for k,v in enumerate(codes)}
void_code = name2id['Void']<jupyter_output><empty_output><jupyter_text>Define Noise for fastai<jupyter_code>rn = TfmPixel(r_noise)
tfms = get_transforms(flip_vert=True, max_rotate=180.0, max_zoom=1.5, max_warp = 0.2 )
new_tfms = (tfms[0] + [rn()], tfms[1])
new_tfms[0][7].use_on_y = False
new_tfms[0][7].p = 0.5
size = src_size<jupyter_output><empty_output><jupyter_text>Checking GPU<jupyter_code>free = gpu_mem_get_free_no_cache()
# the max size of bs depends on the available GPU RAM
if free > 8200: bs=4
else:           bs=2
print(f"using bs={bs}, have {free}MB of GPU RAM free")<jupyter_output><empty_output><jupyter_text>Define DataLoaders<jupyter_code>src = (SegmentationItemList.from_folder(path_img)
       .split_by_rand_pct(valid_pct=0.1)
       .label_from_func(get_y_fn, classes=codes))
data = (src.transform(new_tfms, size=size, tfm_y=True)
        .databunch(bs=bs, num_workers=0)
        .normalize(imagenet_stats))<jupyter_output><empty_output><jupyter_text>Training Models<jupyter_code>loss_func = CombinedLoss
metrics = [ dice,acc_camvid ]
wd = 1e-2

learn = unet_learner(data, models.resnet34, loss_func = loss_func(), metrics=metrics)
lr_find(learn)
learn.recorder.plot()
lr = 3e-4
learn.summary()
learn.fit_one_cycle(10, lr)<jupyter_output><empty_output><jupyter_text>Save Models<jupyter_code>learn.save(f"path - ")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1537427162707306, 'fraction_numerical': 0.025997310623038995, 'mean_word_length': 7.78740157480315, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '547260', 'license': 'MIT', 'n_tokens_mistral': 968, 'n_tokens_neox': 934, 'n_words': 134, 'path': 'src/train.ipynb', 'repo_name': 'hwanseung2/Asan-segmentation', 'size': '2231'}