{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# NCA Emoji Challenge Getting Started ","metadata":{}},{"cell_type":"code","source":"# ref\n# https://distill.pub/2020/growing-ca/\n\n#https://colab.research.google.com/github/google-research/self-organising-systems/blob/master/notebooks/growing_ca.ipynb\n\n#Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at\n\n#https://www.apache.org/licenses/LICENSE-2.0","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Add and Load Script ","metadata":{}},{"cell_type":"markdown","source":"The NCA Emoji Challenge Script has the NCA model and utilities to get started in the competition.  \nLoading images for emojis, training a model and more.  ","metadata":{}},{"cell_type":"code","source":"# to get script for NCA Emoji Challenge - \n# File -> Add utility script\n#   add to sys.path the ../usr/lib/<script name folder>/<script name.py>\n#   then can do import","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import sys\nSPATH = '../usr/lib/nca_emoji_challenge_script/nca_emoji_challenge_script.py'  \nsys.path.insert(1, SPATH)","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:29:51.220449Z","iopub.execute_input":"2022-07-30T10:29:51.220931Z","iopub.status.idle":"2022-07-30T10:29:51.233476Z","shell.execute_reply.started":"2022-07-30T10:29:51.220791Z","shell.execute_reply":"2022-07-30T10:29:51.232708Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from nca_emoji_challenge_script import *","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:29:55.119207Z","iopub.execute_input":"2022-07-30T10:29:55.119613Z","iopub.status.idle":"2022-07-30T10:29:57.435088Z","shell.execute_reply.started":"2022-07-30T10:29:55.119583Z","shell.execute_reply":"2022-07-30T10:29:57.433980Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"CAModel().dmodel.summary()  # model from script should appear ","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:30:08.174772Z","iopub.execute_input":"2022-07-30T10:30:08.175494Z","iopub.status.idle":"2022-07-30T10:30:08.879244Z","shell.execute_reply.started":"2022-07-30T10:30:08.175450Z","shell.execute_reply":"2022-07-30T10:30:08.878390Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport os\nimport shutil\nfrom ast import literal_eval\nimport glob\nfrom shutil import copyfile","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:30:15.734595Z","iopub.execute_input":"2022-07-30T10:30:15.735330Z","iopub.status.idle":"2022-07-30T10:30:15.740850Z","shell.execute_reply.started":"2022-07-30T10:30:15.735285Z","shell.execute_reply":"2022-07-30T10:30:15.739992Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Installs","metadata":{}},{"cell_type":"markdown","source":"Install moviepy to use for nca model regeneration videos","metadata":{}},{"cell_type":"code","source":"!pip install moviepy","metadata":{"_kg_hide-output":true,"execution":{"iopub.status.busy":"2022-07-30T10:30:35.024536Z","iopub.execute_input":"2022-07-30T10:30:35.024976Z","iopub.status.idle":"2022-07-30T10:30:46.185874Z","shell.execute_reply.started":"2022-07-30T10:30:35.024943Z","shell.execute_reply":"2022-07-30T10:30:46.184506Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"os.environ['FFMPEG_BINARY'] = 'ffmpeg'\nimport moviepy.editor as mvp\nfrom moviepy.video.io.ffmpeg_writer import FFMPEG_VideoWriter\nclear_output()","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:30:46.188572Z","iopub.execute_input":"2022-07-30T10:30:46.188976Z","iopub.status.idle":"2022-07-30T10:30:46.419301Z","shell.execute_reply.started":"2022-07-30T10:30:46.188939Z","shell.execute_reply":"2022-07-30T10:30:46.418141Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Class for video writer using moviepy FFMPEG_VideoWriter","metadata":{}},{"cell_type":"code","source":"class VideoWriter:\n  def __init__(self, filename, fps=30.0, **kw):\n    self.writer = None\n    self.params = dict(filename=filename, fps=fps, **kw)\n\n  def add(self, img):\n    img = np.asarray(img)\n    if self.writer is None:\n      h, w = img.shape[:2]\n      self.writer = FFMPEG_VideoWriter(size=(w, h), **self.params)\n    if img.dtype in [np.float32, np.float64]:\n      img = np.uint8(img.clip(0, 1)*255)\n    if len(img.shape) == 2:\n      img = np.repeat(img[..., None], 3, -1)\n    self.writer.write_frame(img)\n\n  def close(self):\n    if self.writer:\n      self.writer.close()\n\n  def __enter__(self):\n    return self\n\n  def __exit__(self, *kw):\n    self.close()","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:30:52.223970Z","iopub.execute_input":"2022-07-30T10:30:52.225109Z","iopub.status.idle":"2022-07-30T10:30:52.235418Z","shell.execute_reply.started":"2022-07-30T10:30:52.225065Z","shell.execute_reply":"2022-07-30T10:30:52.234130Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Train \nThe train csv has examples of what the competition prediction test set will be like and can be used to see how to use the other data and models. \n","metadata":{}},{"cell_type":"code","source":"df_train =  pd.read_csv('../input/nca-emoji-challenge/train.csv')  \ndf_train.head(3)","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:30:55.271830Z","iopub.execute_input":"2022-07-30T10:30:55.272637Z","iopub.status.idle":"2022-07-30T10:30:55.299708Z","shell.execute_reply.started":"2022-07-30T10:30:55.272589Z","shell.execute_reply":"2022-07-30T10:30:55.298612Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Reminder - Use ast literal_eval to get pandas cols back to lists","metadata":{}},{"cell_type":"code","source":"df_train.emojis_comp = df_train.emojis_comp.apply(lambda x: literal_eval(x) )\ndf_train.ucodes_comp = df_train.ucodes_comp.apply(lambda x: literal_eval(x) )","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:30:58.232737Z","iopub.execute_input":"2022-07-30T10:30:58.233186Z","iopub.status.idle":"2022-07-30T10:30:58.241385Z","shell.execute_reply.started":"2022-07-30T10:30:58.233151Z","shell.execute_reply":"2022-07-30T10:30:58.240364Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"There are three types of emo-ginations in this competition - rhyming slang, movie and song. Check train type unique entries that all exist and see an example for each.","metadata":{}},{"cell_type":"code","source":"df_train.type.unique()","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:31:00.897151Z","iopub.execute_input":"2022-07-30T10:31:00.897598Z","iopub.status.idle":"2022-07-30T10:31:00.904635Z","shell.execute_reply.started":"2022-07-30T10:31:00.897559Z","shell.execute_reply":"2022-07-30T10:31:00.903785Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Each emo-gination e_id has clues, a list of the emojis for the competition and a list of the ucodes corresponding to those emojis.\nFor train, the target emoji and the target nca model is provided.  For test, these need to be discovered and predicted.","metadata":{}},{"cell_type":"code","source":"display(df_train[df_train.e_id==1002])  # to display by an e_id using one from above ","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:31:04.303659Z","iopub.execute_input":"2022-07-30T10:31:04.304048Z","iopub.status.idle":"2022-07-30T10:31:04.319132Z","shell.execute_reply.started":"2022-07-30T10:31:04.304016Z","shell.execute_reply":"2022-07-30T10:31:04.318027Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train[df_train.type=='movie'].tail(1)","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:31:13.863068Z","iopub.execute_input":"2022-07-30T10:31:13.863472Z","iopub.status.idle":"2022-07-30T10:31:13.878774Z","shell.execute_reply.started":"2022-07-30T10:31:13.863436Z","shell.execute_reply":"2022-07-30T10:31:13.877901Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train[df_train.type=='song'].tail(1)","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:31:17.412944Z","iopub.execute_input":"2022-07-30T10:31:17.413352Z","iopub.status.idle":"2022-07-30T10:31:17.428871Z","shell.execute_reply.started":"2022-07-30T10:31:17.413321Z","shell.execute_reply":"2022-07-30T10:31:17.427959Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"A bit about ucodes - \nThe emoji images in the competition folder png128 have the naming convention prefix emoji_u and suffix .png \nThis is how they are stored on their source https://github.com/googlefonts/noto-emoji and would be requested if using the original code with URL for load_emoji. To make it easier to work with the emojis for competition lists, the ucodes are already given.\nBut to get the idea, this is an example:\n","metadata":{}},{"cell_type":"code","source":"display(df_train.emojis_comp[df_train.e_id==1002])  # the emojis list ","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:31:21.301783Z","iopub.execute_input":"2022-07-30T10:31:21.302636Z","iopub.status.idle":"2022-07-30T10:31:21.311106Z","shell.execute_reply.started":"2022-07-30T10:31:21.302591Z","shell.execute_reply":"2022-07-30T10:31:21.310040Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.emojis_comp[2][0] # the first emoji in the emojis list above from row 2","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:31:24.202779Z","iopub.execute_input":"2022-07-30T10:31:24.203531Z","iopub.status.idle":"2022-07-30T10:31:24.211018Z","shell.execute_reply.started":"2022-07-30T10:31:24.203479Z","shell.execute_reply":"2022-07-30T10:31:24.209992Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"e = df_train.emojis_comp[2][0]  # take the first emoji in the emojis list\nprint(get_codestring(e))   # from the script use a utility to get the codestring\ndf_train.ucodes_comp[2][0] # and this is the same as the first ucode in the ucode list  ","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:31:27.390754Z","iopub.execute_input":"2022-07-30T10:31:27.391183Z","iopub.status.idle":"2022-07-30T10:31:27.399730Z","shell.execute_reply.started":"2022-07-30T10:31:27.391149Z","shell.execute_reply":"2022-07-30T10:31:27.398471Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"For most single length emojis it will be the same as the code below. It gets the Unicode code point for a one character string using ord, takes the hex for that and then takes off the first two from hex like removes 0x. ","metadata":{}},{"cell_type":"code","source":"print(ord(e))\nprint(hex(ord(e)))\nprint(hex(ord(e))[2:].lower()  )  # for a single character string this works","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:31:31.332794Z","iopub.execute_input":"2022-07-30T10:31:31.333204Z","iopub.status.idle":"2022-07-30T10:31:31.340093Z","shell.execute_reply.started":"2022-07-30T10:31:31.333174Z","shell.execute_reply":"2022-07-30T10:31:31.338780Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"But some emoji sequences have a qualifier fe0f and some are combinations so a person + man or woman or occupation or activity.  And we will see in an example later how tone modifiers can be used as well to customise the look you want. In the script, get_codestring caters for all of these and can be used for an emoji where ucode is not given.\n\nSo to make life easier, the ucodes are provided for the emojis_comp list.  ","metadata":{}},{"cell_type":"markdown","source":"## On to Examples ","metadata":{}},{"cell_type":"code","source":"# A rhyming slang example - e_id==1002 row 2 as shown above\n\nucodes = df_train.ucodes_comp[2]\nemogination = np.hstack([load_ucodes(u) for u in ucodes])\nimshow(zoom(emogination,2))  # use zoom to get a bigger size if you like \n#imshow(emogination)  # or no zoom\nprint(df_train.clues[2] )  # print the clues if you like or not if you want to guess without them","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:31:36.392825Z","iopub.execute_input":"2022-07-30T10:31:36.393192Z","iopub.status.idle":"2022-07-30T10:31:36.421572Z","shell.execute_reply.started":"2022-07-30T10:31:36.393162Z","shell.execute_reply":"2022-07-30T10:31:36.420537Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"The red question mark is the missing emoji that the nca model will regenerate. In train these are provided. \nThe ucode for the red question mark is 2753 and is set below for use as a variable.","metadata":{}},{"cell_type":"code","source":"emjredq = '❓'\nucodesub = get_codestring(emjredq)\nprint(ucodesub)","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:31:39.813185Z","iopub.execute_input":"2022-07-30T10:31:39.813610Z","iopub.status.idle":"2022-07-30T10:31:39.819333Z","shell.execute_reply.started":"2022-07-30T10:31:39.813579Z","shell.execute_reply":"2022-07-30T10:31:39.817859Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"For this example we have the target emoji and the target nca ","metadata":{}},{"cell_type":"code","source":"df_train.target_emoji[2], df_train.target_nca[2]","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:31:42.432600Z","iopub.execute_input":"2022-07-30T10:31:42.433224Z","iopub.status.idle":"2022-07-30T10:31:42.441240Z","shell.execute_reply.started":"2022-07-30T10:31:42.433181Z","shell.execute_reply":"2022-07-30T10:31:42.440019Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# get the model weights from nca-model-wts for the target_nca and load\nnca = df_train.target_nca[2]\nmodel_wts = f'../input/nca-emoji-challenge/nca-model-wts/{nca}'\nmodel_wts  # check the path looks correct ","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:31:45.402663Z","iopub.execute_input":"2022-07-30T10:31:45.403449Z","iopub.status.idle":"2022-07-30T10:31:45.409542Z","shell.execute_reply.started":"2022-07-30T10:31:45.403410Z","shell.execute_reply":"2022-07-30T10:31:45.408788Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ca = CAModel()\nca.load_weights(model_wts)","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:31:48.294208Z","iopub.execute_input":"2022-07-30T10:31:48.294583Z","iopub.status.idle":"2022-07-30T10:31:48.490145Z","shell.execute_reply.started":"2022-07-30T10:31:48.294553Z","shell.execute_reply":"2022-07-30T10:31:48.489036Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Using the NCA model for the loaded weights, regenerate the image in a video","metadata":{}},{"cell_type":"code","source":"models = [ca]\nout_fn = 'train_steps_damage_%d.mp4'%DAMAGE_N\nx = np.zeros([len(models), 72, 72, CHANNEL_N], np.float32)\nx[..., 36, 36, 3:] = 1.0 \nwith VideoWriter(out_fn) as vid:\n  for i in tqdm.trange(500): \n    vis = np.hstack(to_rgb(x))\n    vid.add(zoom(vis, 2))\n    for ca, xk in zip(models, x):\n      xk[:] = ca(xk[None,...])[0]\nmvp.ipython_display(out_fn)","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:31:54.084490Z","iopub.execute_input":"2022-07-30T10:31:54.084906Z","iopub.status.idle":"2022-07-30T10:31:57.555132Z","shell.execute_reply.started":"2022-07-30T10:31:54.084871Z","shell.execute_reply":"2022-07-30T10:31:57.553859Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Now compare the target emoji with the regenerated image. Get the target emoji ucode and use it to replace the ucode for the red question mark in the ucode list. Then view the restored emo-gination!","metadata":{}},{"cell_type":"code","source":"etarg = df_train.target_emoji[2]  \nutarg = get_codestring(etarg)\nprint(utarg)\nucodesrev = ucodes.copy()\nucodesarr = np.array(ucodesrev)\nix = np.where(ucodesarr==ucodesub)[0]\nfor x in ix:\n    ucodesarr[x]= utarg\nucodesrev =  list(ucodesarr)   \nprint(ucodesrev)","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:32:21.598549Z","iopub.execute_input":"2022-07-30T10:32:21.599576Z","iopub.status.idle":"2022-07-30T10:32:21.609214Z","shell.execute_reply.started":"2022-07-30T10:32:21.599531Z","shell.execute_reply":"2022-07-30T10:32:21.607676Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"emogination = np.hstack([load_ucodes(u) for u in ucodesrev])\nimshow(zoom(emogination,2)) \nprint(df_train.clues[2] ) ","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:32:25.501747Z","iopub.execute_input":"2022-07-30T10:32:25.502141Z","iopub.status.idle":"2022-07-30T10:32:25.522498Z","shell.execute_reply.started":"2022-07-30T10:32:25.502109Z","shell.execute_reply":"2022-07-30T10:32:25.521253Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### So now if someone tells you to \"use your loaf\" you know it is short for the rhyming slang \"loaf of bread\".","metadata":{}},{"cell_type":"markdown","source":"## Another Example","metadata":{}},{"cell_type":"markdown","source":"The song example has more emojis and some of the different ucode combinations to get an idea of what they are like.  ","metadata":{}},{"cell_type":"code","source":"display(df_train.emojis_comp[df_train.e_id==1011])  # the emojis list for the song example above row 11","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:32:54.054584Z","iopub.execute_input":"2022-07-30T10:32:54.055766Z","iopub.status.idle":"2022-07-30T10:32:54.065417Z","shell.execute_reply.started":"2022-07-30T10:32:54.055721Z","shell.execute_reply":"2022-07-30T10:32:54.064352Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"(df_train.ucodes_comp[df_train.e_id==1011].values)","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:32:57.453980Z","iopub.execute_input":"2022-07-30T10:32:57.454404Z","iopub.status.idle":"2022-07-30T10:32:57.462278Z","shell.execute_reply.started":"2022-07-30T10:32:57.454367Z","shell.execute_reply":"2022-07-30T10:32:57.461107Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Looking at the emo-gination and the corresponding ucodes there is extra information.\nThe second zombie is showing as a man zombie with the combination _200d_ and 2642.\nThe third zombie is showing as a woman zombine with the combination _200d_ and 2640.\nThe man dancing has a tone modifier _1f3fd, as also the woman running _1f3fd and woman running combination _200d_2640.","metadata":{}},{"cell_type":"code","source":"ucodes = df_train.ucodes_comp[11]\nemogination = np.hstack([load_ucodes(u) for u in ucodes])\nimshow(zoom(emogination,2))  # use zoom to get a bigger size if you like \n#imshow(emogination)  # or no zoom\nprint(df_train.clues[11] )  # print the clues if you like or not if you want to guess without them","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:33:19.734998Z","iopub.execute_input":"2022-07-30T10:33:19.735389Z","iopub.status.idle":"2022-07-30T10:33:19.779005Z","shell.execute_reply.started":"2022-07-30T10:33:19.735359Z","shell.execute_reply":"2022-07-30T10:33:19.777998Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.target_emoji[11], df_train.target_nca[11]","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:38:00.647283Z","iopub.execute_input":"2022-07-30T10:38:00.648885Z","iopub.status.idle":"2022-07-30T10:38:00.658443Z","shell.execute_reply.started":"2022-07-30T10:38:00.648829Z","shell.execute_reply":"2022-07-30T10:38:00.657229Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Using the NCA model for the loaded weights, regenerate the image in a video","metadata":{}},{"cell_type":"code","source":"# get the model weights from nca-model-wts for the target_nca and load\nnca = df_train.target_nca[11]\nmodel_wts = f'../input/nca-emoji-challenge/nca-model-wts/{nca}'\nprint(model_wts)  # check the path looks correct \nca = CAModel()\nca.load_weights(model_wts)\nmodels = [ca]\nout_fn = 'train_steps_damage_%d.mp4'%DAMAGE_N\nx = np.zeros([len(models), 72, 72, CHANNEL_N], np.float32)\nx[..., 36, 36, 3:] = 1.0 \nwith VideoWriter(out_fn) as vid:\n  for i in tqdm.trange(500): \n    vis = np.hstack(to_rgb(x))\n    vid.add(zoom(vis, 2))\n    for ca, xk in zip(models, x):\n      xk[:] = ca(xk[None,...])[0]\nmvp.ipython_display(out_fn)","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:40:06.413634Z","iopub.execute_input":"2022-07-30T10:40:06.414115Z","iopub.status.idle":"2022-07-30T10:40:09.926928Z","shell.execute_reply.started":"2022-07-30T10:40:06.414080Z","shell.execute_reply":"2022-07-30T10:40:09.925381Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"And compare the target emoji with the regenerated image. Get the target emoji ucode and use it to replace the ucode for the red question mark in the ucode list. Then view the restored emo-gination!","metadata":{}},{"cell_type":"code","source":"etarg = df_train.target_emoji[11]  \nutarg = get_codestring(etarg)\nprint(utarg)\nucodesrev = ucodes.copy()\nucodesarr = np.array(ucodesrev)\nix = np.where(ucodesarr==ucodesub)[0]\nfor x in ix:\n    ucodesarr[x]= utarg\nucodesrev =  list(ucodesarr)   \nprint(ucodesrev)\nemogination = np.hstack([load_ucodes(u) for u in ucodesrev])\nimshow(zoom(emogination,2)) \nprint(df_train.clues[11] ) ","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:41:42.995623Z","iopub.execute_input":"2022-07-30T10:41:42.996140Z","iopub.status.idle":"2022-07-30T10:41:43.057741Z","shell.execute_reply.started":"2022-07-30T10:41:42.996102Z","shell.execute_reply":"2022-07-30T10:41:43.056520Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Will leave the rest for you.  ","metadata":{}},{"cell_type":"markdown","source":"## Option Without VideoWriter and moviepy \n\nThe script has a utility so you can show jpegs, if you prefer. ","metadata":{}},{"cell_type":"code","source":"show_model_pred(models)","metadata":{"execution":{"iopub.status.busy":"2022-07-30T10:45:44.835155Z","iopub.execute_input":"2022-07-30T10:45:44.835604Z","iopub.status.idle":"2022-07-30T10:45:47.330392Z","shell.execute_reply.started":"2022-07-30T10:45:44.835571Z","shell.execute_reply":"2022-07-30T10:45:47.329274Z"},"trusted":true},"execution_count":null,"outputs":[]}]}