<jupyter_start><jupyter_text>Import model<jupyter_code>%load_ext autoreload
%autoreload 2
import tensorflow as tf
model_saved = tf.keras.models.load_model("models/fcn4_weights/")<jupyter_output><empty_output><jupyter_text>Run model on an image<jupyter_code>from utils.eval import *
pltPredOnImg(model_saved, "imgs/test_img.jpg",
             save_path="../data/results.png", classes = {2: "person"},
             legend_size=0.8, legend_xpos=250, legend_ypos=50, input_shape=(300, 300))<jupyter_output>(1, 300, 300, 3)
Calculated legend: size 33, (x, y) pos (200.4, 50)
New legend: size 20.8, (x, y) pos (250, 50)<jupyter_text>Run model on a video<jupyter_code>video_path = "../data/video/person_dog.mp4"
out_path = "../data/video/"
pltPredOnVideo(model_saved, video_path, out_path + "person_dog_fcn4_segmentation.gif",
               start_idx=60, end_idx=210, skip=2, legend_size=1.2,
               resize=(500,200), fps=22, input_shape=(300,300), classes = {1: "dog", 2: "person"})
video_path = "../data/video/dog_black.mp4"
out_path = "../data/video/"
pltPredOnVideo(model_saved, video_path, out_path + "dog_black_segmentation_fcn4.gif",
               start_idx=50, end_idx=270, skip=2, legend_size=1.6, legend_xpos=20,
               resize=(500,200), fps=22, input_shape=(300,300), classes = {1: "dog", 2: "person"})
video_path = "../data/video/dog.mp4"
out_path = "../data/video/"
pltPredOnVideo(model_saved, video_path, out_path + "dog_unet_segmentation_fcn4.gif",
               start_idx=0, end_idx=270, skip=2, legend_size=1.6, legend_xpos=20,
               resize=(500,200), fps=22, input_shape=(300,300), classes = {1: "dog"})
video_path = "../data/video/person_then_dog.mp4"
out_path = "../data/video/"
pltPredOnVideo(model_saved, video_path, out_path + "person_then_dog_segmentation_fcn4.gif",
               start_idx=15, end_idx=230, skip=2, legend_size=1.6, legend_xpos=20,
               resize=(500,200), fps=22, input_shape=(300,300), classes = {1: "dog", 2: "person"})<jupyter_output>7%|█████▋                                                                           | 16/230 [00:00<00:03, 54.38it/s]
{'fraction_non_alphanumeric': 0.16086547507055504, 'fraction_numerical': 0.07808090310442145, 'mean_word_length': 3.7583892617449663, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 11, 'https://': 0, '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': '286753', 'license': 'MIT', 'n_tokens_mistral': 896, 'n_tokens_neox': 786, 'n_words': 136, 'path': 'infer_on_videos.ipynb', 'repo_name': 'Apiquet/Segmentation', 'size': '2126'}