yourusername commited on
Commit
c339cc7
1 Parent(s): 4161fb7

:construction: wip

Browse files
Files changed (1) hide show
  1. dino/app.py +8 -8
dino/app.py CHANGED
@@ -14,10 +14,10 @@ os.environ['KMP_DUPLICATE_LIB_OK']='True'
14
 
15
  def func(resize, video):
16
  # return video
17
- if os.path.exists('./outputs'):
18
- shutil.rmtree('./outputs')
19
 
20
- os.makedirs('./outputs/')
21
 
22
  args = Namespace(
23
  arch="vit_small",
@@ -25,7 +25,7 @@ def func(resize, video):
25
  pretrained_weights="dino_deitsmall8_pretrain.pth",
26
  checkpoint_key="teacher",
27
  input_path=video,
28
- output_path="./outputs/",
29
  threshold=0.6,
30
  resize=resize,
31
  video_only=False,
@@ -39,13 +39,13 @@ def func(resize, video):
39
  # Make a video that puts the resized input video + the attn output video together as one
40
  ffmpeg_cmd = """
41
  ffmpeg
42
- -i ./outputs/original-reshaped.mp4
43
- -i ./outputs/video.mp4
44
  -filter_complex hstack
45
- ./outputs/stacked.mp4
46
  """
47
  subprocess.call(ffmpeg_cmd.split())
48
- return './outputs/stacked.mp4'
49
 
50
  title = "Interactive demo: DINO"
51
  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."
 
14
 
15
  def func(resize, video):
16
  # return video
17
+ if os.path.exists('/tmp/outputs'):
18
+ shutil.rmtree('/tmp/outputs')
19
 
20
+ os.makedirs('/tmp/outputs/')
21
 
22
  args = Namespace(
23
  arch="vit_small",
 
25
  pretrained_weights="dino_deitsmall8_pretrain.pth",
26
  checkpoint_key="teacher",
27
  input_path=video,
28
+ output_path="/tmp/outputs/",
29
  threshold=0.6,
30
  resize=resize,
31
  video_only=False,
 
39
  # Make a video that puts the resized input video + the attn output video together as one
40
  ffmpeg_cmd = """
41
  ffmpeg
42
+ -i /tmp/outputs/original-reshaped.mp4
43
+ -i /tmp/outputs/video.mp4
44
  -filter_complex hstack
45
+ /tmp/outputs/stacked.mp4
46
  """
47
  subprocess.call(ffmpeg_cmd.split())
48
+ return '/tmp/outputs/stacked.mp4'
49
 
50
  title = "Interactive demo: DINO"
51
  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."