<jupyter_start><jupyter_text>Clone the repo<jupyter_code>import os

os.chdir('/content/')

!if [ ! -e ~/work ]; then git clone https://github.com/ericpts/CycleGAN-TensorFlow ~/work; fi

os.chdir('/content/work')

! git fetch origin master
! git reset --hard origin/master
!./init.py
!python3 ./build_data.py --X_input_dir data/comp/trainA --X_output_file data/tfrecords/black.tfrecords --Y_input_dir data/comp/trainB --Y_output_file data/tfrecords/colored.tfrecords<jupyter_output><empty_output><jupyter_text>Install a Drive FUSE wrapper, authenticate, and mount a Drive filesystem<jupyter_code># Install a Drive FUSE wrapper.
# https://github.com/astrada/google-drive-ocamlfuse
!apt-get install -y -qq software-properties-common python-software-properties module-init-tools
!add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null
!apt-get update -qq 2>&1 > /dev/null
!apt-get -y install -qq google-drive-ocamlfuse fuse
# Generate auth tokens for Colab
from google.colab import auth
auth.authenticate_user()
# Generate creds for the Drive FUSE library.
from oauth2client.client import GoogleCredentials
creds = GoogleCredentials.get_application_default()
import getpass
!google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL
vcode = getpass.getpass()
!echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret}
# Create a directory and mount Google Drive using that directory.
!mkdir -p ~/drive
!google-drive-ocamlfuse ~/drive
!mkdir -p /content/drive/checkpoints
!mkdir -p /content/drive/samples
!if [ -e /content/work/checkpoints ]; then unlink /content/work/checkpoints; fi
!if [ -e /content/work/samples ]; then unlink /content/work/samples; fi
!ln -sf /content/drive/checkpoints /content/work/checkpoints
!ln -sf /content/drive/samples /content/work/samples
import subprocess
import os
datetime=subprocess.check_output(['ls', 'checkpoints']).decode('utf-8').strip()
os.environ['DATETIME']=datetime
!ls checkpoints/$DATETIME<jupyter_output><empty_output><jupyter_text>Train the network<jupyter_code>!python3 train.py --X data/tfrecords/black.tfrecords --Y data/tfrecords/colored.tfrecords --load_model $DATETIME<jupyter_output><empty_output><jupyter_text>Export the models<jupyter_code>!python3 export_graph.py --checkpoint_dir checkpoints/$DATETIME \
                          --XtoY_model bw2color.pb \
                          --YtoX_model color2bw.pb \
                          --image_size 256<jupyter_output><empty_output><jupyter_text>Generate samples<jupyter_code>!python3 generate_samples.py --nsamples 100
!ls<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12532833020637899, 'fraction_numerical': 0.0075046904315197, 'mean_word_length': 4.648305084745763, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 26, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '396507', 'license': 'MIT', 'n_tokens_mistral': 913, 'n_tokens_neox': 895, 'n_words': 191, 'path': 'colab_notebook.ipynb', 'repo_name': 'ericpts/CycleGAN-TensorFlow', 'size': '2665'}