import pip print(pip.main(['list'])) from video_generation import VideoGenerator import gradio as gr import shutil import os from argparse import Namespace import subprocess os.environ['KMP_DUPLICATE_LIB_OK']='True' subprocess.call("apt-get install ffmpeg".split()) def func(resize, video): # return video if os.path.exists('/tmp/outputs'): shutil.rmtree('/tmp/outputs') os.makedirs('/tmp/outputs/') args = Namespace( arch="vit_small", patch_size=8, pretrained_weights="dino_deitsmall8_pretrain.pth", checkpoint_key="teacher", input_path=video, output_path="/tmp/outputs/", threshold=0.6, resize=resize, video_only=False, fps=30.0, video_format="mp4" ) vid_generator = VideoGenerator(args) vid_generator.run() # Make a video that puts the resized input video + the attn output video together as one ffmpeg_cmd = """ ffmpeg -i /tmp/outputs/original-reshaped.mp4 -i /tmp/outputs/video.mp4 -filter_complex hstack /tmp/outputs/stacked.mp4 """ subprocess.call(ffmpeg_cmd.split()) return '/tmp/outputs/stacked.mp4' title = "Interactive demo: DINO" description = "Demo for Facebook AI's DINO, a new method for self-supervised training of Vision Transformers. Using this method, they are capable of segmenting objects within an image without having ever been trained to do so. This can be observed by displaying the self-attention of the heads from the last layer for the [CLS] token query. This demo uses a ViT-S/8 trained with DINO. To use it, simply upload an image or use the example image below. Results will show up in a few seconds." article = "
Emerging Properties in Self-Supervised Vision Transformers | Github Repo
" iface = gr.Interface(fn=func, inputs=[gr.inputs.Slider(120, 480, 20, label="resize"), gr.inputs.Video(type=None)], outputs="video", title=title, description=description, article=article) iface.launch(debug=True)