GithubHelp home page GithubHelp logo

everypixel / arshadowgan-like Goto Github PK

View Code? Open in Web Editor NEW
28.0 2.0 10.0 1.36 MB

ARShadowGAN-like realization. PyTorch.

License: MIT License

Shell 2.68% Python 97.32%
models python3 pytorch gan neural-networks colab segmentation unet shadow colab-notebook

arshadowgan-like's Introduction

GAN training on shadow generation task example

Alt text

Colab Notebook

PyTorch Colab notebook: ARShadowGAN-like

Prerequisites

  • Python 3
  • CPU or NVIDIA GPU + CUDA CuDNN

Getting Started

Installation

  • Clone this repo:
git clone https://github.com/Everypixel/arshadowgan-like.git
cd arshadowgan
  • Install dependencies (e.g., segmentation_models_pytorch, ...)
pip install -r requirements.txt

Dataset preparation

ARShadow-dataset

We will use the shadow-ar dataset for training and testing our model. We have already splitted it to train and test parts. Download and extract it please .

Your own dataset

Your own dataset has to have the structure such ShadowAR-dataset has. Each folder contains images.

dataset
├── train
│   ├── noshadow ── example1.png, ...
│   ├── shadow ──── example1.png, ...
│   ├── mask ────── example1.png, ...
│   ├── robject ─── example1.png, ...
│   └── rshadow ─── example1.png, ...
└── test
    ├── noshadow ── example2.png, ...
    ├── shadow ──── example2.png, ...
    ├── mask ────── example2.png, ...
    ├── robject ─── example2.png, ...
    └── rshadow ─── example2.png, ...
  • noshadow - no shadow images
  • shadow - images with shadow
  • mask - inserted object masks
  • robject - occluders masks
  • rshadow - occluders shadows

Training

Training attention module

Set the parameters:

  • dataset_path - path to dataset
  • model_path - path for attention model saving
  • batch_size - amount of images in batch
    (reduce it if "CUDA: out of memory" error)
  • seed - seed for random functions
  • img_size - image width or image height (is divisible by 32)
  • lr - learning rate
  • n_epoch - amount of epochs

For example:

python3 scripts/train_attention.py \
       --dataset_path '/content/arshadowgan/dataset/' \
       --model_path '/content/drive/MyDrive/attention128.pth' \
       --batch_size 200 \
       --seed 42 \
       --img_size 256 \
       --lr 1e-4 \
       --n_epoch 100

Training shadow-generation module

  • dataset_path - path to dataset
  • Gmodel_path - path for generator model saving
  • Dmodel_path - path for discriminator model saving
  • batch_size - amount of images in batch
    (reduce it if "CUDA: out of memory" error)
  • seed - seed for random functions
  • img_size - image width or image height (is divisible by 32)
  • lr_G - generator learning rate
  • lr_D - discriminator learning rate
  • n_epoch - amount of epochs
  • betta1,2,3 - loss function coefficients, see ARShadowGAN paper

For example:

python3 scripts/train_SG.py \
       --dataset_path '/content/arshadowgan/dataset/' \
       --Gmodel_path '/content/drive/MyDrive/SG_generator.pth' \
       --Dmodel_path '/content/drive/MyDrive/SG_discriminator.pth' \
       --batch_size 64 \
       --seed 42 \
       --img_size 256 \
       --lr_G 1e-4 \
       --lr_D 1e-6 \
       --n_epoch 600 \
       --betta1 10 \
       --betta2 1 \
       --betta3 1e-2 \
       --patience 10 \
       --encoder 'resnet18'

Run

Start inference with results saving

For example:

python3 scripts/test.py \
       --batch_size 1 \
       --img_size 256 \
       --dataset_path '/content/arshadowgan/dataset/test' \
       --result_path '/content/arshadowgan/results' \
       --path_att '/content/drive/MyDrive/ARShadowGAN-like/attention.pth' \
       --path_SG '/content/drive/MyDrive/ARShadowGAN-like/SG_generator.pth'

Acknowledgements

We thank ARShadowGAN authors for their amazing work.
We also thank segmentation_models.pytorch for network architecture, albumentations for augmentations, PyTorch-GAN for discriminator architecture and piq for Content loss.

arshadowgan-like's People

Contributors

artyomnaz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

arshadowgan-like's Issues

Other unwanted colors appear in the test results

1.My test data only has the original image and the corresponding mask
image

image

2.I want to know what the other 3 folders are, how can I get these 3 folders if my own data set,
what's the effect
image

I see that the image resolution is 256. Is it possible to achieve any size input?

pre trained models

thank you for your job
Can you upload the pre-trained models?
thank you

run test.py

error:
_jb_pytest_runner.py: error: unrecognized arguments: test.py::test_arshadowgan

RMSE

Hello sir, I was also reading this paper recently and found the code that you reproduced. I have learned a lot. I have a question about the article. How is the RMSE calculated in the text? Is there any relevant code, because I calculate The results are very different, I hope you can reply, thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.