Ivan Felipe Rodriguez commited on
Commit
d977e82
·
1 Parent(s): 103a92c

updating to checkpoint v2

Browse files
Files changed (2) hide show
  1. app.py +8 -7
  2. inference.py +25 -21
app.py CHANGED
@@ -195,7 +195,7 @@ with gr.Blocks(title='Shark Patrol',theme=gr.themes.Soft(),live=True,) as demo:
195
  with gr.Row():
196
  video_example = gr.Video(source='upload',include_audio=False,stream=True)
197
  with gr.Row():
198
- paths = sorted(pathlib.Path('videos_example/').rglob('*rgb.mp4'))
199
  example_preds = gr.Dataset(components=[video_example],
200
  samples=[[path.as_posix()]
201
  for path in paths])
@@ -212,16 +212,17 @@ with gr.Blocks(title='Shark Patrol',theme=gr.themes.Soft(),live=True,) as demo:
212
 
213
  video_button = gr.Button("Analyze your Video")
214
  with gr.Row():
215
- paths = sorted(pathlib.Path('videos_example/').rglob('*.mp4'))
 
216
  example_images = gr.Dataset(components=[video_input],
217
  samples=[[path.as_posix()]
218
- for path in paths if 'raw_videos' not in str(path)])
219
-
220
- video_button.click(analyze_video_parallel, inputs=video_input, outputs=video_output)
221
-
222
- example_images.click(fn=set_example_image,
223
  inputs=example_images,
224
  outputs=video_input)
 
 
 
225
 
226
  demo.queue()
227
  #if os.getenv('SYSTEM') == 'spaces':
 
195
  with gr.Row():
196
  video_example = gr.Video(source='upload',include_audio=False,stream=True)
197
  with gr.Row():
198
+ paths = sorted(pathlib.Path('videos_example/').rglob('*rgb.mp4'))[:8]
199
  example_preds = gr.Dataset(components=[video_example],
200
  samples=[[path.as_posix()]
201
  for path in paths])
 
212
 
213
  video_button = gr.Button("Analyze your Video")
214
  with gr.Row():
215
+ paths = sorted(pathlib.Path('videos_example/raw_videos/').rglob('*.mp4'))
216
+ print(paths)
217
  example_images = gr.Dataset(components=[video_input],
218
  samples=[[path.as_posix()]
219
+ for path in paths])
220
+ example_images.click(fn=set_example_image,
 
 
 
221
  inputs=example_images,
222
  outputs=video_input)
223
+ video_button.click(analyze_video_parallel, inputs=video_input, outputs=video_output)
224
+
225
+
226
 
227
  demo.queue()
228
  #if os.getenv('SYSTEM') == 'spaces':
inference.py CHANGED
@@ -19,22 +19,22 @@ import concurrent.futures
19
  import threading
20
 
21
 
22
- classes= ['Beach',
 
23
  'Sea',
24
  'Wave',
25
  'Rock',
26
  'Breaking wave',
27
  'Reflection of the sea',
28
  'Foam',
29
- 'Algae',
30
- 'Vegetation',
31
  'Watermark',
32
  'Bird',
33
- 'Ship',
34
- 'Boat',
35
- 'Car',
36
  'Kayak',
37
- "Shark's line",
38
  'Dock',
39
  'Dog',
40
  'Unidentifiable shade',
@@ -44,33 +44,37 @@ classes= ['Beach',
44
  'Surfer shadow',
45
  'Shark shadow',
46
  'Surfboard shadow',
 
47
  'Crocodile',
48
  'Sea cow',
49
  'Stingray',
50
  'Person',
51
- 'ocean',
52
- 'Surfer',
53
  'Surfer',
 
54
  'Fish',
55
  'Killer whale',
56
  'Whale',
57
  'Dolphin',
58
  'Miscellaneous',
59
- 'Unidentifiable shark',
 
60
  'Carpet shark',
61
  'Dusty shark',
62
  'Blue shark',
63
  'Great white shark',
64
- 'Copper shark',
65
- 'Nurse shark',
66
- 'Silky shark',
67
- 'Leopard shark',
68
- 'Shortfin mako shark',
69
- 'Hammerhead shark',
70
- 'Oceanic whitetip shark',
71
- 'Blacktip shark',
72
- 'Tiger shark',
73
- 'Bull shark']*3
 
 
74
 
75
 
76
 
@@ -89,7 +93,7 @@ snapshot_download(repo_id=REPO_ID, token= os.environ.get('SHARK_MODEL'),local_di
89
  config_file ='model/mask2former_swin-t-p4-w7-224_8xb2-lsj-50e_coco-panoptic/mask2former_swin-t-p4-w7-224_8xb2-lsj-50e_coco-panoptic.py'
90
  #'/content/mmdetection/configs/panoptic_fpn/panoptic-fpn_r50_fpn_ms-3x_coco.py'
91
  # Setup a checkpoint file to load
92
- checkpoint_file ='model/mask2former_swin-t-p4-w7-224_8xb2-lsj-50e_coco-panoptic/checkpoint.pth'
93
  # '/content/drive/MyDrive/Algorithms/weights/shark_panoptic_weights_16_4_23/panoptic-fpn_r50_fpn_ms-3x_coco/epoch_36.pth'
94
 
95
  # register all modules in mmdet into the registries
 
19
  import threading
20
 
21
 
22
+
23
+ classes= [ 'Beach',
24
  'Sea',
25
  'Wave',
26
  'Rock',
27
  'Breaking wave',
28
  'Reflection of the sea',
29
  'Foam',
30
+ 'Algae',
31
+ 'Vegetation',
32
  'Watermark',
33
  'Bird',
34
+ 'Ship',
35
+ 'Boat',
36
+ 'Car',
37
  'Kayak',
 
38
  'Dock',
39
  'Dog',
40
  'Unidentifiable shade',
 
44
  'Surfer shadow',
45
  'Shark shadow',
46
  'Surfboard shadow',
47
+ 'Turtle',
48
  'Crocodile',
49
  'Sea cow',
50
  'Stingray',
51
  'Person',
52
+ 'Surf table',
 
53
  'Surfer',
54
+ 'Seal',
55
  'Fish',
56
  'Killer whale',
57
  'Whale',
58
  'Dolphin',
59
  'Miscellaneous',
60
+ "Shark's line",
61
+ 'Unidentifiable shark',
62
  'Carpet shark',
63
  'Dusty shark',
64
  'Blue shark',
65
  'Great white shark',
66
+ 'Copper shark',
67
+ 'Nurse shark',
68
+ 'Silky shark',
69
+ 'Leopard shark',
70
+ 'Shortfin mako shark',
71
+ 'Hammerhead shark',
72
+ 'Oceanic whitetip shark',
73
+ 'Blacktip shark',
74
+ 'Tiger shark',
75
+ 'Bull shark']
76
+
77
+ classes +=['None']*50
78
 
79
 
80
 
 
93
  config_file ='model/mask2former_swin-t-p4-w7-224_8xb2-lsj-50e_coco-panoptic/mask2former_swin-t-p4-w7-224_8xb2-lsj-50e_coco-panoptic.py'
94
  #'/content/mmdetection/configs/panoptic_fpn/panoptic-fpn_r50_fpn_ms-3x_coco.py'
95
  # Setup a checkpoint file to load
96
+ checkpoint_file ='model/mask2former_swin-t-p4-w7-224_8xb2-lsj-50e_coco-panoptic/checkpoint_v2.pth'
97
  # '/content/drive/MyDrive/Algorithms/weights/shark_panoptic_weights_16_4_23/panoptic-fpn_r50_fpn_ms-3x_coco/epoch_36.pth'
98
 
99
  # register all modules in mmdet into the registries