• Stars
    star
    165
  • Rank 228,906 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created over 3 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

[AAAI 2022] The first dataset on foreground object shadow generation for image composition in real-world scenes. The code used in our paper "Shadow Generation for Composite Image in Real-world Scenes", AAAI2022. Useful for shadow generation, shadow removal, image composition, etc.

Problem Definition

Object Shadow Generation is to deal with the shadow inconsistency between the foreground object and the background in a composite image, that is, generating plausible shadow for the foreground object according to background information, to make the composite image more realistic.

Our dataset DESOBA is a synthesized dataset for Object Shadow Generation. We build our dataset on the basis of Shadow-OBject Association dataset SOBA, which collects real-world images in complex scenes and provides annotated masks for object-shadow pairs. Based on SOBA dataset, we remove all the shadows to construct our DEshadowed Shadow-OBject Association (DESOBA) dataset, which can be used for shadow generation task and other shadow-related tasks as well.

Illustration of DESOBA dataset construction (top flow): Given a ground-truth target image Ig, we manually remove all shadows to produce a deshadowed image Id. Then, we randomly select a foreground object in Ig, and replace its shadow area with the counterpart in Id to synthesize a composite image Ic without foreground shadow. Ic and Ig form a pair of input composite image and ground-truth target image.

Illustration of shadow generation task (bottom flow): Given Ic and its foreground object mask Mfo, we aim to reconstruct the target image Ig with foreground shadow.

Our DESOBA Dataset

Our DESOBA dataset contains 839 training images with totally 2,995 object-shadow pairs and 160 test images with totally 624 object-shadow pairs. Note that we discard one complex training image from SOBA. During testing, we ignore 9 object-shadow pairs with too small shadows after the whole image is resized to 256×256, resulting in 615 test image pairs.The DESOBA dataset is provided in Baidu Cloud (access code: 1234), or Google Drive.

We refer to the test image pairs with Background Object-Shadow (BOS) pairs as BOS test image pairs (from left to right in the left subfigure: synthetic composite image, foreground object mask, background object mask,background shadow mask, and ground-truth target image), and the remaining ones as BOS-free test image pairs (from left to right in the right subfigure: synthetic composite image, foreground object mask, and ground-truth target image).

Visualizing training/testing pairs of DESOBA dataset

cd ./DESOBA_DATASET_util

  • Visualizing training image pairs (839 train images with 11509 pairs):
python Vis_Desoba_Dataset --serial_batches --isTrain 1

Training image pairs are stored in /DESOBA_DATASET/TrainTestVisualization/train/.

  • Visualizing BOS-free test image pairs (34 BOS-free test images with 34 pairs):
python Vis_Desoba_Dataset --serial_batches --isTrain 0 --bosfree

BOS-free test image pairs are stored in /DESOBA_DATASET/TrainTestVisualization/train/test_bosfree.

  • Visualizing BOS test image pairs (126 BOS test images with 581 pairs):
python Vis_Desoba_Dataset --serial_batches --isTrain 0 --bos

BOS test image pairs are stored in /DESOBA_DATASET/TrainTestVisualization/train/test_bos.

We show some examples of training/testing tuples below:

From left to right: synthetic composite image without foreground shadow, target image with foreground shadow, foreground object mask, foreground shadow mask, background object mask, and background shadow mask.

Producing real composite images from test images of DESOBA

cd ./DESOBA_DATASET_util

  • Producing real composite images with one foreground object:
python Vis_RealCompositionImages_fromDesoba_Dataset.py --foreground_object_num 1

Real composite images with one foreground object are stored in /DESOBA_DATASET/CompositeImages/1_ForegroundObject/.

  • Producing real composite images with two foreground objects:
python Vis_RealCompositionImages_fromDesoba_Dataset.py --foreground_object_num 2

Real composite images with two foreground objects are stored in /DESOBA_DATASET/CompositeImages/2_ForegroundObject.

We show a real composite image with one foreground object and a real composite image with two foreground objects below:

From left to right: synthetic composite image without foreground shadow, foreground object mask, background object mask, background shadow mask.

To evaluate the effectiveness of different methods in real scenarios, we prepare 100 real composite images including 74 images with one foreground object and 26 images with two foreground objects. We provide 100 real composite images in Baidu Cloud (access code: 1234), or Google Drive.

Dataloader preparation for your own project

We provide the code of obtaining training/testing tuples, in which each tuple contains foreground object mask, foreground shadow mask, background object mask, background shadow mask, shadow image, and synthetic composite image without foreground shadow mask. The dataloader is available in /DESOBA_DATASET_util/data/DesobaSyntheticImageGeneration_dataset.py, which can be used as dataloader in training phase or testing phase.

Baselines

  • Pix2Pix: Image to image translation method. Implementation of paper "Image-to-Image Translation with Conditional Adversarial Nets" [pdf].

  • Pix2Pix-Res: Image to image translation method. Implementation of paper "Image-to-Image Translation with Conditional Adversarial Nets" [pdf]. Pix2Pix-Res is a variant of Pix2Pix whose architecture is the same as Pix2Pix but outputs the residual results.

  • ShadowGAN: Image to image translation method. Implementation of paper "ShadowGAN: Shadow synthesis for virtual objects with conditional adversarial networks" [pdf].

  • Mask-ShadowGAN: Image to image translation method. Implementation of paper "Mask-ShadowGAN: Learning to remove shadows from unpaired data" [pdf].

  • ARShadowGAN: Image to image translation method. Implementation of paper "ARShadowGAN: Shadow Generative Adversarial Network for Augmented Reality in Single Light Scenes" [pdf].

Our SGRNet

Here we provide PyTorch implementation and the trained model of our SGRNet.

Prerequisites

  • Python
  • Pytorch
  • PIL
  • you can create a new environment by using pip install -r requirements.txt

Getting Started

Installation

  • Clone this repo:
git clone https://github.com/bcmi/Object-Shadow-Generation-Dataset-DESOBA.git
cd Object-Shadow-Generation-Dataset-DESOBA
  • Download the DESOBA dataset from Baidu Cloud (access code: 1234), or Google Drive. Save it at /DESOBA_DATASET/.

  • Download the pretrained model of SGRNet and baseline methods from Baidu Cloud (access code:1234), or Google Drive. Save it at /TrainedModels/.

Data preparation

DESOBA dataset has six subfolders including: ShadowImage, DeshadowedImage, InstanceMask, ShadowMask, newshadowmask, shadowparams.

Test on your own data

You should provide foreground object mask and background image without foreground shadow.

  • For SGRNet method:

  • With background object mask and background shadow mask, you can modify (reseting the paths of your own data) and run

/src/script/SGRNet_RealComposite.sh

to produce foreground shadow for your own composite images using pretrained SGRNet model.

  • Without background object mask and background shadow mask, you can modify (reseting the paths of your own data) and run
/src/script/SGRNet_RealComposite_2.sh

to produce foreground shadow for your own composite images using pretrained SGRNet model.

  • For baselines methods: You can run
/src/script/Pix2pix_RealComposite.sh
/src/script/Pix2pixRes_RealComposite.sh
/src/script/ARShadowGAN_RealComposite.sh
/src/script/MaskshadowGAN_RealComposite.sh
/src/script/ShadowGAN_RealComposite.sh

to produce foreground shadow for your own composite images using pretrained baseline models, respectively.

Test on real composite images

We provide 100 real composite images with foreground mask and you can download them to /DESOBA_DATASET/.

  • For SGRNet method: You can run
/src/script/SGRNet_RealComposite.sh

to produce shadow for prepared real composite images using pretrained SGRNet model.

  • For baselines methods: You can run,
/src/script/Pix2pix_RealComposite.sh
/src/script/Pix2pixRes_RealComposite.sh
/src/script/ARShadowGAN_RealComposite.sh
/src/script/MaskshadowGAN_RealComposite.sh
/src/script/ShadowGAN_RealComposite.sh

to produce shadow for prepared real composite images using pretrained baseline models.

Test on DESOBA dataset

  • For SGRNet method:

  • For BOS test images, set TESTDATA=--bos in /src/script/SGRNet_test.sh and run

/src/script/SGRNet_test.sh

to conduct evaluation on BOS test images from DESOBA dataset.

  • For BOS-free test images, set TESTDATA=--bosfree in /src/script/SGRNet_test.sh and run
/src/script/SGRNet_test.sh

to conduct evaluation on BOS-free test images from DESOBA dataset.

  • For baselines methods:

  • For BOS test images, set TESTDATA=--bos and run

/src/script/Pix2pix_test.sh
/src/script/Pix2pixRes_test.sh
/src/script/ARShadowGAN_test.sh
/src/script/MaskshadowGAN_test.sh
/src/script/ShadowGAN_test.sh

to conduct evaluation on BOS test images from DESOBA dataset for different baseline methods, respectively.

  • For BOS-free test images, set TESTDATA=--bosfree and run
/src/script/Pix2pix_test.sh
/src/script/Pix2pixRes_test.sh
/src/script/ARShadowGAN_test.sh
/src/script/MaskshadowGAN_test.sh
/src/script/ShadowGAN_test.sh

to conduct evaluation on BOS-free test images from DESOBA dataset for different baseline methods, respectively.

Train on DESOBA dataset

Considering that our SGRNet relied on shadow parameters during training phase, we need to calculate shadow parameters from paired shadow-deshadow images. We provide calculated shadow parameters in DESOBA dataset. You can also calculate shadow parameters based on tuple {shadowimage, deshadowed image, shadow mask} by runing /data_processing/compute_params_DESOBA.py

  • For SGRNet method: you can run
/src/script/SGRNet_train.sh

to train SGRNet model on DESOBA dataset.

  • For baselines methods: you can run
/src/script/Pix2pix_train.sh
/src/script/Pix2pixRes_train.sh
/src/script/ARShadowGAN_train.sh
/src/script/MaskshadowGAN_train.sh
/src/script/ShadowGAN_train.sh

to train model on DESOBA dataset for different baseline methods, respectively.

Experimental Results

Leaderboard

Here we show the quantitative results of different methods on DESOBA test set based on Root Mean Square Error (RMSE) and Structural SIMilarity index (SSIM). Global RMSE (GRMSE) and Global SSIM (GSSIM) are calculated over the whole image, while Local RMSE (LRMSE) and Local SSIM (LSSIM) are calculated over the ground-truth foreground shadow area. The paper/code/model of shadow generation related methods are summarized in Awesome-Object-Shadow-Generation.

Method BOS Test Images BOS-free Test Images
Evaluation metric GRMSE LRMSE GSSIM LSSIM* GRMSE LRMSE GSSIM LSSIM*
Pix2Pix 7.659 75.346 0.927 0.249 18.875 81.444 0.856 0.110
Pix2Pix-Res 5.961 76.046 0.971 0.253 18.305 81.966 0.901 0.107
ShadowGAN 5.985 78.413 0.986 0.240 19.306 87.017 0.918 0.078
Mask-ShadowGAN 8.287 79.212 0.953 0.245 19.475 83.457 0.891 0.109
ARShandowGAN 6.481 75.099 0.983 0.251 18.723 81.272 0.917 0.109
SGRNet 4.754 61.762 0.988 0.380 15.128 61.439 0.927 0.183

*: Note that the LSSIM results in official AAAI paper are miscalculated due to a bug in the evaluation code util/ssim.py. We sincerely apologize for this mistake and have updated the results in arXiv.

Visualization results on DESOBA dataset

Here we show some example results of different baselines on DESOBA dataset. More examples can be found in our main paper.

From left to right: input composite image (a), foreground object mask (b), results of Pix2Pix (c), Pix2Pix-Res (d), ShadowGAN (e), Mask-ShadowGAN (f), ARShadowGAN (g), our SGRNet (h), ground-truth (i). The results on BOS test images are shown in row 1-2, and the results on BOS-free test images are shown in row 3-4).

Visualization results on real composite images

Below we present several results of different baselines on real composite images. The 100 real composite images could be found in Baidu Cloud (access code: 1234), or Google Drive.

From left to right: input composite image (a), foreground object mask (b), results of Pix2Pix (c), Pix2Pix-Res (d), ShadowGAN (e), Mask-ShadowGAN (f), ARShadowGAN (g), SGRNet (h).

Other Resources

Bibtex

If you find this work is useful for your research, please cite our paper using the following BibTeX [arxiv]:

@article{hong2021shadow,
  title={Shadow Generation for Composite Image in Real-world Scenes},
  author={Hong, Yan and Niu, Li and Zhang, Jianfu},
  journal={AAAI},
  year={2022}
}

More Repositories

1

Awesome-Image-Composition

A curated list of papers, code and resources pertaining to image composition/compositing or object insertion, which aims to generate realistic composite image.
1,171
star
2

Image-Harmonization-Dataset-iHarmony4

[CVPR 2020] The first large-scale public benchmark dataset for image harmonization. The code used in our paper "DoveNet: Deep Image Harmonization via Domain Verification", CVPR2020. Useful for image harmonization, image composition, etc.
MATLAB
764
star
3

libcom

Image composition toolbox: everything you want to know about image composition or object insertion
Python
499
star
4

Awesome-Image-Harmonization

A curated list of papers, code and resources pertaining to image harmonization.
425
star
5

DCI-VTON-Virtual-Try-On

[ACM Multimedia 2023] Taming the Power of Diffusion Models for High-Quality Virtual Try-On with Appearance Flow.
Python
398
star
6

Awesome-Few-Shot-Image-Generation

A curated list of papers, code and resources pertaining to few-shot image generation.
366
star
7

Awesome-Aesthetic-Evaluation-and-Cropping

276
star
8

CaGNet-Zero-Shot-Semantic-Segmentation

Code for our ACMMM2020 paper "Context-aware Feature Generation for Zero-shot Semantic Segmentation".
Python
233
star
9

SLBR-Visible-Watermark-Removal

[ACM MM 2021] Visible Watermark Removal via Self-calibrated Localization and Background Refinement
Python
214
star
10

Awesome-Weak-Shot-Learning

A curated list of papers, code and resources pertaining to weak-shot classification, detection, and segmentation.
183
star
11

ControlCom-Image-Composition

A controllable image composition model which could be used for image blending, image harmonization, view synthesis.
Python
141
star
12

CDTNet-High-Resolution-Image-Harmonization

[CVPR 2022] We unify pixel-to-pixel transformation and color-to-color transformation in a coherent framework for high-resolution image harmonization. We also release 100 high-resolution real composite images for evaluation.
Python
124
star
13

Image-Composition-Assessment-Dataset-CADB

[BMVC2021] The first image composition assessment dataset. Used in the paper "Image Composition Assessment with Saliency-augmented Multi-pattern Pooling". Useful for image composition assessment, image aesthetic assesment, etc.
Python
112
star
14

Awesome-Visible-Watermark-Removal

102
star
15

Object-Shadow-Generation-Dataset-DESOBAv2

[CVPR 2024] The dataset, code, and model for our paper "Shadow Generation for Composite Image Using Diffusion Model", CVPR, 2024.
Python
102
star
16

GracoNet-Object-Placement

[ECCV 2022] Official code for "Learning Object Placement via Dual-path Graph Completion"
Python
100
star
17

Awesome-Object-Shadow-Generation

A curated list of papers, code, and resources pertaining to object shadow generation.
89
star
18

Awesome-Generative-Image-Composition

A curated list of papers, code, and resources pertaining to generative image composition or object insertion.
Python
78
star
19

F2GAN-Few-Shot-Image-Generation

Fusing-and-Filling GAN (F2GAN) for few-shot image generation, ACM MM2020
Python
78
star
20

Awesome-Object-Placement

A curated list of papers, code, and resources pertaining to object placement.
75
star
21

Object-Placement-Assessment-Dataset-OPA

The first dataset of composite images with rationality score indicating whether the object placement in a composite image is reasonable.
Python
74
star
22

BargainNet-Image-Harmonization

BargainNet: Background-Guided Domain Translation for Image Harmonization. Useful for Image harmonization, image composition, etc.
Python
67
star
23

SimTrans-Weak-Shot-Classification

[NeurIPS 2021] The first weak-shot classification paper.
Python
63
star
24

SSP-AI-Generated-Image-Detection

The code for "A Single Simple Patch is All You Need for AI-generated Image Detection"
Python
62
star
25

Video-Harmonization-Dataset-HYouTube

[IJCAI 2022] The first public benchmark dataset for video harmonization. The code used in our paper "Deep Video Harmonization with Color Mapping Consistency", IJCAI 2022.
Python
59
star
26

ObjectStitch-Image-Composition

An unofficial implementation of the paper "ObjectStitch: Object Compositing with Diffusion Model", CVPR 2023.
Python
55
star
27

TraMaS-Weak-Shot-Object-Detection

[NeurIPS 2021] A weak-shot object detection approach by transferring semantic similarity and mask prior.
Python
52
star
28

PHDiffusion-Painterly-Image-Harmonization

[ACM MM 2023] The code used in our paper "Painterly Image Harmonization using Diffusion Model", ACM MM2023.
Python
51
star
29

DeltaGAN-Few-Shot-Image-Generation

[ECCV 2022] Generate sample-specific intra-category deltas for few-shot image generation.
Python
50
star
30

PHDNet-Painterly-Image-Harmonization

[AAAI 2023] Painterly image harmonization in both spatial domain and frequency domain.
Python
50
star
31

Causal-VidQA

[CVPR 2022] A large-scale public benchmark dataset for video question-answering, especially about evidence and commonsense reasoning. The code used in our paper "From Representation to Reasoning: Towards both Evidence and Commonsense Reasoning for Video Question-Answering", CVPR2022.
Python
50
star
32

SimFormer-Weak-Shot-Semantic-Segmentation

Python
44
star
33

DucoNet-Image-Harmonization

[ACM MM 23] Deep image harmonization in Dual Color Space
Python
38
star
34

Awesome-Image-Blending

A curated list of papers, code and resources pertaining to image blending.
38
star
35

CaGNetv2-Zero-Shot-Semantic-Segmentation

Code for "From Pixel to Patch: Synthesize Context-aware Features for Zero-shot Semantic Segmentation".
Python
36
star
36

SycoNet-Adaptive-Image-Harmonization

[ICCV 2023] The code used in our paper "Deep Image Harmonization with Learnable Augmentation", ICCV2023.
Python
35
star
37

FOPA-Fast-Object-Placement-Assessment

A discriminative object placement approach
Python
32
star
38

MatchingGAN-Few-Shot-Image-Generation

code for Matchinggan: Matching-Based Few-Shot Image Generation
Python
30
star
39

ProPIH-Painterly-Image-Harmonization

[AAAI2024] Progressive Painterly Image Harmonization from Low-level Styles to High-level Styles
Python
24
star
40

RETAB-Weak-Shot-Semantic-Segmentation

Official Implementation for Weak-shot Semantic Segmentation by Transferring Semantic Affinity and Boundary (BMVC 2022)
Python
24
star
41

ArtoPIH-Painterly-Image-Harmonization

[AAAI2024] Painterly Image Harmonization by Learning from Painterly Objects
Python
24
star
42

Human-Centric-Image-Cropping

Official implementation for ECCV2022 paper: Human-centric Image Cropping with Partition-aware and Content-preserving Features.
Python
24
star
43

DIRL-Inharmonious-Region-Localization

[ICME2021]The first work on Deep Inharmonious Region Localization, which can help image harmonization in an adversarial way.
Python
24
star
44

Accessory-Try-On-Dataset-STRAT

A virtual accessory try-on dataset which could be used for image composition
Python
21
star
45

TopNet-Object-Placement

An unofficial implementation of the paper "TopNet: Transformer-based Object Placement Network for Image Compositing", CVPR 2023.
Python
20
star
46

Foreground-Object-Search-Dataset-FOSD

[ICCV 2023] The datasets and code used in our paper "Foreground Object Search by Distilling Composite Image Feature", ICCV2023.
Python
19
star
47

Composite-Image-Evaluation

19
star
48

stock-price-prediction

Fall 18' Class Project for Artificial Intelligence
Jupyter Notebook
19
star
49

Rendered-Shadow-Generation-Dataset-RdSOBA

[AAAI 2024] The dataset used in our paper "Shadow Generation with Decomposed Mask Prediction and Attentive Shadow Filling", AAAI 2024.
19
star
50

DreamCom-Image-Composition

A simple baseline for image composition using text-guided inpainting model
Python
18
star
51

MadisNet-Inharmonious-Region-Localization

[AAAI 2022] MadisNet: Inharmonious Region Localization by Magnifying Domain Discrepancy
Python
16
star
52

Rendered-Image-Harmonization-Dataset-RdHarmony

The first rendered image harmonization dataset. Used in our paper "CharmNet: Deep Image Harmonization by Bridging the Reality Gap". Useful for Image harmonization, image composition, etc.
Python
16
star
53

Image-Harmonization-Dataset-ccHarmony

[ICCV 2023] The color checker based harmonization dataset contributed in our paper "Deep Image Harmonization with Globally Guided Feature Transformation and Relation Distillation", ICCV2023.
Python
16
star
54

Color-Transfer-for-Image-Harmonization

Summarize different color transfer strategies for image harmonization task.
MATLAB
15
star
55

Awesome-Foreground-Object-Search

A curated list of papers, code, and resources pertaining to foreground object search.
13
star
56

AustNet-Inharmonious-Region-Localization

[BMVC2022] Inharmonious Region Localization with Auxiliary Style Feature
Python
13
star
57

GPSDiffusion-Object-Shadow-Generation

4
star
58

toolbox

Python
4
star
59

MureObjectStitch-Image-Composition

Python
3
star
60

iConReg

Regulating contagion risk to curb the systemic crisis in loan networks though deep graph learning
2
star
61

Awesome-Video-Composition

2
star
62

ESL-chinese

Element of Statistical Learning 中文翻译版
1
star
63

anormal-detection

anormal detection of time series data.
1
star
64

financial-time-series

Learning Causal Relationships in Financial Time Series
1
star