<jupyter_start><jupyter_text>Table of contents Installation Training your own classifier  Installation - Run these commands          - git clone https://github.com/Tessellate-Imaging/Monk_Object_Detection.git          - cd Monk_Object_Detection/18_mmaction/installation      - Select the right file and run      - chmod +x install.sh && ./install.sh<jupyter_code>! git clone https://github.com/Tessellate-Imaging/Monk_Object_Detection.git
! cd Monk_Object_Detection/18_mmaction/installation && chmod +x install.sh && ./install.sh<jupyter_output><empty_output><jupyter_text>Download and reformat Dataset  - Dataset Credits: http://web.eecs.umich.edu/~jjcorso/r/a2d/<jupyter_code>! wget http://web.eecs.umich.edu/~jjcorso/bigshare/A2D_main_1_0.tar.bz
! bzip2 -d A2D_main_1_0.tar.bz
! tar -xf A2D_main_1_0.tar
# copy the following lines to classes.txt

Background
adult-climbing
adult-crawling
adult-eating
adult-flying
adult-jumping
adult-rolling
adult-running
adult-walking
adult-none
baby-climbing
baby-crawling
baby-eating
baby-flying
baby-jumping
baby-rolling
baby-running
baby-walking
baby-none
ball-climbing
ball-crawling
ball-eating
ball-flying
ball-jumping
ball-rolling
ball-running
ball-walking
ball-none
bird-climbing
bird-crawling
bird-eating
bird-flying
bird-jumping
bird-rolling
bird-running
bird-walking
bird-none
car-climbing
car-crawling
car-eating
car-flying
car-jumping
car-rolling
car-running
car-walking
car-none
cat-climbing
cat-crawling
cat-eating
cat-flying
cat-jumping
cat-rolling
cat-running
cat-walking
cat-none
dog-climbing
dog-crawling
dog-eating
dog-flying
dog-jumping
dog-rolling
dog-running
dog-walking
dog-none
# changing ID numbers, making them continuous for training
! mkdir videos
import os
import pandas as pd
import numpy as np

f = open("Release/videoset.csv");
lines = f.readlines();
f.close()

combined = [];
from tqdm import tqdm

for i in tqdm(range(len(lines))):
    tmp = lines[i].split(",");
    in_vid = "Release/clips320H/" + tmp[0] + ".mp4";
    class_id = int(tmp[1])-10;
    st = tmp[2];
    et = tmp[3];
    out_vid = "videos/" + str(i) + ".mp4"
    
    cmd = "ffmpeg -ss " + st + " -i " + in_vid + " -to " + et + " -c copy " + out_vid
    
    os.system(cmd)
    
    wr = out_vid + " " + str(class_id);
    combined.append(wr)
    
    #print(cmd)
    #print(in_vid, os.path.isfile(in_vid))
    #break;
import random
random.shuffle(combined)
train_list = combined[:int(len(combined)*0.8)];
val_list = combined[int(len(combined)*0.8):];
f = open("train.txt", 'w')
for i in range(len(train_list)):
    f.write(train_list[i] + "\n");
f.close();
f = open("val.txt", 'w')
for i in range(len(val_list)):
    f.write(val_list[i] + "\n");
f.close();<jupyter_output><empty_output><jupyter_text>Train your own network<jupyter_code>import os
import sys
sys.path.append("Monk_Object_Detection/18_mmaction/lib");
from train_engine import Detector_Videos
gtf = Detector_Videos();
video_dir = './';
anno_file = 'train.txt';
classes_list_file = 'classes.txt';

gtf.Train_Video_Dataset(video_dir, 
                          anno_file, 
                          classes_list_file);
video_dir = './';
anno_file = 'val.txt';

gtf.Val_Video_Dataset(video_dir, 
                          anno_file);
gtf.Dataset_Params(batch_size=4, num_workers=4)
gtf.List_Models();
gtf.Model_Params(model_name="tsm_r50", gpu_devices=[0])
gtf.Hyper_Params(lr=0.002, momentum=0.9, weight_decay=0.0001)
gtf.Training_Params(num_epochs=100, val_interval=10)
gtf.Train();<jupyter_output><empty_output><jupyter_text>Inference on trained network<jupyter_code>import os
import sys
sys.path.append("Monk_Object_Detection/18_mmaction/lib");
from infer_engine import Infer_Videos
gtf = Infer_Videos();
gtf.Dataset_Params('classes.txt');
config_file = "work_dirs/config.py"
checkpoint_file = "work_dirs/latest.pth"

gtf.Model_Params(config_file, checkpoint_file, use_gpu=True)
import os
vid_list = os.listdir("videos")
video_path = "videos/" + vid_list[0]
results = gtf.Predict(video_path)
from IPython.display import Video
Video(video_path)
video_path = "videos/" + vid_list[1]
results = gtf.Predict(video_path)
from IPython.display import Video
Video(video_path)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12958551691281564, 'fraction_numerical': 0.013577894235350167, 'mean_word_length': 4.525, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '631579', 'license': 'Apache-2.0', 'n_tokens_mistral': 1665, 'n_tokens_neox': 1608, 'n_words': 299, 'path': 'application_model_zoo/Example - A2D Action Recognition Dataset.ipynb', 'repo_name': 'Boltuzamaki/Monk_Object_Detection', 'size': '4198'}