{
  "id": 104281,
  "title": "When BigGAN met StyleGAN (public 12.4 solution)",
  "url": "/competitions/generative-dog-images/writeups/bestfitting-when-biggan-met-stylegan-public-12-4-s",
  "author_name": "",
  "post_date": "2019-08-29T06:58:46.987Z",
  "votes": 133,
  "comment_count": 40,
  "views": 0,
  "content": "<p>It's an interesting competition, and this is the first time I write a solution without knowing private LB score. Great thanks to kaggle for the efforts to host this competition and quick response to the community by <a href=\"/juliaelliott\">@juliaelliott</a>, <a href=\"/wendykan\">@wendykan</a>. </p>\n\n<p>My solution may be described as a mix of StyleGAN and BigGAN.</p>\n\n<p>Respect to the authors of the  papers and these two github repositories:\n<a href=\"https://github.com/ajbrock/BigGAN-PyTorch\">https://github.com/ajbrock/BigGAN-PyTorch</a>\n<a href=\"https://github.com/rosinality/style-based-gan-pytorch\">https://github.com/rosinality/style-based-gan-pytorch</a></p>\n\n<p><strong>Challenges</strong>:\n1. Limited resources and limited time  to train a GAN from scratch.\n2. A new kind of challenge with new rules and settings. It took me 2 weeks to choose between this one and the Youbute 8M video challenge.</p>\n\n<p><strong>Solution</strong>:</p>\n\n<p>I tried DCGAN and ACGAN to get familiar with this competition at first , and then select papers related, I selected about 40 papers which might be useful.</p>\n\n<p>I was impressed by the results of the StyleGAN and tried to make it work more efficiently so I could make it run in a kernel, but I found Progressive GAN and its followers were inefficient to train,  but I still spent about 10 days to tune it and got  FID about 35 , I guessed that this score was not enough to top 10, but I thought I should spend more time on it to get understanding of every detail of it before I stepped forward.</p>\n\n<p>Then I tried VQ-VAE2 and a lot of other mechanisms and I was not satisfied with the efficiency and the scores.</p>\n\n<p>BigGAN was listed on the top of my most promising solutions, but the <strong>BIG</strong>, <strong>DEEP</strong>  in the model name prevent me from trying it in a hurry and the paper stated that using more channels was important, I worried that it might be inefficient in this competition, so I planed to try it after I have tested others. To my surprise, the channels was not so important, when I decreased the G_ch and D_ch from 64 to 24, the FID score did not decrease too much and the FID score can easily reach below 30.</p>\n\n<p>What's more, the project structure of the  <a href=\"https://github.com/ajbrock/BigGAN-PyTorch\">https://github.com/ajbrock/BigGAN-PyTorch</a> is very good, we can do a lot of experiments by just modifying some parameters, so I could start many experiments and went out have a bicycle driving or swimming :)  After several experiments, my score reached about 24. </p>\n\n<p>After I checked and compared the architecture and mechanisms of the  Big and Style GAN, I found that Spectral normalization and Class-conditional Batch  normalization were important to BigAN, so we need not use progressive training,  and BigGAN's G_shared and skip_z mechanisms were similar to the StyleGAN's style mechanism to some extend, so I made a lot of modifications to BigGAN and tried to move almost all important  mechanisms of StyleGAN to it. After many experiments, I found: Style mechanism could improve the score significantly and coverage more quickly, the Blur was also important, Noise was not so important, to save time, I did not add it to my networks.  Since I had more efficient and powerful  tools for the BigGAN, so I did not use skip_z.  I found mix-style mechanism of StyleGAN was not important in this competition, so I did not use it in my final submission. After these efforts and some hyper-parameters tuning, the score can reach about 17. </p>\n\n<p>I thought I might use large image size to train the network, so I designed a 96x96 model instead of 64x64, I found it could improve the score.</p>\n\n<p>I tried to use Attention including BigGAN's attention and CBAM  in the network, it increased the training time and the improvement to the score was not so big, so I did not use them</p>\n\n<p>To my surprise, although the paper of BigGAN stated that the larger batch-size, the better result, I found 32 was the best batch-size. So the two most important results--large channels and bigger batch-size of the BigGAN were not suitable of this dataset, so my solution should be called <strong>Style-Small-GAN</strong> ??  :smile::smile:</p>\n\n<p>My best parameters can be described as the following command:</p>\n\n<pre>python train.py --shuffle --batch_size 32 --num_G_accumulations 1 --num_D_accumulations 1 --num_epochs 200 --num_D_steps 1 --G_lr 1e-4 --D_lr 6e-4 --dataset DogOrigin96 --bottom_width 6 --G_ortho 0.0 --G_attn 0 --D_attn 0 --G_init ortho --D_init ortho --ema --use_ema --ema_start 2000 --test_every 25 --save_every 10 --num_best_copies 5 --num_save_copies 2 --G_ch 24 --D_ch 24 --seed 0 --augment 1 --add_blur --add_style --crop_mode 8  --on_kaggle --experiment_name i96_ch24_hinge_ema_dstep1_bs32_noatt_glr0001_glr0006_aug_init_ortho_blur_style_origin_crop_mode8\n</pre>\n\n<p>The score  improved to  <strong>12.4</strong> on public LB after these steps</p>\n\n<p>In the last several days of this competition, I turned to the model's generalization and the data itself, I found that if I cropped square box containing the dogs only, it performed better than adding resized origin images, but, as kaggle will use another datasets and my models were trained on all-dogs datasets,  they might over-fit to the cropped all-dogs to some extend, when my models were applied on other images, the dogs might not be cropped,  so I added resized origin images to the datasets with some probability. The score on public LB of this augmentation is <strong>13.4</strong>, but I guess this model may perform better than 12.4 one.</p>\n\n<p>I also added all kinds of mechanisms , such as mode seeking, all kinds of loss functions such as such as GDPP, normalizations, regularizations , initializations, and most of them did not work.</p>\n\n<p>Most of mechanism I talked above are kept in the kernels and can be tested by using the parameters. If you want to have a try, 100 epochs in 4.5h can reach FID 18.x, and 125 epochs can reach FID 15.x</p>\n\n<p><strong>What can we do to improve the model if there are no limits on the resources and time?</strong>\n1. I designed a mechanism to add dog count in an image to the model, that's to say, dog count embedding. It works, but it took more time. \n2. We can still cluster the images to 30-40 clusters, use these cluster id as other embedding, so, the dog on the grass, floor..... ( I did not test it )\n3. We can use large sized images.</p>\n\n<p>So the FID less than 10 is not so difficult to achieve if we have two GPUs or double time. \n1 and 2 can be described as Multi-Classes-Conditional Style GAN,  with the mixture of the Style and BigGAN, after some well designed experiments we may make some progress to the state of the art GANs?\nYou can check some of images, a type of dogs per line:\n<a href=\"https://raw.githubusercontent.com/bestfitting/kaggle/master/gandogs/samples/samples_mode8.jpg\">https://raw.githubusercontent.com/bestfitting/kaggle/master/gandogs/samples/samples_mode8.jpg</a></p>\n\n<p>The link to my kernels:\n<a href=\"https://www.kaggle.com/bestfitting/i96-1e-4-6e-4-bs32-195\">https://www.kaggle.com/bestfitting/i96-1e-4-6e-4-bs32-195</a>\n<a href=\"https://www.kaggle.com/bestfitting/i96-crop-mode3-dstep1-1e-4-6e-4-bs32\">https://www.kaggle.com/bestfitting/i96-crop-mode3-dstep1-1e-4-6e-4-bs32</a></p>\n\n<p><b>Updated</b>\nThe source codes in the  kennels above are not easy to read, you can check the normal python project structure version here <a href=\"https://github.com/bestfitting/kaggle/tree/master/gandogs\">https://github.com/bestfitting/kaggle/tree/master/gandogs</a></p>\n\n<hr>\n\n<p><em>Please note that the progresses and the scores of my models are not a formal ablation study in a paper and I don't plan to write a paper either, I modified the parameters and other setting during these progresses, they were results of a series of complex experiment setting.</em></p>",
  "messages": [
    {
      "id": "600170",
      "postDate": "08/15/2019 18:40:24",
      "content": "<p>It's an interesting competition, and this is the first time I write a solution without knowing private LB score. Great thanks to kaggle for the efforts to host this competition and quick response to the community by <a href=\"/juliaelliott\">@juliaelliott</a>, <a href=\"/wendykan\">@wendykan</a>. </p>\n\n<p>My solution may be described as a mix of StyleGAN and BigGAN.</p>\n\n<p>Respect to the authors of the  papers and these two github repositories:\n<a href=\"https://github.com/ajbrock/BigGAN-PyTorch\">https://github.com/ajbrock/BigGAN-PyTorch</a>\n<a href=\"https://github.com/rosinality/style-based-gan-pytorch\">https://github.com/rosinality/style-based-gan-pytorch</a></p>\n\n<p><strong>Challenges</strong>:\n1. Limited resources and limited time  to train a GAN from scratch.\n2. A new kind of challenge with new rules and settings. It took me 2 weeks to choose between this one and the Youbute 8M video challenge.</p>\n\n<p><strong>Solution</strong>:</p>\n\n<p>I tried DCGAN and ACGAN to get familiar with this competition at first , and then select papers related, I selected about 40 papers which might be useful.</p>\n\n<p>I was impressed by the results of the StyleGAN and tried to make it work more efficiently so I could make it run in a kernel, but I found Progressive GAN and its followers were inefficient to train,  but I still spent about 10 days to tune it and got  FID about 35 , I guessed that this score was not enough to top 10, but I thought I should spend more time on it to get understanding of every detail of it before I stepped forward.</p>\n\n<p>Then I tried VQ-VAE2 and a lot of other mechanisms and I was not satisfied with the efficiency and the scores.</p>\n\n<p>BigGAN was listed on the top of my most promising solutions, but the <strong>BIG</strong>, <strong>DEEP</strong>  in the model name prevent me from trying it in a hurry and the paper stated that using more channels was important, I worried that it might be inefficient in this competition, so I planed to try it after I have tested others. To my surprise, the channels was not so important, when I decreased the G_ch and D_ch from 64 to 24, the FID score did not decrease too much and the FID score can easily reach below 30.</p>\n\n<p>What's more, the project structure of the  <a href=\"https://github.com/ajbrock/BigGAN-PyTorch\">https://github.com/ajbrock/BigGAN-PyTorch</a> is very good, we can do a lot of experiments by just modifying some parameters, so I could start many experiments and went out have a bicycle driving or swimming :)  After several experiments, my score reached about 24. </p>\n\n<p>After I checked and compared the architecture and mechanisms of the  Big and Style GAN, I found that Spectral normalization and Class-conditional Batch  normalization were important to BigAN, so we need not use progressive training,  and BigGAN's G_shared and skip_z mechanisms were similar to the StyleGAN's style mechanism to some extend, so I made a lot of modifications to BigGAN and tried to move almost all important  mechanisms of StyleGAN to it. After many experiments, I found: Style mechanism could improve the score significantly and coverage more quickly, the Blur was also important, Noise was not so important, to save time, I did not add it to my networks.  Since I had more efficient and powerful  tools for the BigGAN, so I did not use skip_z.  I found mix-style mechanism of StyleGAN was not important in this competition, so I did not use it in my final submission. After these efforts and some hyper-parameters tuning, the score can reach about 17. </p>\n\n<p>I thought I might use large image size to train the network, so I designed a 96x96 model instead of 64x64, I found it could improve the score.</p>\n\n<p>I tried to use Attention including BigGAN's attention and CBAM  in the network, it increased the training time and the improvement to the score was not so big, so I did not use them</p>\n\n<p>To my surprise, although the paper of BigGAN stated that the larger batch-size, the better result, I found 32 was the best batch-size. So the two most important results--large channels and bigger batch-size of the BigGAN were not suitable of this dataset, so my solution should be called <strong>Style-Small-GAN</strong> ??  :smile::smile:</p>\n\n<p>My best parameters can be described as the following command:</p>\n\n<pre>python train.py --shuffle --batch_size 32 --num_G_accumulations 1 --num_D_accumulations 1 --num_epochs 200 --num_D_steps 1 --G_lr 1e-4 --D_lr 6e-4 --dataset DogOrigin96 --bottom_width 6 --G_ortho 0.0 --G_attn 0 --D_attn 0 --G_init ortho --D_init ortho --ema --use_ema --ema_start 2000 --test_every 25 --save_every 10 --num_best_copies 5 --num_save_copies 2 --G_ch 24 --D_ch 24 --seed 0 --augment 1 --add_blur --add_style --crop_mode 8  --on_kaggle --experiment_name i96_ch24_hinge_ema_dstep1_bs32_noatt_glr0001_glr0006_aug_init_ortho_blur_style_origin_crop_mode8\n</pre>\n\n<p>The score  improved to  <strong>12.4</strong> on public LB after these steps</p>\n\n<p>In the last several days of this competition, I turned to the model's generalization and the data itself, I found that if I cropped square box containing the dogs only, it performed better than adding resized origin images, but, as kaggle will use another datasets and my models were trained on all-dogs datasets,  they might over-fit to the cropped all-dogs to some extend, when my models were applied on other images, the dogs might not be cropped,  so I added resized origin images to the datasets with some probability. The score on public LB of this augmentation is <strong>13.4</strong>, but I guess this model may perform better than 12.4 one.</p>\n\n<p>I also added all kinds of mechanisms , such as mode seeking, all kinds of loss functions such as such as GDPP, normalizations, regularizations , initializations, and most of them did not work.</p>\n\n<p>Most of mechanism I talked above are kept in the kernels and can be tested by using the parameters. If you want to have a try, 100 epochs in 4.5h can reach FID 18.x, and 125 epochs can reach FID 15.x</p>\n\n<p><strong>What can we do to improve the model if there are no limits on the resources and time?</strong>\n1. I designed a mechanism to add dog count in an image to the model, that's to say, dog count embedding. It works, but it took more time. \n2. We can still cluster the images to 30-40 clusters, use these cluster id as other embedding, so, the dog on the grass, floor..... ( I did not test it )\n3. We can use large sized images.</p>\n\n<p>So the FID less than 10 is not so difficult to achieve if we have two GPUs or double time. \n1 and 2 can be described as Multi-Classes-Conditional Style GAN,  with the mixture of the Style and BigGAN, after some well designed experiments we may make some progress to the state of the art GANs?\nYou can check some of images, a type of dogs per line:\n<a href=\"https://raw.githubusercontent.com/bestfitting/kaggle/master/gandogs/samples/samples_mode8.jpg\">https://raw.githubusercontent.com/bestfitting/kaggle/master/gandogs/samples/samples_mode8.jpg</a></p>\n\n<p>The link to my kernels:\n<a href=\"https://www.kaggle.com/bestfitting/i96-1e-4-6e-4-bs32-195\">https://www.kaggle.com/bestfitting/i96-1e-4-6e-4-bs32-195</a>\n<a href=\"https://www.kaggle.com/bestfitting/i96-crop-mode3-dstep1-1e-4-6e-4-bs32\">https://www.kaggle.com/bestfitting/i96-crop-mode3-dstep1-1e-4-6e-4-bs32</a></p>\n\n<p><b>Updated</b>\nThe source codes in the  kennels above are not easy to read, you can check the normal python project structure version here <a href=\"https://github.com/bestfitting/kaggle/tree/master/gandogs\">https://github.com/bestfitting/kaggle/tree/master/gandogs</a></p>\n\n<hr>\n\n<p><em>Please note that the progresses and the scores of my models are not a formal ablation study in a paper and I don't plan to write a paper either, I modified the parameters and other setting during these progresses, they were results of a series of complex experiment setting.</em></p>",
      "rawMarkdown": "It's an interesting competition, and this is the first time I write a solution without knowing private LB score. Great thanks to kaggle for the efforts to host this competition and quick response to the community by @juliaelliott, @wendykan. \n\nMy solution may be described as a mix of StyleGAN and BigGAN.\n\nRespect to the authors of the  papers and these two github repositories:\nhttps://github.com/ajbrock/BigGAN-PyTorch\nhttps://github.com/rosinality/style-based-gan-pytorch\n\n\n**Challenges**:\n1. Limited resources and limited time  to train a GAN from scratch.\n2. A new kind of challenge with new rules and settings. It took me 2 weeks to choose between this one and the Youbute 8M video challenge.\n\n**Solution**:\n\nI tried DCGAN and ACGAN to get familiar with this competition at first , and then select papers related, I selected about 40 papers which might be useful.\n\nI was impressed by the results of the StyleGAN and tried to make it work more efficiently so I could make it run in a kernel, but I found Progressive GAN and its followers were inefficient to train,  but I still spent about 10 days to tune it and got  FID about 35 , I guessed that this score was not enough to top 10, but I thought I should spend more time on it to get understanding of every detail of it before I stepped forward.\n\nThen I tried VQ-VAE2 and a lot of other mechanisms and I was not satisfied with the efficiency and the scores.\n\nBigGAN was listed on the top of my most promising solutions, but the **BIG**, **DEEP**  in the model name prevent me from trying it in a hurry and the paper stated that using more channels was important, I worried that it might be inefficient in this competition, so I planed to try it after I have tested others. To my surprise, the channels was not so important, when I decreased the G\\_ch and D\\_ch from 64 to 24, the FID score did not decrease too much and the FID score can easily reach below 30.\n\nWhat's more, the project structure of the  https://github.com/ajbrock/BigGAN-PyTorch is very good, we can do a lot of experiments by just modifying some parameters, so I could start many experiments and went out have a bicycle driving or swimming :)  After several experiments, my score reached about 24. \n\nAfter I checked and compared the architecture and mechanisms of the  Big and Style GAN, I found that Spectral normalization and Class-conditional Batch  normalization were important to BigAN, so we need not use progressive training,  and BigGAN's G_shared and skip\\_z mechanisms were similar to the StyleGAN's style mechanism to some extend, so I made a lot of modifications to BigGAN and tried to move almost all important  mechanisms of StyleGAN to it. After many experiments, I found: Style mechanism could improve the score significantly and coverage more quickly, the Blur was also important, Noise was not so important, to save time, I did not add it to my networks.  Since I had more efficient and powerful  tools for the BigGAN, so I did not use skip\\_z.  I found mix-style mechanism of StyleGAN was not important in this competition, so I did not use it in my final submission. After these efforts and some hyper-parameters tuning, the score can reach about 17. \n\nI thought I might use large image size to train the network, so I designed a 96x96 model instead of 64x64, I found it could improve the score.\n\nI tried to use Attention including BigGAN's attention and CBAM  in the network, it increased the training time and the improvement to the score was not so big, so I did not use them\n\nTo my surprise, although the paper of BigGAN stated that the larger batch-size, the better result, I found 32 was the best batch-size. So the two most important results--large channels and bigger batch-size of the BigGAN were not suitable of this dataset, so my solution should be called **Style-Small-GAN** ??  :smile::smile:\n\nMy best parameters can be described as the following command:\n<pre>python train.py --shuffle --batch_size 32 --num_G_accumulations 1 --num_D_accumulations 1 --num_epochs 200 --num_D_steps 1 --G_lr 1e-4 --D_lr 6e-4 --dataset DogOrigin96 --bottom_width 6 --G_ortho 0.0 --G_attn 0 --D_attn 0 --G_init ortho --D_init ortho --ema --use_ema --ema_start 2000 --test_every 25 --save_every 10 --num_best_copies 5 --num_save_copies 2 --G_ch 24 --D_ch 24 --seed 0 --augment 1 --add_blur --add_style --crop_mode 8  --on_kaggle --experiment_name i96_ch24_hinge_ema_dstep1_bs32_noatt_glr0001_glr0006_aug_init_ortho_blur_style_origin_crop_mode8\n</pre>\nThe score  improved to  **12.4** on public LB after these steps\n\nIn the last several days of this competition, I turned to the model's generalization and the data itself, I found that if I cropped square box containing the dogs only, it performed better than adding resized origin images, but, as kaggle will use another datasets and my models were trained on all-dogs datasets,  they might over-fit to the cropped all-dogs to some extend, when my models were applied on other images, the dogs might not be cropped,  so I added resized origin images to the datasets with some probability. The score on public LB of this augmentation is **13.4**, but I guess this model may perform better than 12.4 one.\n\nI also added all kinds of mechanisms , such as mode seeking, all kinds of loss functions such as such as GDPP, normalizations, regularizations , initializations, and most of them did not work.\n\nMost of mechanism I talked above are kept in the kernels and can be tested by using the parameters. If you want to have a try, 100 epochs in 4.5h can reach FID 18.x, and 125 epochs can reach FID 15.x\n\n**What can we do to improve the model if there are no limits on the resources and time?**\n1. I designed a mechanism to add dog count in an image to the model, that's to say, dog count embedding. It works, but it took more time. \n2. We can still cluster the images to 30-40 clusters, use these cluster id as other embedding, so, the dog on the grass, floor..... ( I did not test it )\n3. We can use large sized images.\n\nSo the FID less than 10 is not so difficult to achieve if we have two GPUs or double time. \n1 and 2 can be described as Multi-Classes-Conditional Style GAN,  with the mixture of the Style and BigGAN, after some well designed experiments we may make some progress to the state of the art GANs?\nYou can check some of images, a type of dogs per line:\nhttps://raw.githubusercontent.com/bestfitting/kaggle/master/gandogs/samples/samples_mode8.jpg\n\nThe link to my kernels:\nhttps://www.kaggle.com/bestfitting/i96-1e-4-6e-4-bs32-195\nhttps://www.kaggle.com/bestfitting/i96-crop-mode3-dstep1-1e-4-6e-4-bs32\n\n<b>Updated</b>\nThe source codes in the  kennels above are not easy to read, you can check the normal python project structure version here https://github.com/bestfitting/kaggle/tree/master/gandogs\n\n\n<hr>\n\n*Please note that the progresses and the scores of my models are not a formal ablation study in a paper and I don't plan to write a paper either, I modified the parameters and other setting during these progresses, they were results of a series of complex experiment setting.*",
      "votes": null
    },
    {
      "id": "600211",
      "postDate": "08/15/2019 19:52:37",
      "content": "<p>10 thumbs up!! Amazing work Bestfitting. I like how you combined the best features of multiple top performing GANs and invented your own GAN.</p>\n\n<p>For those that are interested, below are images from Bestfitting's two posted solutions. Check out the double headed dog in the bottom images in row 5 column 8 :-)</p>\n\n<h1>Samples from i96-1e-4-6e-4-bs32-195</h1>\n\n<p><img src=\"http://playagricola.com/Kaggle/dogs1b81419.png\" alt=\"image\"></p>\n\n<h1>Samples from i96-crop-mode3-dstep1-1e-4-6e-4-bs32</h1>\n\n<p><img src=\"http://playagricola.com/Kaggle/dogs2b81419.png\" alt=\"image\"></p>",
      "rawMarkdown": "10 thumbs up!! Amazing work Bestfitting. I like how you combined the best features of multiple top performing GANs and invented your own GAN.\n  \nFor those that are interested, below are images from Bestfitting's two posted solutions. Check out the double headed dog in the bottom images in row 5 column 8 :-)\n# Samples from i96-1e-4-6e-4-bs32-195\n![image](http://playagricola.com/Kaggle/dogs1b81419.png)\n# Samples from i96-crop-mode3-dstep1-1e-4-6e-4-bs32\n![image](http://playagricola.com/Kaggle/dogs2b81419.png)",
      "votes": null
    },
    {
      "id": "600212",
      "postDate": "08/15/2019 19:56:53",
      "content": "<p>Nice solution, thanks!\nI have similar findings about batch size and the number of channels in BigGAN model</p>",
      "rawMarkdown": "Nice solution, thanks!\nI have similar findings about batch size and the number of channels in BigGAN model",
      "votes": null
    },
    {
      "id": "600240",
      "postDate": "08/15/2019 20:35:30",
      "content": "<p>I have just put a link in my main post, you can check the images, a class of dogs per line.  When the metric is  FID,  the variety is important.</p>",
      "rawMarkdown": "I have just put a link in my main post, you can check the images, a class of dogs per line.  When the metric is  FID,  the variety is important.",
      "votes": null
    },
    {
      "id": "600244",
      "postDate": "08/15/2019 20:40:48",
      "content": "<p>Could you tell us please, how did you implement the code used in your kernels? Was it generated from notebooks? </p>\n\n<p>It looks like a dump of many Python files/notebooks into \"procedural\", C-like plain file. Did you iterate through your modules/py-files and gathered everything relevant making proper prefixes? So probably you had some \"source\" that was compiled into this \"concise\" representation.</p>",
      "rawMarkdown": "Could you tell us please, how did you implement the code used in your kernels? Was it generated from notebooks? \n\nIt looks like a dump of many Python files/notebooks into \"procedural\", C-like plain file. Did you iterate through your modules/py-files and gathered everything relevant making proper prefixes? So probably you had some \"source\" that was compiled into this \"concise\" representation.",
      "votes": null
    },
    {
      "id": "600250",
      "postDate": "08/15/2019 20:45:12",
      "content": "<p>It's inconvenient to edit the source codes in a kernel, so I  wrote codes  in my local computer and converted them to a file and paste it to the kernel. I am cleaning the codes.</p>",
      "rawMarkdown": "It's inconvenient to edit the source codes in a kernel, so I  wrote codes  in my local computer and converted them to a file and paste it to the kernel. I am cleaning the codes.",
      "votes": null
    },
    {
      "id": "600399",
      "postDate": "08/16/2019 04:11:16",
      "content": "<p>Amazing Work... Thanks for Sharing...!! <a href=\"/bestfitting\">@bestfitting</a> </p>",
      "rawMarkdown": "Amazing Work... Thanks for Sharing...!! @bestfitting",
      "votes": null
    },
    {
      "id": "600483",
      "postDate": "08/16/2019 06:46:49",
      "content": "<p>Yes, absolutely agree, but did you do it manually or using some converter script? Because you're totally right and it is not that suitable to run scripts on kernels, so I am thinking how to better organize my pipelines, like write a proper Python structure with folders and modules, and then have something like <code>export.py</code> that could traverse that structure and paste into a single file to submit on Kaggle. I think that it could be a cool tool: point to the repo on GitHub, and convert it into single, standalone, plain <code>.py</code> file that can be run anywhere.​</p>",
      "rawMarkdown": "Yes, absolutely agree, but did you do it manually or using some converter script? Because you're totally right and it is not that suitable to run scripts on kernels, so I am thinking how to better organize my pipelines, like write a proper Python structure with folders and modules, and then have something like `export.py` that could traverse that structure and paste into a single file to submit on Kaggle. I think that it could be a cool tool: point to the repo on GitHub, and convert it into single, standalone, plain `.py` file that can be run anywhere.​",
      "votes": null
    },
    {
      "id": "600533",
      "postDate": "08/16/2019 08:35:52",
      "content": "<p>Thank you for taking your time and explaining all this. There is so much to learn here for me 👌 </p>",
      "rawMarkdown": "Thank you for taking your time and explaining all this. There is so much to learn here for me 👌",
      "votes": null
    },
    {
      "id": "600697",
      "postDate": "08/16/2019 13:16:27",
      "content": "<p>I  wrote a script to convert the project to a .py file indeed.</p>",
      "rawMarkdown": "I  wrote a script to convert the project to a .py file indeed.",
      "votes": null
    },
    {
      "id": "600706",
      "postDate": "08/16/2019 13:31:39",
      "content": "<p>Thanks for Sharing</p>",
      "rawMarkdown": "Thanks for Sharing",
      "votes": null
    },
    {
      "id": "600833",
      "postDate": "08/16/2019 16:05:13",
      "content": "<p>Thanks for sharing.\nIs there any way one can get reliable tricks about StyleGAN training ?</p>",
      "rawMarkdown": "Thanks for sharing.\nIs there any way one can get reliable tricks about StyleGAN training ?",
      "votes": null
    },
    {
      "id": "600843",
      "postDate": "08/16/2019 16:20:57",
      "content": "<p>If you read my source codes,  you will find I have moved many interesting mechanisms  to BigGAN framework, for example, you can use my mix-style parameter to train a model to get similar effects of the SytleGAN. so this may be one of  tricks to train StyleGAN  efficiently by removing progressive training?  But I have not tested on larger datasets and large image sizes, I believe it will work. </p>",
      "rawMarkdown": "If you read my source codes,  you will find I have moved many interesting mechanisms  to BigGAN framework, for example, you can use my mix-style parameter to train a model to get similar effects of the SytleGAN. so this may be one of  tricks to train StyleGAN  efficiently by removing progressive training?  But I have not tested on larger datasets and large image sizes, I believe it will work.",
      "votes": null
    },
    {
      "id": "600854",
      "postDate": "08/16/2019 16:32:34",
      "content": "<p>Thanks for sharing <a href=\"/bestfitting\">@bestfitting</a> .</p>",
      "rawMarkdown": "Thanks for sharing @bestfitting .",
      "votes": null
    },
    {
      "id": "600901",
      "postDate": "08/16/2019 18:03:51",
      "content": "<p>this is out of the world !</p>",
      "rawMarkdown": "this is out of the world !",
      "votes": null
    },
    {
      "id": "601048",
      "postDate": "08/17/2019 00:14:34",
      "content": "<p>I have read you solution, and I found we did a lot of similar experiments and got similar results, it confirmed a lot of effective and not so effective parts of BigGAN and others architecture, it's very interesting and useful. </p>",
      "rawMarkdown": "I have read you solution, and I found we did a lot of similar experiments and got similar results, it confirmed a lot of effective and not so effective parts of BigGAN and others architecture, it's very interesting and useful.",
      "votes": null
    },
    {
      "id": "601093",
      "postDate": "08/17/2019 02:22:04",
      "content": "<p>thank u :)</p>",
      "rawMarkdown": "thank u :)",
      "votes": null
    },
    {
      "id": "601095",
      "postDate": "08/17/2019 02:23:25",
      "content": "<p>Good info !</p>",
      "rawMarkdown": "Good info !",
      "votes": null
    },
    {
      "id": "601116",
      "postDate": "08/17/2019 03:28:47",
      "content": "<p>what a wonderful Name. Nice solution. I will try your method next time. </p>",
      "rawMarkdown": "what a wonderful Name. Nice solution. I will try your method next time.",
      "votes": null
    },
    {
      "id": "601280",
      "postDate": "08/17/2019 10:19:28",
      "content": "<p>Thanks for Sharing</p>",
      "rawMarkdown": "Thanks for Sharing",
      "votes": null
    },
    {
      "id": "601296",
      "postDate": "08/17/2019 11:24:50",
      "content": "<p>informative</p>",
      "rawMarkdown": "informative",
      "votes": null
    },
    {
      "id": "601527",
      "postDate": "08/17/2019 18:41:02",
      "content": "<p>informative</p>",
      "rawMarkdown": "informative",
      "votes": null
    },
    {
      "id": "601559",
      "postDate": "08/17/2019 20:07:16",
      "content": "<p>so this is the level of the best in the Kaggle... impresive! ;)</p>",
      "rawMarkdown": "so this is the level of the best in the Kaggle... impresive! ;)",
      "votes": null
    },
    {
      "id": "602095",
      "postDate": "08/18/2019 15:06:00",
      "content": "<p>many thanks for sharing. amazing work</p>",
      "rawMarkdown": "many thanks for sharing. amazing work",
      "votes": null
    },
    {
      "id": "602140",
      "postDate": "08/18/2019 16:30:55",
      "content": "<p>Without knowledge of real LB is might interesting, but not useful. Sometimes to know what happens is good to know how much effort should be added. And hidden LB pushed everybody to not share ideas, which is also not good. </p>",
      "rawMarkdown": "Without knowledge of real LB is might interesting, but not useful. Sometimes to know what happens is good to know how much effort should be added. And hidden LB pushed everybody to not share ideas, which is also not good.",
      "votes": null
    },
    {
      "id": "602260",
      "postDate": "08/18/2019 20:42:59",
      "content": "<p>Under the inspiration of <a href=\"https://www.kaggle.com/lopuhin/imet-2019-submission\">this kernel</a>, I used the following code. Since it is not readable anyway, this solution seemed more convenient to me.</p>\n\n<p>```python\nimport base64\nimport io\nimport os\nimport shutil\nimport subprocess\nimport sys\nimport zipfile</p>\n\n<p>def unzip_code(code_b64):\n    z = zipfile.ZipFile(io.BytesIO(base64.b64decode(code_b64)))\n    z.extractall('.')</p>\n\n<p>ROOT_PROJECT_DIR = '../working/'\nPROJECT_DIR = 'dog_gan'\nsys.path.append('/kaggle/working')\nprint(sys.path)</p>\n\n<p>code_b64 = b'YOUR_BASE64_ZIP_HASHED_REPOSITORY'\ntry:\n    shutil.rmtree(PROJECT_DIR)\nexcept Exception as e:\n    pass\nunzip_code(code_b64)</p>\n\n<p>from dog_gan.run import main</p>\n\n<h1>Select your config (OOP-like hierarchy)</h1>\n\n<p>from dog_gan.configuration import KernelConfig</p>\n\n<p>k = KernelConfig()</p>\n\n<h1>Change your config atributes here</h1>\n\n<p>main('submit')</p>\n\n<p>```</p>",
      "rawMarkdown": "Under the inspiration of [this kernel](https://www.kaggle.com/lopuhin/imet-2019-submission), I used the following code. Since it is not readable anyway, this solution seemed more convenient to me.\n\n```python\nimport base64\nimport io\nimport os\nimport shutil\nimport subprocess\nimport sys\nimport zipfile\n\n\ndef unzip_code(code_b64):\n    z = zipfile.ZipFile(io.BytesIO(base64.b64decode(code_b64)))\n    z.extractall('.')\n\n\nROOT_PROJECT_DIR = '../working/'\nPROJECT_DIR = 'dog_gan'\nsys.path.append('/kaggle/working')\nprint(sys.path)\n\ncode_b64 = b'YOUR_BASE64_ZIP_HASHED_REPOSITORY'\ntry:\n    shutil.rmtree(PROJECT_DIR)\nexcept Exception as e:\n    pass\nunzip_code(code_b64)\n\nfrom dog_gan.run import main\n# Select your config (OOP-like hierarchy)\nfrom dog_gan.configuration import KernelConfig\n\nk = KernelConfig()\n# Change your config atributes here\nmain('submit')\n\n```",
      "votes": null
    },
    {
      "id": "602368",
      "postDate": "08/19/2019 02:14:12",
      "content": "<p>Thanks for sharing this info</p>",
      "rawMarkdown": "Thanks for sharing this info",
      "votes": null
    },
    {
      "id": "602372",
      "postDate": "08/19/2019 02:27:17",
      "content": "<p>Thank you for your sharing</p>",
      "rawMarkdown": "Thank you for your sharing",
      "votes": null
    },
    {
      "id": "602404",
      "postDate": "08/19/2019 03:40:51",
      "content": "<p>thanks</p>",
      "rawMarkdown": "thanks",
      "votes": null
    },
    {
      "id": "602690",
      "postDate": "08/19/2019 11:50:03",
      "content": "<p>Thanks</p>",
      "rawMarkdown": "Thanks",
      "votes": null
    },
    {
      "id": "603144",
      "postDate": "08/19/2019 23:37:04",
      "content": "<p>Great!</p>",
      "rawMarkdown": "Great!",
      "votes": null
    },
    {
      "id": "603245",
      "postDate": "08/20/2019 03:48:52",
      "content": "<p>awesome code. your work is so impresive!  I really with have fun with this. thanks for sharing.  I have a question for you? how many hours do you speed making this? </p>",
      "rawMarkdown": "awesome code. your work is so impresive!  I really with have fun with this. thanks for sharing.  I have a question for you? how many hours do you speed making this?",
      "votes": null
    },
    {
      "id": "603410",
      "postDate": "08/20/2019 08:26:10",
      "content": "<p>Good</p>",
      "rawMarkdown": "Good",
      "votes": null
    },
    {
      "id": "603874",
      "postDate": "08/20/2019 18:53:43",
      "content": "<p>thanks</p>",
      "rawMarkdown": "thanks",
      "votes": null
    },
    {
      "id": "605974",
      "postDate": "08/23/2019 03:19:57",
      "content": "<p>Great. Thanks for sharing 😊 </p>",
      "rawMarkdown": "Great. Thanks for sharing 😊",
      "votes": null
    },
    {
      "id": "609132",
      "postDate": "08/27/2019 12:37:22",
      "content": "<p>thanks for the explanation :)</p>",
      "rawMarkdown": "thanks for the explanation :)",
      "votes": null
    },
    {
      "id": "610546",
      "postDate": "08/28/2019 21:20:26",
      "content": "<p>Nice, really good work!</p>",
      "rawMarkdown": "Nice, really good work!",
      "votes": null
    },
    {
      "id": "646385",
      "postDate": "10/11/2019 07:44:34",
      "content": "<p>Thank you for your sharing. I learned a lot from your explaination. </p>",
      "rawMarkdown": "Thank you for your sharing. I learned a lot from your explaination.",
      "votes": null
    },
    {
      "id": "1000896",
      "postDate": "09/06/2020 22:04:36",
      "content": "<p>What is the difference Between This Code And The Original BigGAN</p>",
      "rawMarkdown": "What is the difference Between This Code And The Original BigGAN",
      "votes": null
    },
    {
      "id": "1084385",
      "postDate": "11/20/2020 01:47:43",
      "content": "<p>Thank you for this. I am curious, what kind of hardware did you need to run and how long did training typically take?</p>",
      "rawMarkdown": "Thank you for this. I am curious, what kind of hardware did you need to run and how long did training typically take?",
      "votes": null
    },
    {
      "id": "2644287",
      "postDate": "02/09/2024 11:12:00",
      "content": "<p>سلام الله عليكم</p>",
      "rawMarkdown": "سلام الله عليكم",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1000896,
      "author_name": "amirahalsulami",
      "author_url": "",
      "post_date": "09/06/2020 22:04:36",
      "content": "<p>What is the difference Between This Code And The Original BigGAN</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1084385,
      "author_name": "matthewchung",
      "author_url": "",
      "post_date": "11/20/2020 01:47:43",
      "content": "<p>Thank you for this. I am curious, what kind of hardware did you need to run and how long did training typically take?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 2644287,
      "author_name": "khalidamin77",
      "author_url": "",
      "post_date": "02/09/2024 11:12:00",
      "content": "<p>سلام الله عليكم</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 600211,
      "author_name": "cdeotte",
      "author_url": "",
      "post_date": "08/15/2019 19:52:37",
      "content": "<p>10 thumbs up!! Amazing work Bestfitting. I like how you combined the best features of multiple top performing GANs and invented your own GAN.</p>\n\n<p>For those that are interested, below are images from Bestfitting's two posted solutions. Check out the double headed dog in the bottom images in row 5 column 8 :-)</p>\n\n<h1>Samples from i96-1e-4-6e-4-bs32-195</h1>\n\n<p><img src=\"http://playagricola.com/Kaggle/dogs1b81419.png\" alt=\"image\"></p>\n\n<h1>Samples from i96-crop-mode3-dstep1-1e-4-6e-4-bs32</h1>\n\n<p><img src=\"http://playagricola.com/Kaggle/dogs2b81419.png\" alt=\"image\"></p>",
      "votes": null,
      "replies": [
        {
          "id": 600240,
          "author_name": "bestfitting",
          "author_url": "",
          "post_date": "08/15/2019 20:35:30",
          "content": "<p>I have just put a link in my main post, you can check the images, a class of dogs per line.  When the metric is  FID,  the variety is important.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 600212,
      "author_name": "dvorobiev",
      "author_url": "",
      "post_date": "08/15/2019 19:56:53",
      "content": "<p>Nice solution, thanks!\nI have similar findings about batch size and the number of channels in BigGAN model</p>",
      "votes": null,
      "replies": [
        {
          "id": 601048,
          "author_name": "bestfitting",
          "author_url": "",
          "post_date": "08/17/2019 00:14:34",
          "content": "<p>I have read you solution, and I found we did a lot of similar experiments and got similar results, it confirmed a lot of effective and not so effective parts of BigGAN and others architecture, it's very interesting and useful. </p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 600244,
      "author_name": "purplejester",
      "author_url": "",
      "post_date": "08/15/2019 20:40:48",
      "content": "<p>Could you tell us please, how did you implement the code used in your kernels? Was it generated from notebooks? </p>\n\n<p>It looks like a dump of many Python files/notebooks into \"procedural\", C-like plain file. Did you iterate through your modules/py-files and gathered everything relevant making proper prefixes? So probably you had some \"source\" that was compiled into this \"concise\" representation.</p>",
      "votes": null,
      "replies": [
        {
          "id": 600250,
          "author_name": "bestfitting",
          "author_url": "",
          "post_date": "08/15/2019 20:45:12",
          "content": "<p>It's inconvenient to edit the source codes in a kernel, so I  wrote codes  in my local computer and converted them to a file and paste it to the kernel. I am cleaning the codes.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 600483,
          "author_name": "purplejester",
          "author_url": "",
          "post_date": "08/16/2019 06:46:49",
          "content": "<p>Yes, absolutely agree, but did you do it manually or using some converter script? Because you're totally right and it is not that suitable to run scripts on kernels, so I am thinking how to better organize my pipelines, like write a proper Python structure with folders and modules, and then have something like <code>export.py</code> that could traverse that structure and paste into a single file to submit on Kaggle. I think that it could be a cool tool: point to the repo on GitHub, and convert it into single, standalone, plain <code>.py</code> file that can be run anywhere.​</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 600697,
          "author_name": "bestfitting",
          "author_url": "",
          "post_date": "08/16/2019 13:16:27",
          "content": "<p>I  wrote a script to convert the project to a .py file indeed.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 602260,
          "author_name": "lucidyan",
          "author_url": "",
          "post_date": "08/18/2019 20:42:59",
          "content": "<p>Under the inspiration of <a href=\"https://www.kaggle.com/lopuhin/imet-2019-submission\">this kernel</a>, I used the following code. Since it is not readable anyway, this solution seemed more convenient to me.</p>\n\n<p>```python\nimport base64\nimport io\nimport os\nimport shutil\nimport subprocess\nimport sys\nimport zipfile</p>\n\n<p>def unzip_code(code_b64):\n    z = zipfile.ZipFile(io.BytesIO(base64.b64decode(code_b64)))\n    z.extractall('.')</p>\n\n<p>ROOT_PROJECT_DIR = '../working/'\nPROJECT_DIR = 'dog_gan'\nsys.path.append('/kaggle/working')\nprint(sys.path)</p>\n\n<p>code_b64 = b'YOUR_BASE64_ZIP_HASHED_REPOSITORY'\ntry:\n    shutil.rmtree(PROJECT_DIR)\nexcept Exception as e:\n    pass\nunzip_code(code_b64)</p>\n\n<p>from dog_gan.run import main</p>\n\n<h1>Select your config (OOP-like hierarchy)</h1>\n\n<p>from dog_gan.configuration import KernelConfig</p>\n\n<p>k = KernelConfig()</p>\n\n<h1>Change your config atributes here</h1>\n\n<p>main('submit')</p>\n\n<p>```</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 600399,
      "author_name": "veeralakrishna",
      "author_url": "",
      "post_date": "08/16/2019 04:11:16",
      "content": "<p>Amazing Work... Thanks for Sharing...!! <a href=\"/bestfitting\">@bestfitting</a> </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 600533,
      "author_name": "matthiaspilz",
      "author_url": "",
      "post_date": "08/16/2019 08:35:52",
      "content": "<p>Thank you for taking your time and explaining all this. There is so much to learn here for me 👌 </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 600706,
      "author_name": "peacemakertsp",
      "author_url": "",
      "post_date": "08/16/2019 13:31:39",
      "content": "<p>Thanks for Sharing</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 600833,
      "author_name": "penanklihicyrille",
      "author_url": "",
      "post_date": "08/16/2019 16:05:13",
      "content": "<p>Thanks for sharing.\nIs there any way one can get reliable tricks about StyleGAN training ?</p>",
      "votes": null,
      "replies": [
        {
          "id": 600843,
          "author_name": "bestfitting",
          "author_url": "",
          "post_date": "08/16/2019 16:20:57",
          "content": "<p>If you read my source codes,  you will find I have moved many interesting mechanisms  to BigGAN framework, for example, you can use my mix-style parameter to train a model to get similar effects of the SytleGAN. so this may be one of  tricks to train StyleGAN  efficiently by removing progressive training?  But I have not tested on larger datasets and large image sizes, I believe it will work. </p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 600854,
      "author_name": "joelhanson",
      "author_url": "",
      "post_date": "08/16/2019 16:32:34",
      "content": "<p>Thanks for sharing <a href=\"/bestfitting\">@bestfitting</a> .</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 600901,
      "author_name": "phoenix9032",
      "author_url": "",
      "post_date": "08/16/2019 18:03:51",
      "content": "<p>this is out of the world !</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 601093,
      "author_name": "hsmin065",
      "author_url": "",
      "post_date": "08/17/2019 02:22:04",
      "content": "<p>thank u :)</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 601095,
      "author_name": "easylife93",
      "author_url": "",
      "post_date": "08/17/2019 02:23:25",
      "content": "<p>Good info !</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 601116,
      "author_name": "topchaebol",
      "author_url": "",
      "post_date": "08/17/2019 03:28:47",
      "content": "<p>what a wonderful Name. Nice solution. I will try your method next time. </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 601280,
      "author_name": "sumansahoo16",
      "author_url": "",
      "post_date": "08/17/2019 10:19:28",
      "content": "<p>Thanks for Sharing</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 601296,
      "author_name": "troublem1",
      "author_url": "",
      "post_date": "08/17/2019 11:24:50",
      "content": "<p>informative</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 601527,
      "author_name": "abhinavsinha1",
      "author_url": "",
      "post_date": "08/17/2019 18:41:02",
      "content": "<p>informative</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 601559,
      "author_name": "jesucristo",
      "author_url": "",
      "post_date": "08/17/2019 20:07:16",
      "content": "<p>so this is the level of the best in the Kaggle... impresive! ;)</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 602095,
      "author_name": "jazzzzm",
      "author_url": "",
      "post_date": "08/18/2019 15:06:00",
      "content": "<p>many thanks for sharing. amazing work</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 602140,
      "author_name": "muhakabartay",
      "author_url": "",
      "post_date": "08/18/2019 16:30:55",
      "content": "<p>Without knowledge of real LB is might interesting, but not useful. Sometimes to know what happens is good to know how much effort should be added. And hidden LB pushed everybody to not share ideas, which is also not good. </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 602368,
      "author_name": "naveev",
      "author_url": "",
      "post_date": "08/19/2019 02:14:12",
      "content": "<p>Thanks for sharing this info</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 602372,
      "author_name": "elsa1717",
      "author_url": "",
      "post_date": "08/19/2019 02:27:17",
      "content": "<p>Thank you for your sharing</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 602404,
      "author_name": "tuanakka",
      "author_url": "",
      "post_date": "08/19/2019 03:40:51",
      "content": "<p>thanks</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 602690,
      "author_name": "dbfud3516",
      "author_url": "",
      "post_date": "08/19/2019 11:50:03",
      "content": "<p>Thanks</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 603144,
      "author_name": "lzz888",
      "author_url": "",
      "post_date": "08/19/2019 23:37:04",
      "content": "<p>Great!</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 603245,
      "author_name": "marcovasquez",
      "author_url": "",
      "post_date": "08/20/2019 03:48:52",
      "content": "<p>awesome code. your work is so impresive!  I really with have fun with this. thanks for sharing.  I have a question for you? how many hours do you speed making this? </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 603410,
      "author_name": "shubhangi23",
      "author_url": "",
      "post_date": "08/20/2019 08:26:10",
      "content": "<p>Good</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 603874,
      "author_name": "amirahalsulami",
      "author_url": "",
      "post_date": "08/20/2019 18:53:43",
      "content": "<p>thanks</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 605974,
      "author_name": "vishnurapps",
      "author_url": "",
      "post_date": "08/23/2019 03:19:57",
      "content": "<p>Great. Thanks for sharing 😊 </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 609132,
      "author_name": "benru89",
      "author_url": "",
      "post_date": "08/27/2019 12:37:22",
      "content": "<p>thanks for the explanation :)</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 610546,
      "author_name": "ekolodin",
      "author_url": "",
      "post_date": "08/28/2019 21:20:26",
      "content": "<p>Nice, really good work!</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 646385,
      "author_name": "doantientai",
      "author_url": "",
      "post_date": "10/11/2019 07:44:34",
      "content": "<p>Thank you for your sharing. I learned a lot from your explaination. </p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "600170": "It's an interesting competition, and this is the first time I write a solution without knowing private LB score. Great thanks to kaggle for the efforts to host this competition and quick response to the community by @juliaelliott, @wendykan. \n\nMy solution may be described as a mix of StyleGAN and BigGAN.\n\nRespect to the authors of the  papers and these two github repositories:\nhttps://github.com/ajbrock/BigGAN-PyTorch\nhttps://github.com/rosinality/style-based-gan-pytorch\n\n\n**Challenges**:\n1. Limited resources and limited time  to train a GAN from scratch.\n2. A new kind of challenge with new rules and settings. It took me 2 weeks to choose between this one and the Youbute 8M video challenge.\n\n**Solution**:\n\nI tried DCGAN and ACGAN to get familiar with this competition at first , and then select papers related, I selected about 40 papers which might be useful.\n\nI was impressed by the results of the StyleGAN and tried to make it work more efficiently so I could make it run in a kernel, but I found Progressive GAN and its followers were inefficient to train,  but I still spent about 10 days to tune it and got  FID about 35 , I guessed that this score was not enough to top 10, but I thought I should spend more time on it to get understanding of every detail of it before I stepped forward.\n\nThen I tried VQ-VAE2 and a lot of other mechanisms and I was not satisfied with the efficiency and the scores.\n\nBigGAN was listed on the top of my most promising solutions, but the **BIG**, **DEEP**  in the model name prevent me from trying it in a hurry and the paper stated that using more channels was important, I worried that it might be inefficient in this competition, so I planed to try it after I have tested others. To my surprise, the channels was not so important, when I decreased the G\\_ch and D\\_ch from 64 to 24, the FID score did not decrease too much and the FID score can easily reach below 30.\n\nWhat's more, the project structure of the  https://github.com/ajbrock/BigGAN-PyTorch is very good, we can do a lot of experiments by just modifying some parameters, so I could start many experiments and went out have a bicycle driving or swimming :)  After several experiments, my score reached about 24. \n\nAfter I checked and compared the architecture and mechanisms of the  Big and Style GAN, I found that Spectral normalization and Class-conditional Batch  normalization were important to BigAN, so we need not use progressive training,  and BigGAN's G_shared and skip\\_z mechanisms were similar to the StyleGAN's style mechanism to some extend, so I made a lot of modifications to BigGAN and tried to move almost all important  mechanisms of StyleGAN to it. After many experiments, I found: Style mechanism could improve the score significantly and coverage more quickly, the Blur was also important, Noise was not so important, to save time, I did not add it to my networks.  Since I had more efficient and powerful  tools for the BigGAN, so I did not use skip\\_z.  I found mix-style mechanism of StyleGAN was not important in this competition, so I did not use it in my final submission. After these efforts and some hyper-parameters tuning, the score can reach about 17. \n\nI thought I might use large image size to train the network, so I designed a 96x96 model instead of 64x64, I found it could improve the score.\n\nI tried to use Attention including BigGAN's attention and CBAM  in the network, it increased the training time and the improvement to the score was not so big, so I did not use them\n\nTo my surprise, although the paper of BigGAN stated that the larger batch-size, the better result, I found 32 was the best batch-size. So the two most important results--large channels and bigger batch-size of the BigGAN were not suitable of this dataset, so my solution should be called **Style-Small-GAN** ??  :smile::smile:\n\nMy best parameters can be described as the following command:\n<pre>python train.py --shuffle --batch_size 32 --num_G_accumulations 1 --num_D_accumulations 1 --num_epochs 200 --num_D_steps 1 --G_lr 1e-4 --D_lr 6e-4 --dataset DogOrigin96 --bottom_width 6 --G_ortho 0.0 --G_attn 0 --D_attn 0 --G_init ortho --D_init ortho --ema --use_ema --ema_start 2000 --test_every 25 --save_every 10 --num_best_copies 5 --num_save_copies 2 --G_ch 24 --D_ch 24 --seed 0 --augment 1 --add_blur --add_style --crop_mode 8  --on_kaggle --experiment_name i96_ch24_hinge_ema_dstep1_bs32_noatt_glr0001_glr0006_aug_init_ortho_blur_style_origin_crop_mode8\n</pre>\nThe score  improved to  **12.4** on public LB after these steps\n\nIn the last several days of this competition, I turned to the model's generalization and the data itself, I found that if I cropped square box containing the dogs only, it performed better than adding resized origin images, but, as kaggle will use another datasets and my models were trained on all-dogs datasets,  they might over-fit to the cropped all-dogs to some extend, when my models were applied on other images, the dogs might not be cropped,  so I added resized origin images to the datasets with some probability. The score on public LB of this augmentation is **13.4**, but I guess this model may perform better than 12.4 one.\n\nI also added all kinds of mechanisms , such as mode seeking, all kinds of loss functions such as such as GDPP, normalizations, regularizations , initializations, and most of them did not work.\n\nMost of mechanism I talked above are kept in the kernels and can be tested by using the parameters. If you want to have a try, 100 epochs in 4.5h can reach FID 18.x, and 125 epochs can reach FID 15.x\n\n**What can we do to improve the model if there are no limits on the resources and time?**\n1. I designed a mechanism to add dog count in an image to the model, that's to say, dog count embedding. It works, but it took more time. \n2. We can still cluster the images to 30-40 clusters, use these cluster id as other embedding, so, the dog on the grass, floor..... ( I did not test it )\n3. We can use large sized images.\n\nSo the FID less than 10 is not so difficult to achieve if we have two GPUs or double time. \n1 and 2 can be described as Multi-Classes-Conditional Style GAN,  with the mixture of the Style and BigGAN, after some well designed experiments we may make some progress to the state of the art GANs?\nYou can check some of images, a type of dogs per line:\nhttps://raw.githubusercontent.com/bestfitting/kaggle/master/gandogs/samples/samples_mode8.jpg\n\nThe link to my kernels:\nhttps://www.kaggle.com/bestfitting/i96-1e-4-6e-4-bs32-195\nhttps://www.kaggle.com/bestfitting/i96-crop-mode3-dstep1-1e-4-6e-4-bs32\n\n<b>Updated</b>\nThe source codes in the  kennels above are not easy to read, you can check the normal python project structure version here https://github.com/bestfitting/kaggle/tree/master/gandogs\n\n\n<hr>\n\n*Please note that the progresses and the scores of my models are not a formal ablation study in a paper and I don't plan to write a paper either, I modified the parameters and other setting during these progresses, they were results of a series of complex experiment setting.*",
    "600211": "10 thumbs up!! Amazing work Bestfitting. I like how you combined the best features of multiple top performing GANs and invented your own GAN.\n  \nFor those that are interested, below are images from Bestfitting's two posted solutions. Check out the double headed dog in the bottom images in row 5 column 8 :-)\n# Samples from i96-1e-4-6e-4-bs32-195\n![image](http://playagricola.com/Kaggle/dogs1b81419.png)\n# Samples from i96-crop-mode3-dstep1-1e-4-6e-4-bs32\n![image](http://playagricola.com/Kaggle/dogs2b81419.png)",
    "600212": "Nice solution, thanks!\nI have similar findings about batch size and the number of channels in BigGAN model",
    "600240": "I have just put a link in my main post, you can check the images, a class of dogs per line.  When the metric is  FID,  the variety is important.",
    "600244": "Could you tell us please, how did you implement the code used in your kernels? Was it generated from notebooks? \n\nIt looks like a dump of many Python files/notebooks into \"procedural\", C-like plain file. Did you iterate through your modules/py-files and gathered everything relevant making proper prefixes? So probably you had some \"source\" that was compiled into this \"concise\" representation.",
    "600250": "It's inconvenient to edit the source codes in a kernel, so I  wrote codes  in my local computer and converted them to a file and paste it to the kernel. I am cleaning the codes.",
    "600399": "Amazing Work... Thanks for Sharing...!! @bestfitting",
    "600483": "Yes, absolutely agree, but did you do it manually or using some converter script? Because you're totally right and it is not that suitable to run scripts on kernels, so I am thinking how to better organize my pipelines, like write a proper Python structure with folders and modules, and then have something like `export.py` that could traverse that structure and paste into a single file to submit on Kaggle. I think that it could be a cool tool: point to the repo on GitHub, and convert it into single, standalone, plain `.py` file that can be run anywhere.​",
    "600533": "Thank you for taking your time and explaining all this. There is so much to learn here for me 👌",
    "600697": "I  wrote a script to convert the project to a .py file indeed.",
    "600706": "Thanks for Sharing",
    "600833": "Thanks for sharing.\nIs there any way one can get reliable tricks about StyleGAN training ?",
    "600843": "If you read my source codes,  you will find I have moved many interesting mechanisms  to BigGAN framework, for example, you can use my mix-style parameter to train a model to get similar effects of the SytleGAN. so this may be one of  tricks to train StyleGAN  efficiently by removing progressive training?  But I have not tested on larger datasets and large image sizes, I believe it will work.",
    "600854": "Thanks for sharing @bestfitting .",
    "600901": "this is out of the world !",
    "601048": "I have read you solution, and I found we did a lot of similar experiments and got similar results, it confirmed a lot of effective and not so effective parts of BigGAN and others architecture, it's very interesting and useful.",
    "601093": "thank u :)",
    "601095": "Good info !",
    "601116": "what a wonderful Name. Nice solution. I will try your method next time.",
    "601280": "Thanks for Sharing",
    "601296": "informative",
    "601527": "informative",
    "601559": "so this is the level of the best in the Kaggle... impresive! ;)",
    "602095": "many thanks for sharing. amazing work",
    "602140": "Without knowledge of real LB is might interesting, but not useful. Sometimes to know what happens is good to know how much effort should be added. And hidden LB pushed everybody to not share ideas, which is also not good.",
    "602260": "Under the inspiration of [this kernel](https://www.kaggle.com/lopuhin/imet-2019-submission), I used the following code. Since it is not readable anyway, this solution seemed more convenient to me.\n\n```python\nimport base64\nimport io\nimport os\nimport shutil\nimport subprocess\nimport sys\nimport zipfile\n\n\ndef unzip_code(code_b64):\n    z = zipfile.ZipFile(io.BytesIO(base64.b64decode(code_b64)))\n    z.extractall('.')\n\n\nROOT_PROJECT_DIR = '../working/'\nPROJECT_DIR = 'dog_gan'\nsys.path.append('/kaggle/working')\nprint(sys.path)\n\ncode_b64 = b'YOUR_BASE64_ZIP_HASHED_REPOSITORY'\ntry:\n    shutil.rmtree(PROJECT_DIR)\nexcept Exception as e:\n    pass\nunzip_code(code_b64)\n\nfrom dog_gan.run import main\n# Select your config (OOP-like hierarchy)\nfrom dog_gan.configuration import KernelConfig\n\nk = KernelConfig()\n# Change your config atributes here\nmain('submit')\n\n```",
    "602368": "Thanks for sharing this info",
    "602372": "Thank you for your sharing",
    "602404": "thanks",
    "602690": "Thanks",
    "603144": "Great!",
    "603245": "awesome code. your work is so impresive!  I really with have fun with this. thanks for sharing.  I have a question for you? how many hours do you speed making this?",
    "603410": "Good",
    "603874": "thanks",
    "605974": "Great. Thanks for sharing 😊",
    "609132": "thanks for the explanation :)",
    "610546": "Nice, really good work!",
    "646385": "Thank you for your sharing. I learned a lot from your explaination.",
    "1000896": "What is the difference Between This Code And The Original BigGAN",
    "1084385": "Thank you for this. I am curious, what kind of hardware did you need to run and how long did training typically take?",
    "2644287": "سلام الله عليكم"
  },
  "source": "meta"
}