Skip to content

Help on preparing dataset for finetuning MRI DICOM 3D data #59

@Ribin-Baby

Description

@Ribin-Baby

Hi, I was trying to finetune 'google/medgemma-1.5-4b-it' model on 3D brain MRI DICOM data. In the repository i can find examples on finetuning on single image slices but to finetune on 3D data, here is how i have curated the data,

{'images': [<PIL.Image.Image image mode=RGB size=224x224>,
  <PIL.Image.Image image mode=RGB size=224x224>,
  <PIL.Image.Image image mode=RGB size=224x224>,
  <PIL.Image.Image image mode=RGB size=224x224>,
  <PIL.Image.Image image mode=RGB size=224x224>,
  <PIL.Image.Image image mode=RGB size=224x224>,
  <PIL.Image.Image image mode=RGB size=224x224>,
  <PIL.Image.Image image mode=RGB size=224x224>],
 'messages': [{'role': 'system',
   'content': [{'type': 'text', 'text': 'You are an expert radiologist.'}]},
  {'role': 'user',
   'content': [{'type': 'image'},
    {'type': 'text', 'text': 'Slice 1'},
    {'type': 'image'},
    {'type': 'text', 'text': 'Slice 2'},
    {'type': 'image'},
    {'type': 'text', 'text': 'Slice 3'},
    {'type': 'image'},
    {'type': 'text', 'text': 'Slice 4'},
    {'type': 'image'},
    {'type': 'text', 'text': 'Slice 5'},
    {'type': 'image'},
    {'type': 'text', 'text': 'Slice 6'},
    {'type': 'image'},
    {'type': 'text', 'text': 'Slice 7'},
...
    {'type': 'text',
     'text': 'Analyze this brain MRI and provide the most likely diagnosis in one short phrase.'}]},
  {'role': 'assistant',
   'content': [{'type': 'text',
     'text': 'acute ischemic stroke left precentral gyrus'}]}]}    

The issue i was facing is was not able to include complete slices for finetuning, if i take all slices i was getting Out of memory error even with 2 L40 GPU with 48GB VRAM.

Can you provide an example training script for finetuning for DICOM dataset, is the way i prepared data was correct or not ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions