Hello, I’m new to coding, I have a similar problem, and I was wondering if anyone would be able to help me out. I’m trying to create a Custom
ItemList that returns an image (an xray of a hand) along with either a 1 or a 0 as inputs (1 and 0 are for gender; 1 means male and 0 means female). The data set I’m using is from a pediatric bone age prediction challenge from 2017 (which has since ended). I’m trying to predict the age of the patient, based on the image and the gender.
Data can be found here.
More information can be found here.
This is what my dataframe looks like:
I’m trying to follow this tutorial on creating a Custom
ItemList however my custom
ItemList differs from the example in 2 ways: I’d like to have an image and a number as an input (instead of 2 images), and I’d like to use
.from_csv instead of
This is my attempt at a custom
def __init__(self, img1, gender):
self.img1,self.gender = img1,gender
self.obj,self.data = (img1,gender),[-1+2*img1.data,gender.data]
def __init__(self, items, itemsB=None, **kwargs):
self.itemsB = itemsB
def get(self, i):
img1 = super().get(i)
itemsB = df['IsMale']
gender = self.itemsB[i]
return ItemTuple(img1, gender)
When I attempt to create a databunch with this ItemList, I get an error:
<ipython-input-13-3410e54c85a8> in __init__(self, items, itemsB, **kwargs)
1 class ImageTupleList(ItemList):
2 def __init__(self, items, itemsB=None, **kwargs):
----> 3 super().__init__(items, **kwargs)
4 self.itemsB = itemsB
TypeError: __init__() got an unexpected keyword argument 'folder'
Or when I try to use the
ImageList class instead of
ItemList I get:
<ipython-input-10-d9d9dcb87708> in get(self, i)
12 img1 = super().get(i)
13 itemsB = df['IsMale']
---> 14 gender = self.itemsB[i]
15 return ImageTuple(img1, gender)
16 # def from_folders(cls, path, folderA, folderB, **kwargs):
TypeError: 'NoneType' object is not subscriptable
On github, I found a custom dataset loader for pytorch for this dataset available here under
class CelebaDataset(Dataset) ,however, I’m not sure how to plug this into the fastai library.
There may be a simple solution for someone who is more experienced but this has become a brick wall for a noob like myself, so if someone knows the answer and can show me how to do this that would be greatly appreciated!