<jupyter_start><jupyter_text>Next Frame Prediction using Pix2PixHDBy <NAME>Forked repo and tutorial based on [<NAME>’s excellent repo and Medium](https://medium.com/@jctestud/video-generation-with-pix2pix-aed5b1b69f57) article.  Mount Google Drive<jupyter_code>from google.colab import drive
drive.mount('/content/drive', force_remount=True)<jupyter_output><empty_output><jupyter_text>**Install libraries and dependencies**  Run this cell if you haven’t previously install Pix2PixHD in your Google Drive<jupyter_code>%cd /content/drive/My\ Drive
!mkdir nfp-colab
%cd nfp-colab
!git clone -b video https://github.com/dvschultz/pix2pixHD.git
!pip install dominate
%cd pix2pixHD/<jupyter_output><empty_output><jupyter_text>Run this cell if you’ve already installed Pix2PixHD in Google Drive before<jupyter_code>%cd /content/drive/My\ Drive/nfp-colab/pix2pixHD/
# !git pull
!pip install dominate<jupyter_output><empty_output><jupyter_text>Extract frames from videoUpload a video to either Colab or Google Drive.* `-video` is the path to the video file* `-name` should be a unique name (think of it like a project name)* `-width` and `-height` **must** to be a multiple of 32* `-p2pdir` leave as `.` unless you know it shouldn’t be that ;)<jupyter_code>!python extract_frames.py -video /content/1961.mp4 -name 1961 -p2pdir . -width 1280 -height 736<jupyter_output><empty_output><jupyter_text>Train your model  Initial trainingNote: if you have a large dataset, this may timeout initially (`ValueError: __len__() should return >= 0`). Give it a minute or two and run it again.*   `--name` should be a unique name (think of it like a project name). For your sanity I recommend using the same `-name` as above.*   `--dataroot` should point to your dataset. This will usually be in `./datasets/[your project name]`<jupyter_code>!python train_video.py --name chiquitettas2 --dataroot ./datasets/chiquitettas2/ --save_epoch_freq 5 #--continue_train<jupyter_output><empty_output><jupyter_text>Continue TrainingTo pick up from a previous training session run the same command you ran to start with and append `--continue_train` to the end of the command.<jupyter_code>!python train_video.py --name chiquitettas2 --dataroot ./datasets/chiquitettas2/ --save_epoch_freq 1 --continue_train<jupyter_output><empty_output><jupyter_text>Generating VideosTo generate a video from your completed model, run the `generate_video.py` script. I recommend keeping the `--name` and `--dataroot` arguments the same.There are a number of additional arguments you’ll need to include in this command:*   `--fps` frame rate for your video*   `--how_many` how many frames you want to create (this + fps = video length)*   `--which_epoch` which epoch you want to generate videos from (note: if you choose `133` but there’s no epoch 133 model file, this will throw an error)*   `--start_from` by default your video will start predicting images from the 60th frame of your training set. You can pass in the path to a different frame to have it start from that frameI recommend playing with both the `--which_epoch` and `--start_from` arguments as you can get dramatically different results by changing in the inputs here.<jupyter_code>!python generate_video.py --name chiquitettas2 --dataroot ./datasets/chiquitettas2/ --fps 24 --how_many 600 --which_epoch latest
import os

def exportMultiple():
  for epoch in range(10, 200, 10):
    command = 'python generate_video.py --name chiquitettas2 --dataroot ./datasets/chiquitettas2/ --fps 24 --how_many 600 --which_epoch {e}'.format(e = epoch)
    print('running: ' + command)
    os.system(command)

exportMultiple()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09819474835886215, 'fraction_numerical': 0.01887308533916849, 'mean_word_length': 4.995081967213115, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 32, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '375356', 'license': 'MIT', 'n_tokens_mistral': 1187, 'n_tokens_neox': 1118, 'n_words': 421, 'path': 'Pix2PixHD_next_frame.ipynb', 'repo_name': 'duskvirkus/colab-notebooks', 'size': '3668'}