Kaggle最速入门:318场TOP方案,学完就上手!

Kaggle比赛,绝对是同学们提升背景性价比最高的途径!一段KagglePrizeWinner经历,让你在众多竞争者中脱颖而出,为申请、求职起到强有力的背书。

很多同学担心自己的比赛经验不多,无法上手。其实在入门的时候,多学习Kaggle大神的TOP方案是一个找到比赛思路的高效方法。我总结了318场比赛TOP方案,有需要的同学可以扫码领取。

扫码回复“比赛

318篇TOP方案
96ff4ce30c31e6b06c9bde98d8d753e8.png

最近Kaggle也发布了一个CV方向的比赛:RSNA 2023 Abdominal Trauma Detection 腹部创伤检测竞赛。适合同学们进行实战练习。

我专门联合Kaggle前1000大神Mozak老师,带来本次比赛的赛题讲座为大家详解高分Baseline。讲座免费观看,扫码就能解锁。

扫码回复“比赛

赛题讲座免费看

ba280df477048ab20b7d26998fdd6227.png

本次比赛的思路为:

数据预处理和图像特征提取

使用Python库如pydicom来加载这些图像。由于DICOM数据可能包含多个图像序列,可以根据patient_id和series_id将它们组织起来。

模型选择

可以选择使用经典的卷积神经网络架构,如ResNet、DenseNet或EfficientNet。

模型训练和验证

将数据分为训练集和验证集,用于训练和调整模型。

模型推断和测试集评估

在训练好的模型上进行推断,对测试集中的图像进行预测。

扫码回复“比赛

赛题讲座免费看

28094519dc838838e67fffeb95394359.png

以下为部分关键代码:

 将DICOM转换为jpg

def dicom_to_image(dicom_image):
    """
    Read the dicom file and preprocess appropriately.
    """
    pixel_array = dicom_image.pixel_array
    
    if dicom_image.PixelRepresentation == 1:
        bit_shift = dicom_image.BitsAllocated - dicom_image.BitsStored
        dtype = pixel_array.dtype 
        new_array = (pixel_array << bit_shift).astype(dtype) >>  bit_shift
        pixel_array = pydicom.pixel_data_handlers.util.apply_modality_lut(new_array, dicom_image)
    
    if dicom_image.PhotometricInterpretation == "MONOCHROME1":
        pixel_array = 1 - pixel_array
    
    # transform to hounsfield units
    intercept = dicom_image.RescaleIntercept
    slope = dicom_image.RescaleSlope
    pixel_array = pixel_array * slope + intercept
    
    # windowing
    window_center = int(dicom_image.WindowCenter)
    window_width = int(dicom_image.WindowWidth)
    img_min = window_center - window_width // 2
    img_max = window_center + window_width // 2
    pixel_array = pixel_array.copy()
    pixel_array[pixel_array < img_min] = img_min
    pixel_array[pixel_array > img_max] = img_max
    
    # normalization
    pixel_array = (pixel_array - pixel_array.min())/(pixel_array.max() - pixel_array.min())
    
    return (pixel_array * 255).astype(np.uint8)

 模型预测

pred_list = []
for pid in train_pids[:10]:    
    pid_paths_dcm_paths = glob.glob('/kaggle/input/rsna-2023-abdominal-trauma-detection/train_images/' + str(pid) + '/*/*')
    pid_paths_dcm_paths.sort()
    
    pid_paths_dcm_paths = pid_paths_dcm_paths[-5:]
    imgs = [Image.fromarray(dicom_to_image(pydicom.read_file(x))) for x in pid_paths_dcm_paths]
    imgs = [transform(x) for x in imgs]
    
    imgs = torch.cat(imgs, 0)
    imgs = imgs[:, None, :, :]
    with torch.no_grad():
        imgs = imgs.cuda()
        output = model(imgs)[:, :-1]
        pred = torch.sigmoid(output).data.cpu().numpy().round(3)
        pred = pred.mean(0)
        
    pred_list.append(pred)

扫码回复“比赛

赛题讲座免费看

e8694661481dfd9116145e2f049194df.png

a553ce0fca825459aeb5e3f569e4b7c0.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值