# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import pandas as pd
df = pd.read_csv('data/index.csv')

import numpy as np
msk = np.random.rand(len(df)) < 0.8

train = df[msk]
val = df[~msk]

len(train), len(val)

train.to_csv('data/train.csv', index=None)
val.to_csv('data/val.csv', index=None)

import torch
torch.cuda.is_available()

from torch.utils.tensorboard import SummaryWriter

import torch
batch_size = 32
image = torch.randn(batch_size, 3, 576, 576)

image.shape

mask = (image>0).float()

mask.shape

mask.max()

mask[:,0,:,:].shape

mask.shape

mask = torch.randn(3, 576, 576)

mask[0].unsqueeze(0).shape

fl = torch.flatten(image)

fl.shape

from sklearn.metrics import roc_curve, auc



fl = fl/fl.max()

fpr, tpr, thresholds = roc_curve(fl, fl)

fl

from PIL import Image
image = Image.open('data/mask/0.png')

image

import numpy as np
data = np.asarray(image)

data.max()

import torchvision.transforms.functional as F

a = F.to_tensor(image)
a.max()



StarcoderdataJupyterScriptsDedupFiltered