Medha Sawhney commited on
Commit
c429c7f
1 Parent(s): 1b4ea90

Adding option for FPS/Min Tarck Length

Browse files
Files changed (2) hide show
  1. .gitignore +3 -2
  2. app.py +20 -9
.gitignore CHANGED
@@ -1,5 +1,5 @@
1
  *.ipynb
2
- ipynb_checkpoints/
3
  *.mp4
4
  *.avi
5
  flagged/
@@ -10,4 +10,5 @@ data/
10
  raw_data/
11
  DataFeatures/
12
  app_trial.py
13
- models*
 
 
1
  *.ipynb
2
+ *ipynb_checkpoints/
3
  *.mp4
4
  *.avi
5
  flagged/
 
10
  raw_data/
11
  DataFeatures/
12
  app_trial.py
13
+ models/
14
+ *__pycache__/
app.py CHANGED
@@ -81,7 +81,7 @@ def download_and_unzip_google_drive_file(file_id, output_path, unzip_path):
81
 
82
 
83
  # @spaces.GPU()
84
- def doo(video, progress=gr.Progress()):
85
  # download and unzip models
86
  # file_id = '1agsLD5HV_VmDNpDhjHXTCAVmGUm2IQ6p'
87
  # output_path = 'models.zip'
@@ -98,6 +98,7 @@ def doo(video, progress=gr.Progress()):
98
  test_video_list = ["video1"] # list of videos to generate features for
99
  exp_name = "collagen_motility_inference" # name of experiment
100
  feature_data_path = os.path.join(feature_dir, exp_name)
 
101
 
102
 
103
  #path to saved models
@@ -158,9 +159,9 @@ def doo(video, progress=gr.Progress()):
158
  progress(1 / 3, desc=f"Tracking {1}/{3}")
159
  track_bacteria(video_num=video_num, max_age=35, max_interpolation=35, data_path=feature_data_path)
160
  progress(2 / 3, desc=f"Tracking {2}/{3}")
161
- folder_path = analyse_tracking(video_num=video_num, data_feature_path=feature_data_path, data_root_path=final_data_dir, plot=True)
162
  progress(3 / 3, desc=f"Tracking {3}/{3}")
163
- output_video = gen_tracking_video(video_num=video_num, fps=60, data_path=feature_data_path)
164
  final_video = os.path.basename(output_video)
165
  shutil.copy(output_video, final_video)
166
  print(output_video)
@@ -178,13 +179,23 @@ examples = [['RBS_2_4_h264.mp4'], ['RBS_4_4_h264.mp4']]# ['RBS_7_6_h264.mp4']]
178
  title = "🎞️ MEMTrack Bacteria Tracking Video Tool"
179
  description = "Upload a video or selct from example to track. <br><br> If the input video does not play on browser, ensure its in a browser accetable format. Output will be generated iirespective of playback on browser. Refer: https://colab.research.google.com/drive/1U5pX_9iaR_T8knVV7o4ftKdDoGndCdEM?usp=sharing"
180
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  iface = gr.Interface(
182
  fn=doo,
183
- inputs=gr.Video(label="Input Video"),
184
- outputs=[
185
- gr.Video(label="Tracked Video"),
186
- gr.Files(label="CSV Data")
187
- ],
188
  examples=examples,
189
  title=title,
190
  description=description,
@@ -193,4 +204,4 @@ iface = gr.Interface(
193
 
194
 
195
  if __name__ == "__main__":
196
- iface.launch()
 
81
 
82
 
83
  # @spaces.GPU()
84
+ def doo(video, fps, min_track_length, progress=gr.Progress()):
85
  # download and unzip models
86
  # file_id = '1agsLD5HV_VmDNpDhjHXTCAVmGUm2IQ6p'
87
  # output_path = 'models.zip'
 
98
  test_video_list = ["video1"] # list of videos to generate features for
99
  exp_name = "collagen_motility_inference" # name of experiment
100
  feature_data_path = os.path.join(feature_dir, exp_name)
101
+ min_track_length = min_track_length
102
 
103
 
104
  #path to saved models
 
159
  progress(1 / 3, desc=f"Tracking {1}/{3}")
160
  track_bacteria(video_num=video_num, max_age=35, max_interpolation=35, data_path=feature_data_path)
161
  progress(2 / 3, desc=f"Tracking {2}/{3}")
162
+ folder_path = analyse_tracking(video_num=video_num, min_track_length=min_track_length, data_feature_path=feature_data_path, data_root_path=final_data_dir, plot=True)
163
  progress(3 / 3, desc=f"Tracking {3}/{3}")
164
+ output_video = gen_tracking_video(video_num=video_num, fps=fps, data_path=feature_data_path)
165
  final_video = os.path.basename(output_video)
166
  shutil.copy(output_video, final_video)
167
  print(output_video)
 
179
  title = "🎞️ MEMTrack Bacteria Tracking Video Tool"
180
  description = "Upload a video or selct from example to track. <br><br> If the input video does not play on browser, ensure its in a browser accetable format. Output will be generated iirespective of playback on browser. Refer: https://colab.research.google.com/drive/1U5pX_9iaR_T8knVV7o4ftKdDoGndCdEM?usp=sharing"
181
 
182
+
183
+ inputs = [
184
+ gr.Video(label="Input Video"),
185
+ gr.Slider(minimum=1, maximum=100, step=1, default=60, label="FPS", choices=[10, 20, 30, 60]),
186
+ gr.Slider(minimum=1, maximum=1000, step=1, default=60, label="Minimum Track Length Threshold", choices=[5, 10, 20, 50, 100])
187
+ ]
188
+
189
+ outputs = [
190
+ gr.Video(label="Tracked Video"),
191
+ gr.Files(label="CSV Data")
192
+ ]
193
+
194
+
195
  iface = gr.Interface(
196
  fn=doo,
197
+ inputs=inputs,
198
+ outputs=outputs,
 
 
 
199
  examples=examples,
200
  title=title,
201
  description=description,
 
204
 
205
 
206
  if __name__ == "__main__":
207
+ iface.launch(share=True)