#!/usr/bin/env python # coding: utf-8 # # Working with survailance videos, captioning frames and detecting indoor/outdoor # In[29]: # This notebook is a tutorial of fastdup beta advanced capabilities. Please sign up for a free version at info@visual-layer.com to unlock those and many other functionalities. # In[13]: from IPython.display import Image # ## Download the fight detection survailance camera dataset # In[ ]: get_ipython().system('git clone https://github.com/seymanurakti/fight-detection-surv-dataset.git') # ## Install fastdup # In[1]: get_ipython().run_line_magic('pip', 'install fastdup') import fastdup # ## Extract videos into frames # In[4]: get_ipython().system('mkdir -p frames') fastdup.extract_video_frames('fight-detection-surv-dataset/fight/', 'frames/fight') fastdup.extract_video_frames('fight-detection-surv-dataset/noFight/', 'frames/no-fight') # ## Quick preview of video frames # In[8]: fight_files=get_ipython().getoutput("find frames/fight/ -name '*.jpg'") no_fight_files=get_ipython().getoutput("find frames/no-fight/ -name '*.jpg'") # In[9]: ret = fastdup.generate_sprite_image(fight_files, 55, ".")[0] from IPython.display import Image Image(filename=ret) # In[12]: ret = fastdup.generate_sprite_image(no_fight_files, 55, ".")[0] Image(filename=ret) # ## Build fastdup model # In[3]: # Cluster similar frames together fd = fastdup.create(input_dir='frames', work_dir='out_frames') fd.run(overwrite=True, model_path='dinov2s') # In[10]: fd.vis.component_gallery(num_images=10) # ## Look at video outliers, and caption them automatically # In[6]: fd.vis.outliers_gallery(num_images=10, label_col='blip') # In[25]: # In the above reports the captions are given under the "label" field name # ## Look at image outliers, and classify them into indoors/outdoors # In[10]: fd.vis.outliers_gallery(num_images=10, label_col='indoors_outdoors') # In[28]: # As can be seen the indoors/outdoors classifier is 90% correct on the above example # In[ ]: