A TensorFlow Implementation of "Deep Multi-Scale Video Prediction Beyond Mean Square Error" by Mathieu, Couprie & LeCun.

Overview

Adversarial Video Generation

This project implements a generative adversarial network to predict future frames of video, as detailed in "Deep Multi-Scale Video Prediction Beyond Mean Square Error" by Mathieu, Couprie & LeCun. Their official code (using Torch) can be found here.

Adversarial generation uses two networks – a generator and a discriminator – to improve the sharpness of generated images. Given the past four frames of video, the generator learns to generate accurate predictions for the next frame. Given either a generated or a real-world image, the discriminator learns to correctly classify between generated and real. The two networks "compete," with the generator attempting to fool the discriminator into classifying its output as real. This forces the generator to create frames that are very similar to what real frames in the domain might look like.

Results and Comparison

I trained and tested my network on a dataset of frame sequences from Ms. Pac-Man. To compare adversarial training vs. non-adversarial, I trained an adversarial network for 500,000 steps on both the generator and discriminator, and I trained a non-adversarial network for 1,000,000 steps (as the non-adversarial network runs about twice as fast). Training took around 24 hours for each network, using a GTX 980TI GPU.

In the following examples, I ran the networks recursively for 64 frames. (i.e. The input to generate the first frame was [input1, input2, input3, input4], the input to generate the second frame was [input2, input3, input4, generated1], etc.). As the networks are not fed actions from the original game, they cannot predict much of the true motion (such as in which direction Ms. Pac-Man will turn). Thus, the goal is not to line up perfectly with the ground truth images, but to maintain a crisp and likely representation of the world.

The following example exhibits how quickly the non-adversarial network becomes fuzzy and loses definition of the sprites. The adversarial network exhibits this behavior to an extent, but is much better at maintaining sharp representations of at least some sprites throughout the sequence:

This example shows how the adversarial network is able to keep a sharp representation of Ms. Pac-Man around multiple turns, while the non-adversarial network fails to do so:

While the adversarial network is clearly superior in terms of sharpness and consistency over time, the non-adversarial network does generate some fun/spectacular failures:

Using the error measurements outlined in the paper (Peak Signal to Noise Ratio and Sharp Difference) did not show significant difference between adversarial and non-adversarial training. I believe this is because sequential frames from the Ms. Pac-Man dataset have no motion in the majority of pixels, while the original paper was trained on real-world video where there is motion in much of the frame. Despite this, it is clear that adversarial training produces a qualitative improvement in the sharpness of the generated frames, especially over long time spans. You can view the loss and error statistics by running tensorboard --logdir=./Results/Summaries/ from the root of this project.

Usage

  1. Clone or download this repository.
  2. Prepare your data:
  • If you want to replicate my results, you can download the Ms. Pac-Man dataset here. Put this in a directory named Data/ in the root of this project for default behavior. Otherwise, you will need to specify your data location using the options outlined in parts 3 and 4.
  • If you would like to train on your own videos, preprocess them so that they are directories of frame sequences as structured below. (Neither the names nor the image extensions matter, only the structure):
  - Test
    - Video 1
      - frame1.png
      - frame2.png
      - frame ...
      - frameN.png
    - Video ...
    - Video N
      - ...
  - Train
    - Video 1
      - frame ...
    - Video ...
    - Video N
      - frame ...
  1. Process training data:
  • The network trains on random 32x32 pixel crops of the input images, filtered to make sure that most clips have some movement in them. To process your input data into this form, run the script python process_data from the Code/ directory with the following options:
-n/--num_clips= <# clips to process for training> (Default = 5000000)
-t/--train_dir= <Directory of full training frames>
-c/--clips_dir= <Save directory for processed clips>
                (I suggest making this a hidden dir so the filesystem doesn't freeze
                 with so many files. DON'T `ls` THIS DIRECTORY!)
-o/--overwrite  (Overwrites the previous data in clips_dir)
-H/--help       (prints usage)
  • This can take a few hours to complete, depending on the number of clips you want.
  1. Train/Test:
  • If you want to plug-and-play with the Ms. Pac-Man dataset, you can download my trained models here. Load them using the -l option. (e.g. python avg_runner.py -l ./Models/Adversarial/model.ckpt-500000).
  • Train and test your network by running python avg_runner.py from the Code/ directory with the following options:
-l/--load_path=    <Relative/path/to/saved/model>
-t/--test_dir=     <Directory of test images>
-r--recursions=    <# recursive predictions to make on test>
-a/--adversarial=  <{t/f}> (Whether to use adversarial training. Default=True)
-n/--name=         <Subdirectory of ../Data/Save/*/ in which to save output of this run>
-O/--overwrite     (Overwrites all previous data for the model with this save name)
-T/--test_only     (Only runs a test step -- no training)
-H/--help          (Prints usage)
--stats_freq=      <How often to print loss/train error stats, in # steps>
--summary_freq=    <How often to save loss/error summaries, in # steps>
--img_save_freq=   <How often to save generated images, in # steps>
--test_freq=       <How often to test the model on test data, in # steps>
--model_save_freq= <How often to save the model, in # steps>

FAQs

Why don't you train on patches larger then 32x32? Why not train on the whole image?

Memory usage. Since the discriminator has fully-connected layers after the convolutions, the output of the last convolution must be flattened to connect to the first fully-connected layer. The size of this output is dependent on the input image size, and blows up really quickly (e.g. For an input size of 64x64, going from 128 feature maps to a fully connected layer with 512 nodes, you need a connection with 64 * 64 * 128 * 512 = 268,435,456 weights). Because of this, training on patches larger than 32x32 causes an out-of-memory error (at least on my machine).

Luckily, you only need the discriminator for training, and the generator network is fully convolutional, so you can test the weights you trained on 32x32 images over images of any size (which is why I'm able to do generations for the entire Ms. Pac-Man board).

Comments
  • What do the output images represent?

    What do the output images represent?

    screen shot 2018-03-16 at 12 59 19 pm I have been able to run this code successfully, excellent tutorial by the way. I had few doubts, if I may, I have been saving the output images after every 10 steps. The output image folder has 7 folders from 0 to 7. I wanted to know what exactly do these 7 folders represent? Will the model generate outputs of all the images given in training folder? Im not able to understand what exactly are these. screen shot 2018-03-16 at 12 47 13 pm
    opened by AdarshMJ 12
  • how to decide the SCALE_CONV_FMS  and SCALE_KERNEL_SIZES

    how to decide the SCALE_CONV_FMS and SCALE_KERNEL_SIZES

    Hello: If I want to change the number of the input frames and the output frames. for example, given 10 input frames and predict the next 3 frames. then, how to decide the matrix of SCALE_CONV_FMS, SCALE_KERNEL_SIZES and SCALE_FC_LAYER_SIZES.

    Thank you!

    opened by bitxsw93 9
  • Confusion using the plug-and-play data

    Confusion using the plug-and-play data

    Hi,

    I've cloned the repo and grabbed your trained models in an attempt to quickly see the demo running on my computer, but I'm getting an error and I'm not 100% sure I've understood how to place the data correctly:

    get_train_batch c.TRAIN_DIR_CLIPS ../Data/.Clips/ c.NUM_CLIPS 0
    Traceback (most recent call last):
      File "avg_runner.py", line 186, in <module>
        main()
      File "avg_runner.py", line 182, in main
        runner.train()
      File "avg_runner.py", line 68, in train
        batch = get_train_batch()
      File "~/Adversarial_Video_Generation/Code/utils.py", line 127, in get_train_batch
        path = c.TRAIN_DIR_CLIPS + str(np.random.choice(c.NUM_CLIPS)) + '.npz'
      File "mtrand.pyx", line 1391, in mtrand.RandomState.choice (numpy/random/mtrand/mtrand.c:15381)
    ValueError: a must be greater than 0
    

    I'm running the script by first cding into Code then running python avg_runner.py -l ../Models/Adversarial/model.ckpt-500000. I've added a print statement before the error line to see what the variables hold and it looks like the .Clips folder is empty: get_train_batch c.TRAIN_DIR_CLIPS ../Data/.Clips/ c.NUM_CLIPS 0

    I've double checked and that seems to be the case:

    > file ../Data/.Clips/
    ../Data/.Clips/: directory
    > ls ../Data/.Clips/ | wc -w
    0
    

    I feel I'm missing something: should I have downloaded the contents of the .Clips folder (if so from where ?) or should the .Clips contents be generated ?

    How can I double check and make sure I'm using the examples correctly ?

    I am using tensorflow version '0.12.0' with gpu support in a virtual environment on OSX 10.11.5 with an nVidia GeForce GT 750M (2GB VRAM), CUDA 8.0 and CuDNN 5.1 installed.

    The first 3 levels of the repo look like this:

    ├── Code
    │   ├── avg_runner.py
    │   ├── constants.py
    │   ├── constants.pyc
    │   ├── d_model.py
    │   ├── d_model.pyc
    │   ├── d_scale_model.py
    │   ├── d_scale_model.pyc
    │   ├── g_model.py
    │   ├── g_model.pyc
    │   ├── loss_functions.py
    │   ├── loss_functions.pyc
    │   ├── loss_functions_test.py
    │   ├── process_data.py
    │   ├── tfutils.py
    │   ├── tfutils.pyc
    │   ├── tfutils_test.py
    │   ├── utils.py
    │   └── utils.pyc
    ├── Data
    │   └── Ms_Pacman
    │       ├── Test
    │       └── Train
    ├── DataOld
    │   └── Ms_Pacman
    │       ├── Test
    │       └── Train
    ├── LICENSE
    ├── Models
    │   ├── Adversarial
    │   │   ├── checkpoint
    │   │   ├── model.ckpt-500000
    │   │   └── model.ckpt-500000.meta
    │   └── NonAdversarial
    │       ├── checkpoint
    │       ├── model.ckpt-1020000
    │       └── model.ckpt-1020000.meta
    ├── Models.zip
    ├── Ms_Pacman.zip
    ├── README.md
    ├── Results
    │   ├── Gifs
    │   │   ├── 4_Comparison.gif
    │   │   ├── 5_Comparison.gif
    │   │   └── rainbow_NonAdv.gif
    │   └── Summaries
    │       ├── Adv-1
    │       └── NonAdv-1
    ├── Save
    │   ├── Images
    │   │   └── Default
    │   ├── Models
    │   │   └── Default
    │   └── Summaries
    │       └── Default
    └── deep_multi-scale_video_prediction_beyond_mean_square_error.pdf
    

    Full output:

    python avg_runner.py -l ../Models/Adversarial/model.ckpt-500000
    I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcublas.dylib locally
    I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcudnn.dylib locally
    I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcufft.dylib locally
    I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcuda.1.dylib locally
    I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcurand.dylib locally
    c.TEST_DIR ../Data/Ms_Pacman/Test/
    I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:901] OS X does not support NUMA - returning NUMA node zero
    I tensorflow/core/common_runtime/gpu/gpu_device.cc:885] Found device 0 with properties: 
    name: GeForce GT 750M
    major: 3 minor: 0 memoryClockRate (GHz) 0.9255
    pciBusID 0000:01:00.0
    Total memory: 2.00GiB
    Free memory: 1.21GiB
    I tensorflow/core/common_runtime/gpu/gpu_device.cc:906] DMA: 0 
    I tensorflow/core/common_runtime/gpu/gpu_device.cc:916] 0:   Y 
    I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GT 750M, pci bus id: 0000:01:00.0)
    WARNING:tensorflow:From avg_runner.py:30 in __init__.: __init__ (from tensorflow.python.training.summary_io) is deprecated and will be removed after 2016-11-30.
    Instructions for updating:
    Please switch to tf.summary.FileWriter. The interface and behavior is the same; this is just a rename.
    Init discriminator...
    WARNING:tensorflow:From ~/Adversarial_Video_Generation/Code/d_model.py:92 in define_graph.: scalar_summary (from tensorflow.python.ops.logging_ops) is deprecated and will be removed after 2016-11-30.
    Instructions for updating:
    Please switch to tf.summary.scalar. Note that tf.summary.scalar uses the node name instead of the tag. This means that TensorFlow will automatically de-duplicate summary names based on the scope they are created in. Also, passing a tensor or list of tags to a scalar summary op is no longer supported.
    WARNING:tensorflow:From ~/Adversarial_Video_Generation/Code/d_model.py:93 in define_graph.: merge_summary (from tensorflow.python.ops.logging_ops) is deprecated and will be removed after 2016-11-30.
    Instructions for updating:
    Please switch to tf.summary.merge.
    Init generator...
    WARNING:tensorflow:From ~/Adversarial_Video_Generation/Code/g_model.py:199 in define_graph.: scalar_summary (from tensorflow.python.ops.logging_ops) is deprecated and will be removed after 2016-11-30.
    Instructions for updating:
    Please switch to tf.summary.scalar. Note that tf.summary.scalar uses the node name instead of the tag. This means that TensorFlow will automatically de-duplicate summary names based on the scope they are created in. Also, passing a tensor or list of tags to a scalar summary op is no longer supported.
    WARNING:tensorflow:From ~/Adversarial_Video_Generation/Code/g_model.py:219 in define_graph.: scalar_summary (from tensorflow.python.ops.logging_ops) is deprecated and will be removed after 2016-11-30.
    Instructions for updating:
    Please switch to tf.summary.scalar. Note that tf.summary.scalar uses the node name instead of the tag. This means that TensorFlow will automatically de-duplicate summary names based on the scope they are created in. Also, passing a tensor or list of tags to a scalar summary op is no longer supported.
    WARNING:tensorflow:From ~/Adversarial_Video_Generation/Code/g_model.py:221 in define_graph.: scalar_summary (from tensorflow.python.ops.logging_ops) is deprecated and will be removed after 2016-11-30.
    Instructions for updating:
    Please switch to tf.summary.scalar. Note that tf.summary.scalar uses the node name instead of the tag. This means that TensorFlow will automatically de-duplicate summary names based on the scope they are created in. Also, passing a tensor or list of tags to a scalar summary op is no longer supported.
    WARNING:tensorflow:From ~/Adversarial_Video_Generation/Code/g_model.py:226 in define_graph.: scalar_summary (from tensorflow.python.ops.logging_ops) is deprecated and will be removed after 2016-11-30.
    Instructions for updating:
    Please switch to tf.summary.scalar. Note that tf.summary.scalar uses the node name instead of the tag. This means that TensorFlow will automatically de-duplicate summary names based on the scope they are created in. Also, passing a tensor or list of tags to a scalar summary op is no longer supported.
    WARNING:tensorflow:From ~/Adversarial_Video_Generation/Code/g_model.py:228 in define_graph.: scalar_summary (from tensorflow.python.ops.logging_ops) is deprecated and will be removed after 2016-11-30.
    Instructions for updating:
    Please switch to tf.summary.scalar. Note that tf.summary.scalar uses the node name instead of the tag. This means that TensorFlow will automatically de-duplicate summary names based on the scope they are created in. Also, passing a tensor or list of tags to a scalar summary op is no longer supported.
    WARNING:tensorflow:From ~/Adversarial_Video_Generation/Code/g_model.py:232 in define_graph.: merge_summary (from tensorflow.python.ops.logging_ops) is deprecated and will be removed after 2016-11-30.
    Instructions for updating:
    Please switch to tf.summary.merge.
    WARNING:tensorflow:From ~/Adversarial_Video_Generation/Code/g_model.py:233 in define_graph.: merge_summary (from tensorflow.python.ops.logging_ops) is deprecated and will be removed after 2016-11-30.
    Instructions for updating:
    Please switch to tf.summary.merge.
    Init variables...
    Model restored from ../Models/Adversarial/model.ckpt-500000
    get_train_batch c.TRAIN_DIR_CLIPS ../Data/.Clips/ c.NUM_CLIPS 0
    Traceback (most recent call last):
      File "avg_runner.py", line 186, in <module>
        main()
      File "avg_runner.py", line 182, in main
        runner.train()
      File "avg_runner.py", line 68, in train
        batch = get_train_batch()
      File "~/Adversarial_Video_Generation/Code/utils.py", line 127, in get_train_batch
        path = c.TRAIN_DIR_CLIPS + str(np.random.choice(c.NUM_CLIPS)) + '.npz'
      File "mtrand.pyx", line 1391, in mtrand.RandomState.choice (numpy/random/mtrand/mtrand.c:15381)
    ValueError: a must be greater than 0
    

    I appreciate any tips or advice you can share.

    Thank you, George

    opened by orgicus 5
  • Regarding the normalization step

    Regarding the normalization step

    Hi Matt,

    First, thanks for sharing your nice code which helped me a lot for figuring out details of the paper. I came up with a question regarding the normalization step.
    What is the reason for making images to be in the range [0,1] in line 128~133 of 'd_model.py'? Was it due to the undesired interpolation effect occurring during running skimage.transform.resize? I tried by myself with two options: with and without taking your normalization step before resizing; it seems like there is difference.

    One more thing, when running your code with UCF101 dataset, there is an error "Images of type float must be between -1 and 1." I checked with the debugging mode, and found that sometimes skimage.transform.resize results violate [-1, 1] range. For a case you need a quick modification, I guess following code will help you some,

    sknorm_img = np.minimum(sknorm_img, 1)  
    sknorm_img = np.maximum(sknorm_img, -1)
    

    Best, Da-Hye

    opened by DahyeYoon 4
  • What is PSNR error exactly?

    What is PSNR error exactly?

    I know PSNR is Peak signal to Noise Ratio and higher PSNR value implies better the image generated. Is PSNR error and PSNR same? Or am I missing something?

    opened by AdarshMJ 3
  • Why need the data processing step?

    Why need the data processing step?

    Hi Matt,

    Thanks for the elegant code in Tensorflow. But why is the data processing step necessary?

    It seems to me that it's possible to load the dataset into memory before training (at least for the PacMan dataset), and then randomly select 32*32 patches at runtime. Will that make I/O faster?

    Thanks in advance

    opened by JonnyKong 3
  • Binary Coss-Entropy loss

    Binary Coss-Entropy loss

    I think I've found another bug: In the BCE loss you calculate -sum targets · log(preds) + (1 - targets) · log(1 - preds), whereas in the paper it is defined like this:

    BCE loss

    Following the other notation in the paper, Ŷ appears to be the prediction and Y is the target, which also matches the real interval as domain for Ŷ. So it is the other way around in the paper. Is the BCE symmetric?

    opened by 3rd3 3
  • Not up-to-date with TF

    Not up-to-date with TF

    I get the error: 'module' object has no attribute 'SummaryWriter' which I found out is due to a deprecation in the code. I recommend changing these lines or updating the FAQ to suggest a specific version of TensorFlow.

    Thanks for your work! Hopefully I can get it up and running.

    opened by stalgiag 2
  • Some problem about gdl_loss

    Some problem about gdl_loss

    Hi,

    Having read your code, I have some questions about your gdl_loss. In your implementation, it seems that you lost an inner abs ops which is different from the original equation. However, I have seen your result that performs well and I am just curious about that element's influence.

    Thanks,

    opened by nbei 1
  • 模型测试问题

    模型测试问题

    你好, 我在使用你的这个代码进行模型训练没有问题,可以正常的运行, 当我在训练结束,然后将其中的test设置为True,并添加了模型的路径进行数据测试的时候,就报错了, image DataLossError (see above for traceback): Unable to open table file ..\Save\Models\Default\model.ckpt: Data loss: not an sstable (bad magic number): perhaps your file is in a differen…… 请问这个问题应该如何解决呢, 另外一个问题是,生成的图片是不连续的,如何组合成为一个视频或者连续效果的GIF的呢

    opened by zhangtaochn 0
  • ValueError: Dimensions must be equal, but are 1 and 3 for 'generator/train/Conv2D' (op: 'Conv2D') with input shapes: [?,4,4,1], [1,2,3,3].

    ValueError: Dimensions must be equal, but are 1 and 3 for 'generator/train/Conv2D' (op: 'Conv2D') with input shapes: [?,4,4,1], [1,2,3,3].

    Thanks for your sharing, I run the coda36 with my own dataset, the size of my data is (210,160,1), and i have changed the channel 3 to 1, but some errors below:

    Traceback (most recent call last): File "/home/dell/sly/reaver-master/venv/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1576, in _create_c_op c_op = c_api.TF_FinishOperation(op_desc) tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimensions must be equal, but are 1 and 3 for 'generator/train/Conv2D' (op: 'Conv2D') with input shapes: [?,8,8,1], [1,2,3,3].

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last): File "/home/dell/sly/AdversarialVideoGeneration-master/Code36/avg_runner.py", line 185, in main() File "/home/dell/sly/AdversarialVideoGeneration-master/Code36/avg_runner.py", line 177, in main runner = AVGRunner(num_steps, load_path, num_test_rec) File "/home/dell/sly/AdversarialVideoGeneration-master/Code36/avg_runner.py", line 50, in init c.SCALE_KERNEL_SIZES_G) File "/home/dell/sly/AdversarialVideoGeneration-master/Code36/g_model.py", line 48, in init self.define_graph() File "/home/dell/sly/AdversarialVideoGeneration-master/Code36/g_model.py", line 192, in define_graph self.d_scale_preds) File "/home/dell/sly/AdversarialVideoGeneration-master/Code36/loss_functions.py", line 27, in combined_loss loss += lam_gdl * gdl_loss(gen_frames, gt_frames, alpha) File "/home/dell/sly/AdversarialVideoGeneration-master/Code36/loss_functions.py", line 88, in gdl_loss gen_dx = tf.abs(tf.nn.conv2d(gen_frames[i], filter_x, strides, padding=padding)) File "/home/dell/sly/reaver-master/venv/lib/python3.5/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 956, in conv2d data_format=data_format, dilations=dilations, name=name) File "/home/dell/sly/reaver-master/venv/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "/home/dell/sly/reaver-master/venv/lib/python3.5/site-packages/tensorflow/python/util/deprecation.py", line 454, in new_func return func(*args, **kwargs) File "/home/dell/sly/reaver-master/venv/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3155, in create_op op_def=op_def) File "/home/dell/sly/reaver-master/venv/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1731, in init control_input_ops) File "/home/dell/sly/reaver-master/venv/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1579, in _create_c_op raise ValueError(str(e)) ValueError: Dimensions must be equal, but are 1 and 3 for 'generator/train/Conv2D' (op: 'Conv2D') with input shapes: [?,8,8,1], [1,2,3,3].

    Process finished with exit code 1

    I don't know whether i need to change other places??

    opened by songwaimai 0
  • TypeError: Value passed to parameter 'shape' has DataType float32 not in list of allowed values: int32, int64

    TypeError: Value passed to parameter 'shape' has DataType float32 not in list of allowed values: int32, int64

    Traceback (most recent call last): File "avg_runner.py", line 185, in main() File "avg_runner.py", line 177, in main runner = AVGRunner(num_steps, load_path, num_test_rec) File "avg_runner.py", line 40, in init c.SCALE_FC_LAYER_SIZES_D) File "C:\Users\tao-he\PycharmProjects\testing-pytorch\combustion\Adversarial_Video_Generation-master\Code\d_model.py", line 44, in init self.define_graph() File "C:\Users\tao-he\PycharmProjects\testing-pytorch\combustion\Adversarial_Video_Generation-master\Code\d_model.py", line 65, in define_graph self.scale_fc_layer_sizes[scale_num])) File "C:\Users\tao-he\PycharmProjects\testing-pytorch\combustion\Adversarial_Video_Generation-master\Code\d_scale_model.py", line 43, in init self.define_graph() File "C:\Users\tao-he\PycharmProjects\testing-pytorch\combustion\Adversarial_Video_Generation-master\Code\d_scale_model.py", line 76, in define_graph self.conv_layer_fms[i + 1]])) File "C:\Users\tao-he\PycharmProjects\testing-pytorch\combustion\Adversarial_Video_Generation-master\Code\tfutils.py", line 10, in w return tf.int32(Variable(tf.random.truncated_normal(shape, stddev=stddev))) NameError: name 'Variable' is not defined

    C:\Users\tao-he\PycharmProjects\testing-pytorch\combustion\Adversarial_Video_Generation-master\Code>python avg_runner.py --test_dir=F:/zfg/Input/test/ -- name=F:/zfg/output/ --stats_freq=100 --summary_freq=100 --img_save_freq=100 --test_freq=2 --model_save_freq=100 C:\Users\tao-he\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\framework\dtypes.py:516: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint8 = np.dtype([("qint8", np.int8, 1)]) C:\Users\tao-he\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\framework\dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint8 = np.dtype([("quint8", np.uint8, 1)]) C:\Users\tao-he\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\framework\dtypes.py:518: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint16 = np.dtype([("qint16", np.int16, 1)]) C:\Users\tao-he\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\framework\dtypes.py:519: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint16 = np.dtype([("quint16", np.uint16, 1)]) C:\Users\tao-he\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\framework\dtypes.py:520: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint32 = np.dtype([("qint32", np.int32, 1)]) C:\Users\tao-he\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\framework\dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. np_resource = np.dtype([("resource", np.ubyte, 1)]) C:\Users\tao-he\AppData\Roaming\Python\Python36\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:541: FutureWarning: Passing (type, 1) or '1typ e' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint8 = np.dtype([("qint8", np.int8, 1)]) C:\Users\tao-he\AppData\Roaming\Python\Python36\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:542: FutureWarning: Passing (type, 1) or '1typ e' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint8 = np.dtype([("quint8", np.uint8, 1)]) C:\Users\tao-he\AppData\Roaming\Python\Python36\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:543: FutureWarning: Passing (type, 1) or '1typ e' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint16 = np.dtype([("qint16", np.int16, 1)]) C:\Users\tao-he\AppData\Roaming\Python\Python36\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:544: FutureWarning: Passing (type, 1) or '1typ e' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint16 = np.dtype([("quint16", np.uint16, 1)]) C:\Users\tao-he\AppData\Roaming\Python\Python36\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:545: FutureWarning: Passing (type, 1) or '1typ e' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint32 = np.dtype([("qint32", np.int32, 1)]) C:\Users\tao-he\AppData\Roaming\Python\Python36\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:550: FutureWarning: Passing (type, 1) or '1typ e' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. np_resource = np.dtype([("resource", np.ubyte, 1)]) 2019-11-19 11:50:22.962937: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compi led to use: AVX2 Init discriminator... Traceback (most recent call last): File "avg_runner.py", line 185, in main() File "avg_runner.py", line 177, in main runner = AVGRunner(num_steps, load_path, num_test_rec) File "avg_runner.py", line 40, in init c.SCALE_FC_LAYER_SIZES_D) File "C:\Users\tao-he\PycharmProjects\testing-pytorch\combustion\Adversarial_Video_Generation-master\Code\d_model.py", line 44, in init self.define_graph() File "C:\Users\tao-he\PycharmProjects\testing-pytorch\combustion\Adversarial_Video_Generation-master\Code\d_model.py", line 65, in define_graph self.scale_fc_layer_sizes[scale_num])) File "C:\Users\tao-he\PycharmProjects\testing-pytorch\combustion\Adversarial_Video_Generation-master\Code\d_scale_model.py", line 43, in init self.define_graph() File "C:\Users\tao-he\PycharmProjects\testing-pytorch\combustion\Adversarial_Video_Generation-master\Code\d_scale_model.py", line 95, in define_graph self.fc_layer_sizes[i + 1]])) File "C:\Users\tao-he\PycharmProjects\testing-pytorch\combustion\Adversarial_Video_Generation-master\Code\tfutils.py", line 10, in w return tf.Variable(tf.random.truncated_normal(shape, stddev=stddev)) File "C:\Users\tao-he\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\ops\random_ops.py", line 178, in truncated_normal shape_tensor, dtype, seed=seed1, seed2=seed2) File "C:\Users\tao-he\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\ops\gen_random_ops.py", line 1063, in truncated_normal name=name) File "C:\Users\tao-he\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\framework\op_def_library.py", line 626, in _apply_op_helper param_name=input_name) File "C:\Users\tao-he\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\framework\op_def_library.py", line 60, in _SatisfiesTypeConstrain t ", ".join(dtypes.as_dtype(x).name for x in allowed_list))) TypeError: Value passed to parameter 'shape' has DataType float32 not in list of allowed values: int32, int64

    hello, thanks for sharing the repo for us,but when i have finished the 1-3 steps and begin to start train on my own datasets,TypeError: Value passed to parameter 'shape' has DataType float32 not in list of allowed values: int32, int64 is coming, even i changed all the dtype into int,the type error still exited. I will appreciate it very much if you can help me with the error.

    opened by birdflyto 1
  • GLARING bug with the process data pipeline.

    GLARING bug with the process data pipeline.

    Hey all! There is a glaring bug with the data_proccess pipeline.

    Currently, for each clip, the video generator sorts the data by filename ep_frame_paths = (glob(os.path.join(ep_dir, '*'))). If your files are written as

    filename1
    filename2
    ...
    filenameN
    

    and N > 10 this will interlace earlier frames of the data into the clips used for training. With a large history window this adds some robustness to the model, but it really invalidates the modeling assumption!

    Sortiing by the last integer fixes this (change line 80 to this)

    ep_frame_paths = sorted(glob(os.path.join(ep_dir, '*')), key=lambda x: int(x.split("frame")[-1].split(".png")[0]))
    
    opened by MadcowD 0
  • Updating Code to New Tensorflow version

    Updating Code to New Tensorflow version

    Hi, I tried running avg_runner.py and I'm getting quite a few function deprecation errors. For example, the summary writer function here is getting an error:

    File "avg_runner.py", line 191, in <module>
    main()
    

    File "avg_runner.py", line 183, in main runner = AVGRunner(num_steps, load_path, num_test_rec) File "avg_runner.py", line 32, in init self.summary_writer = tf.train.SummaryWriter(c.SUMMARY_SAVE_DIR, graph=self.sess.graph) AttributeError: 'module' object has no attribute 'SummaryWriter'

    I'm using version 1.13.1 of tensorflow, but I noticed the code is only updated for version 0.12. I tried to install version 0.12 of tensorflow but it looks like the older versions are not available anymore. Are there any updated versions of this code using a newer version of tensorflow?

    opened by jennahorrall 2
  • ValueError: Dimension 3 in both shapes must be equal

    ValueError: Dimension 3 in both shapes must be equal

    Traceback (most recent call last): File "/home/guohaoyu/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1628, in _create_c_op c_op = c_api.TF_FinishOperation(op_desc) tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimension 3 in both shapes must be equal, but are 12 and 3. Shapes are [?,8,8,12] and [?,8,8,3]. From merging shape 0 with other shapes. for 'generator/scale_1/calculation/concat/concat_dim' (op: 'Pack') with input shapes: [?,8,8,12], [?,8,8,3].

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last): File "avg_runner.py", line 187, in main() File "avg_runner.py", line 179, in main runner = AVGRunner(num_steps, load_path, num_test_rec) File "avg_runner.py", line 50, in init c.SCALE_KERNEL_SIZES_G) File "/home/guohaoyu/vedio_generation/Adversarial_Video_Generation/Code/g_model.py", line 48, in init self.define_graph() File "/home/guohaoyu/vedio_generation/Adversarial_Video_Generation/Code/g_model.py", line 159, in define_graph last_scale_pred_train) File "/home/guohaoyu/vedio_generation/Adversarial_Video_Generation/Code/g_model.py", line 123, in calculate inputs = tf.concat(3, [inputs, last_gen_frames]) File "/home/guohaoyu/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 1121, in concat dtype=dtypes.int32).get_shape().assert_is_compatible_with( File "/home/guohaoyu/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1050, in convert_to_tensor as_ref=False) File "/home/guohaoyu/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1146, in internal_convert_to_tensor ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref) File "/home/guohaoyu/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 971, in _autopacking_conversion_function return _autopacking_helper(v, dtype, name or "packed") File "/home/guohaoyu/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 923, in _autopacking_helper return gen_array_ops.pack(elems_as_tensors, name=scope) File "/home/guohaoyu/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/ops/gen_array_ops.py", line 4875, in pack "Pack", values=values, axis=axis, name=name) File "/home/guohaoyu/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "/home/guohaoyu/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 488, in new_func return func(*args, **kwargs) File "/home/guohaoyu/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3274, in create_op op_def=op_def) File "/home/guohaoyu/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1792, in init control_input_ops) File "/home/guohaoyu/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1631, in _create_c_op raise ValueError(str(e)) ValueError: Dimension 3 in both shapes must be equal, but are 12 and 3. Shapes are [?,8,8,12] and [?,8,8,3]. From merging shape 0 with other shapes. for 'generator/scale_1/calculation/concat/concat_dim' (op: 'Pack') with input shapes: [?,8,8,12], [?,8,8,3].

    opened by ghailey 1
  • Loss weighting

    Loss weighting

    As I can see here: https://github.com/dyelax/Adversarial_Video_Generation/blob/9b0d10f357871231bbec06c610363588812216e1/Code/g_model.py#L189 https://github.com/dyelax/Adversarial_Video_Generation/blob/9b0d10f357871231bbec06c610363588812216e1/Code/loss_functions.py#L7 there is no weighting on GDL loss, but as I understand absolute values of L2 loss and GDL loss will have large difference. Is it normal?

    @dyelax

    opened by mrgloom 1
Owner
Matt Cooper
I'm an entrepreneur who loves music, coding and great design. Passionate about advancing AI and creating products that bring those advancements to the world.
Matt Cooper
Deploy tensorflow graphs for fast evaluation and export to tensorflow-less environments running numpy.

Deploy tensorflow graphs for fast evaluation and export to tensorflow-less environments running numpy. Now with tensorflow 1.0 support. Evaluation usa

Marcel R. 349 Aug 6, 2022
TensorFlow Ranking is a library for Learning-to-Rank (LTR) techniques on the TensorFlow platform

TensorFlow Ranking is a library for Learning-to-Rank (LTR) techniques on the TensorFlow platform

null 2.6k Jan 4, 2023
Robust Video Matting in PyTorch, TensorFlow, TensorFlow.js, ONNX, CoreML!

Robust Video Matting in PyTorch, TensorFlow, TensorFlow.js, ONNX, CoreML!

Peter Lin 6.5k Jan 4, 2023
Robust Video Matting in PyTorch, TensorFlow, TensorFlow.js, ONNX, CoreML!

Robust Video Matting (RVM) English | 中文 Official repository for the paper Robust High-Resolution Video Matting with Temporal Guidance. RVM is specific

flow-dev 2 Aug 21, 2022
Implementation of Restricted Boltzmann Machine (RBM) and its variants in Tensorflow

xRBM Library Implementation of Restricted Boltzmann Machine (RBM) and its variants in Tensorflow Installation Using pip: pip install xrbm Examples Tut

Omid Alemi 55 Dec 29, 2022
Functional TensorFlow Implementation of Singular Value Decomposition for paper Fast Graph Learning

tf-fsvd TensorFlow Implementation of Functional Singular Value Decomposition for paper Fast Graph Learning with Unique Optimal Solutions Cite If you f

Sami Abu-El-Haija 14 Nov 25, 2021
StyleGAN2 - Official TensorFlow Implementation

StyleGAN2 - Official TensorFlow Implementation

NVIDIA Research Projects 10.1k Dec 28, 2022
An efficient and effective learning to rank algorithm by mining information across ranking candidates. This repository contains the tensorflow implementation of SERank model. The code is developed based on TF-Ranking.

SERank An efficient and effective learning to rank algorithm by mining information across ranking candidates. This repository contains the tensorflow

Zhihu 44 Oct 20, 2022
Implementation of Perceiver, General Perception with Iterative Attention in TensorFlow

Perceiver This Python package implements Perceiver: General Perception with Iterative Attention by Andrew Jaegle in TensorFlow. This model builds on t

Rishit Dagli 84 Oct 15, 2022
Minimal implementation of Denoised Smoothing: A Provable Defense for Pretrained Classifiers in TensorFlow.

Denoised-Smoothing-TF Minimal implementation of Denoised Smoothing: A Provable Defense for Pretrained Classifiers in TensorFlow. Denoised Smoothing is

Sayak Paul 19 Dec 11, 2022
Unofficial Implementation of MLP-Mixer in TensorFlow

mlp-mixer-tf Unofficial Implementation of MLP-Mixer [abs, pdf] in TensorFlow. Note: This project may have some bugs in it. I'm still learning how to i

Rishabh Anand 24 Mar 23, 2022
Tensorflow implementation for Self-supervised Graph Learning for Recommendation

If the compilation is successful, the evaluator of cpp implementation will be called automatically. Otherwise, the evaluator of python implementation will be called.

null 152 Jan 7, 2023
Minimal implementation of PAWS (https://arxiv.org/abs/2104.13963) in TensorFlow.

PAWS-TF ?? Implementation of Semi-Supervised Learning of Visual Features by Non-Parametrically Predicting View Assignments with Support Samples (PAWS)

Sayak Paul 43 Jan 8, 2023
Unofficial TensorFlow implementation of the Keyword Spotting Transformer model

Keyword Spotting Transformer This is the unofficial TensorFlow implementation of the Keyword Spotting Transformer model. This model is used to train o

Intelligent Machines Limited 8 May 11, 2022
A tensorflow implementation of GCN-LPA

GCN-LPA This repository is the implementation of GCN-LPA (arXiv): Unifying Graph Convolutional Neural Networks and Label Propagation Hongwei Wang, Jur

Hongwei Wang 83 Nov 28, 2022
Official Tensorflow implementation of "M-LSD: Towards Light-weight and Real-time Line Segment Detection"

M-LSD: Towards Light-weight and Real-time Line Segment Detection Official Tensorflow implementation of "M-LSD: Towards Light-weight and Real-time Line

NAVER/LINE Vision 357 Jan 4, 2023
Unofficial TensorFlow implementation of Protein Interface Prediction using Graph Convolutional Networks.

[TensorFlow] Protein Interface Prediction using Graph Convolutional Networks Unofficial TensorFlow implementation of Protein Interface Prediction usin

YeongHyeon Park 9 Oct 25, 2022
Tensorflow implementation of MIRNet for Low-light image enhancement

MIRNet Tensorflow implementation of the MIRNet architecture as proposed by Learning Enriched Features for Real Image Restoration and Enhancement. Lanu

Soumik Rakshit 91 Jan 6, 2023
Tensorflow python implementation of "Learning High Fidelity Depths of Dressed Humans by Watching Social Media Dance Videos"

Learning High Fidelity Depths of Dressed Humans by Watching Social Media Dance Videos This repository is the official tensorflow python implementation

Yasamin Jafarian 287 Jan 6, 2023