<jupyter_start><jupyter_text>Colab-co-mod-ganOriginal repo: [zsyzzsoft/co-mod-gan](https://github.com/zsyzzsoft/co-mod-gan)My fork: [styler00dollar/Colab-co-mod-gan](https://github.com/styler00dollar/Colab-co-mod-gan)<jupyter_code>!nvidia-smi
#@title install
!git clone https://github.com/zsyzzsoft/co-mod-gan
# tensorflow 1.15 to avoid tensorflow.python.framework.errors_impl.NotFoundError
!pip install tensorflow==1.15
%cd /content/co-mod-gan<jupyter_output><empty_output><jupyter_text>TestingJust place ``/content/input.png`` and ``/content/mask.png``.<jupyter_code>#@title download pretrain
!gdown --id 1dJa3DRWIkx6Ebr8Sc0v1FdvWf6wkd010 # co-mod-gan-places2-050000.pkl
#!gdown --id 1b3XxfAmJ9k2vd73j-3nPMr_lvNMQOFGE # co-mod-gan-ffhq-9-025000.pkl
#!gdown --id 1M2dSxlJnCFNM6LblpB2nQCnaimgwaaKu # co-mod-gan-ffhq-10-025000.pkl
#@title (optional) read / write / resize file with opencv / invert mask
#@markdown You need masks where ``white = original`` and ``black = inpaint``. Both images are rgb and have the needed dimensions.
import cv2
path_image = '/content/input.png'
path_mask = '/content/mask.png'
image = cv2.imread(path_image)
image = cv2.resize(image, (512,512), cv2.INTER_NEAREST)
cv2.imwrite(path_image, image)

image = cv2.imread(path_mask)
image = 255-image
image = cv2.resize(image, (512,512), cv2.INTER_NEAREST)
cv2.imwrite(path_mask, image)
%cd /content/co-mod-gan
!python run_generator.py -c co-mod-gan-places2-050000.pkl -i /content/input.png -m /content/mask.png -o /content/output.png<jupyter_output><empty_output><jupyter_text>TrainingWarnings: Free colab does not have enough RAM. You need Colab Pro with 25GB RAM. Needs ~13GB RAM. Also needs ~10GB VRAM.Training can also crash, because of:```  File "/content/co-mod-gan/metrics/inception_discriminative_score.py", line 30, in _evaluate    inception = misc.load_pkl('https://drive.google.com/uc?id=1MzTY44rLToO5APn8TZmfR7_ENSe5aZUn')  inception_v3_features.pkl  File "/content/co-mod-gan/training/misc.py", line 29, in load_pkl    with open_file_or_url(file_or_url) as file:  File "/content/co-mod-gan/training/misc.py", line 25, in open_file_or_url    return dnnlib.util.open_url(file_or_url, cache_dir='.stylegan2-cache')  File "/content/co-mod-gan/dnnlib/util.py", line 383, in open_url    raise IOError("Google Drive download quota exceeded -- please try again later")OSError: Google Drive download quota exceeded -- please try again later```<jupyter_code>%cd /content/co-mod-gan/dataset_tools
!python create_from_images.py --tfrecord-dir /content/tfrecord_dir --val-image-dir /content/val --train-image-dir /content/train --resolution 512 --num-channels 3 --num-processes 4
%cd /content/co-mod-gan
# Example: /content/tfrecord_dir/tfrecord_dir-r09.tfrecords
!python run_training.py --data-dir=/content/ --dataset=tfrecord_dir --metrics=ids10k --mirror-augment True --num-gpus=1<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13776393215645552, 'fraction_numerical': 0.040844582900657664, 'mean_word_length': 5.188436830835117, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '380332', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1093, 'n_words': 209, 'path': 'Colab-co-mod-gan.ipynb', 'repo_name': 'styler00dollar/Colab-co-mod-gan', 'size': '2889'}