GithubHelp home page GithubHelp logo

shaohua0116 / novelviewsynthesis-tensorflow Goto Github PK

View Code? Open in Web Editor NEW
48.0 4.0 4.0 11.97 MB

A TensorFlow implementation of a simple Novel View Synthesis model on ShapeNet (cars and chairs), KITTI, and Synthia.

Home Page: https://shaohua0116.github.io/Multiview2Novelview/

License: MIT License

Python 100.00%
computer-vision image-synthesis view-synthesis novel-view-synthesis deep-learn

novelviewsynthesis-tensorflow's Introduction

Novel View Synthesis in TensorFlow

Descriptions

This project is a TensorFlow implementation of a simple novel view synthesis model, which aims to synthesize a target view with an arbitrary camera pose from a given source view and its camera pose. An illustration of the task is as follows.

The model implemented in the repo is a simple conv-deconv network with skip connections. To allow you to focus on building your own model and see how well it can work, all the data loaders/downloading scripts, the training code, as well as the training and testing splits are well-configured based on the setting used in this paper: Multi-view to Novel view: Synthesizing Novel Views with Self-Learned Confidence published in ECCV 2018. All you need to do is play with the model code: synthesizer.py.

The model can be trained on images rendered from 3D object models (ShapeNet) as well as real and synthesized scenes (KITTI and Synthia). All datasets are stored as HDF5 files, they will be downloaded once you run the training code.

  • ShapeNet: cars (150GB) and chairs (14GB)

  • KITTI (4.3GB)

  • Synthia (3.3GB)

Prerequisites

Usage

After downloading the datasets, we can start to train and test models using the following commands

Train

Train a model from scratch

$ python trainer.py --batch_size 32 --dataset car

Fine-tune a model from a checkpoint

$ python trainer.py --batch_size 32 --dataset car --checkpoint /path/to/model/model-XXX
  • Selected arguments (see the trainer.py for more details)
    • --prefix: a nickname for the training
    • --dataset: choose among car, chair, kitti, and synthia. You can also add your own datasets.
    • Checkpoints: specify the path to a pre-trained checkpoint
      • --checkpoint: load all the parameters including the flow and pixel modules and the discriminator.
    • Logging
      • --log_setp: the frequency of outputing log info ([train step 681] Loss: 0.51319 (1.896 sec/batch, 16.878 instances/sec))
      • --ckpt_save_step: the frequency of saving a checkpoint
      • --test_sample_step: the frequency of performing testing inference during training (default 100)
      • --write_summary_step: the frequency of writing TensorBoard summaries (default 100)
    • Hyperparameters
      • --batch_size: the mini-batch size (default 8)
      • --max_steps: the max training iterations

Interpret TensorBoard

Launch Tensorboard and go to the specified port, you can see differernt losses in the scalars tab and plotted images in the images tab. The scalars include L1 loss and SSIM. The plotted images show (from top to bottom): source view, target view, and the predicted target view.

Test

Evaluate trained models

$ python evaler.py --dataset car --loss True --plot_image True --output_dir car_image --write_summary True --summary_file log_car.txt --train_dir train_dir/default-car-bs_16_lr_0.0001-num_input-1-20190430-014454 --data_id_list ./testing_tuple_lists/id_car_random_elevation.txt
  • Selected arguments (see the evaler.py for more details)

    • Id list
      • --data_id_list: specify a list of data point that you want to evaluate
    • Task
      • --loss: report the loss
      • --write_summary: write the summary of this evaluation as a text file
      • --plot_image: render synthesized images
    • Output
      • --quiet: only display the final report
      • --summary_file: the path to the summary file
      • --output_dir: the output dir of plotted images
  • Synthesized images After plotting the synthesized images at the specified output_dir, we can see the results like this

  • Loss summary The overall L1 loss and SSIM can be found at log_car.txt
Checkpoint: train_dir/default-car-bs_16_lr_0.0001-20190430-014454/model-160000
Dataset: car
Id list: ./testing_tuple_lists/id_car_elevation_0.txt
[Final Avg Report] Total datapoint: 10000 from ./testing_tuple_lists/id_car_elevation_0.txt
[Loss]
l1_loss: 0.13343
ssim: 0.90811
[Time] (63.128 sec)

Related work

The code is mainly borrowed from this paper

Check out some other work in novel view synthesis

Cite the paper

If you find this useful, please cite

@inproceedings{sun2018multiview,
  title={Multi-view to Novel View: Synthesizing Novel Views with Self-Learned Confidence},
  author={Sun, Shao-Hua and Huh, Minyoung and Liao, Yuan-Hong and Zhang, Ning and Lim, Joseph J},
  booktitle={European Conference on Computer Vision},
  year={2018},
}

Authors

Shao-Hua Sun

novelviewsynthesis-tensorflow's People

Contributors

shaohua0116 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

novelviewsynthesis-tensorflow's Issues

the error does not converge

I am reproducing the paper of you,but I found the error of training does not converge.The test error and similarity did not reach your results,on the dataset of kitti,the training error is about 0.15 and cannot go down.As to the dataset of chair,the training error is about 0.1 and cannot go down.In this condition,the error of testing was poor.In this case could you give me some guidance?Thank you very much!

Running on smaller images (128,128)

Hey,
I have tried to adapt your code to run on my dataset which contains images of size 128,128. I changed output_shapes accordingly in object_loader.py. The training runs but doesnt converge to a solution, the output images are uniformly black (which is the background colour of my dataset). Do you know why this would be and how I could fix it?
Thanks

Using tensorboard

Hi, first of all, thanks for the open-sourcing of this project, it is really fantastic on the part of your team. However, I tried to use tensorboard directly from your code however it says that no dashboard are currently active. To lanunch, I used tensorboard --logdir train_dir/folder_with_train_data
Is it right?

Checkpoints available

Hi!
Are there any checkpoints available for further fine-tuning?
(especially interested in the one trained on KITTI)

Strange error when using my own dataset

Hi,
I am encountering a strange error when training with my own dataset. The training works for a while then gives me this error:

`
Traceback (most recent call last):
File "/home/ebartrum/anaconda3/envs/novel_view/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1334, in _do_call
return fn(*args)
File "/home/ebartrum/anaconda3/envs/novel_view/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1319, in _run_fn
options, feed_dict, fetch_list, target_list, run_metadata)
File "/home/ebartrum/anaconda3/envs/novel_view/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1407, in _call_tf_sessionrun
run_metadata)
tensorflow.python.framework.errors_impl.OutOfRangeError: RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 12, cur
rent size 0)
[[{{node shuffle_batch}} = QueueDequeueManyV2[component_types=[DT_FLOAT, DT_STRING, DT_FLOAT], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/device:CPU:0"]
(shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "trainer.py", line 185, in
main()
File "trainer.py", line 182, in main
trainer.train()
File "trainer.py", line 113, in train
self.run_single_step(self.batch_train, step=s, is_train=True)
File "trainer.py", line 130, in run_single_step
batch_chunk = self.session.run(batch)
File "/home/ebartrum/anaconda3/envs/novel_view/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 929, in run
run_metadata_ptr)
File "/home/ebartrum/anaconda3/envs/novel_view/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1152, in _run
feed_dict_tensor, options, run_metadata)
File "/home/ebartrum/anaconda3/envs/novel_view/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1328, in _do_run
run_metadata)
File "/home/ebartrum/anaconda3/envs/novel_view/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1348, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.OutOfRangeError: RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 12, current size 0)
[[node shuffle_batch (defined at /home/ebartrum/Documents/repos/NovelViewSynthesis-TensorFlow/input_ops.py:76) = QueueDequeueManyV2[component_types=[DT_FLOAT, DT_STRING, DT_FLOAT], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/device:CPU:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]

Caused by op 'shuffle_batch', defined at:
File "trainer.py", line 185, in
main()
File "trainer.py", line 179, in main
trainer = Trainer(config, model, dataset_train, dataset_test)
File "trainer.py", line 39, in init
dataset, self.batch_size, is_training=True)
File "/home/ebartrum/Documents/repos/NovelViewSynthesis-TensorFlow/input_ops.py", line 76, in create_input_ops
min_after_dequeue=min_capacity,
File "/home/ebartrum/anaconda3/envs/novel_view/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 306, in new_func
return func(*args, **kwargs)
File "/home/ebartrum/anaconda3/envs/novel_view/lib/python3.6/site-packages/tensorflow/python/training/input.py", line 1344, in shuffle_batch
name=name)
File "/home/ebartrum/anaconda3/envs/novel_view/lib/python3.6/site-packages/tensorflow/python/training/input.py", line 871, in _shuffle_batch
dequeued = queue.dequeue_many(batch_size, name=name)
File "/home/ebartrum/anaconda3/envs/novel_view/lib/python3.6/site-packages/tensorflow/python/ops/data_flow_ops.py", line 478, in dequeue_many
self._queue_ref, n=n, component_types=self._dtypes, name=name)
File "/home/ebartrum/anaconda3/envs/novel_view/lib/python3.6/site-packages/tensorflow/python/ops/gen_data_flow_ops.py", line 3487, in queue_dequeue_many_v2
component_types=component_types, timeout_ms=timeout_ms, name=name)
File "/home/ebartrum/anaconda3/envs/novel_view/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "/home/ebartrum/anaconda3/envs/novel_view/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 488, in new_func
return func(*args, **kwargs)
File "/home/ebartrum/anaconda3/envs/novel_view/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3274, in create_op
op_def=op_def)
File "/home/ebartrum/anaconda3/envs/novel_view/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1770, in init
self._traceback = tf_stack.extract_stack()

OutOfRangeError (see above for traceback): RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 12, current size 0)
[[node shuffle_batch (defined at /home/ebartrum/Documents/repos/NovelViewSynthesis-TensorFlow/input_ops.py:76) = QueueDequeueManyV2[component_types=[DT_FLOAT, DT_STRING, DT_FLOAT], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/device:CPU:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]
`
Do you know what this means?

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.