GAN class conditioning

Hi there,
I wonder what is the preferred / intended way to incorporate class labels into my GAN training? According to the GAN docu the DataBunch to throw into GAN training has noise as input and real images as labels. So where do I put my class labels?
Can I realize this with some functionality that let’s me have multiple different labels per input item? Does this kind of multi label thing exist somewhere? (not multi label classification, I’m talking an arbitrary mix of label types)

I made an attempt to this a few months ago, basically putting all my labels in a tuple, splitting this in a callback, passing on only one of the labels (otherwise weird stuff happened) and retrieving the others from the splitting callback. However this seemed kind of dirty and was unflexible (especially when you have to check for gen_mode in basically every callback). I assume there might be a more elegant way?

Can someone please point me where to find such functionality in fastai or clarify whether it exists?

You should have a custom ItemList that groups image and class as a target, then if you adapt your loss function (the generator side) it should work without any hack.

1 Like