Example for GANLearner / GANItemList?

I’m working through using the GANLearner in v1.0.39, utilizing images stored in a pandas dataframe. However, I’m running into a variety of problems which I suspect are more a result of not understanding how to properly use the GANItemList and GANLearner than any specific bugs.

Does anyone have a tutorial or example of how they’ve used the GANItemList and GANLearner?

For reference, here is what my code looks like. I am fairly confident in my dataframe (and the general itemlist/databunch code) as I’ve been using it for a CNN image classifier.

fastai_image_databunch = (GANItemList.from_df(df=dataframe, path='/data/images/files', folder='thumbs/lg', cols='image_path')
                     .random_split_by_pct(valid_pct=validation_percent, seed=random_seed)
                     .label_from_df(cols='categories_labels')
                     .transform(tfms, size=image_size)
                     .databunch(bs=batch_size))

fastai_critic = basic_critic(64, 3)
fastai_generator = basic_generator(64,3)
fastai_wgan_learner = GANLearner.wgan(fastai_image_databunch, fastai_generator, fastai_critic)

fastai_wgan_learner.fit(epoch_size, learner_rate)

Using this code, I run into the following errors:
When creating the GANItemList: UserWarning: There seems to be something wrong with your dataset, can't access self.train_ds[i] for all i in ...
and
When fitting the GANLearner: site-packages/PIL/Image.py", line 2613, in open fp.seek(0) AttributeError: 'list' object has no attribute 'seek'

Thanks!

1 Like

There is an example in the last lesson. Note that GANItemList will give you a noisy vector as inputs and an image as outputs, if you want image to image, you should use ImageImageList.

1 Like

Fantastic, exactly what I was looking for. Thanks!

That example is great for generating images from a random seed. Any idea how to feed the generator an existing image (instead of a random image) and have it transform it to the output domain?