Spaces:
Build error
Build error
Commit
·
c704b34
1
Parent(s):
7a65463
update api of write and generate video, fix dependencies
Browse files- app.py +13 -7
- requirements.txt +2 -2
app.py
CHANGED
|
@@ -151,8 +151,6 @@ def track(args):
|
|
| 151 |
|
| 152 |
input_shape = reader.input_shape
|
| 153 |
output_shape = reader.output_shape
|
| 154 |
-
ratio_y = input_shape[0] / (output_shape[0] // args.downsampling_factor)
|
| 155 |
-
ratio_x = input_shape[1] / (output_shape[1] // args.downsampling_factor)
|
| 156 |
|
| 157 |
detections = []
|
| 158 |
logger.info('---Detecting...')
|
|
@@ -173,7 +171,12 @@ def track(args):
|
|
| 173 |
# store unfiltered results
|
| 174 |
datestr = datetime.datetime.now().strftime('%Y%m%d%H%M%S%f')
|
| 175 |
output_filename = op.splitext(args.video_path)[0] + "_" + datestr + '_unfiltered.txt'
|
| 176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
logger.info('---Filtering...')
|
| 178 |
|
| 179 |
# read from the file
|
|
@@ -181,7 +184,11 @@ def track(args):
|
|
| 181 |
filtered_results = filter_tracks(results, config_track.kappa, config_track.tau)
|
| 182 |
# store filtered results
|
| 183 |
output_filename = op.splitext(args.video_path)[0] + "_" + datestr + '_filtered.txt'
|
| 184 |
-
write_tracking_results_to_file(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
|
| 186 |
return filtered_results
|
| 187 |
|
|
@@ -222,9 +229,8 @@ def run_model(video_path, model_type, seconds, skip, tau, kappa, gps_file):
|
|
| 222 |
|
| 223 |
# Generate new video
|
| 224 |
generate_video_with_annotations(reader, output_json, output_path,
|
| 225 |
-
config_track.skip_frames, config_track.
|
| 226 |
-
|
| 227 |
-
labels2icons=labels2icons)
|
| 228 |
output_label = count_objects(output_json, id_categories)
|
| 229 |
|
| 230 |
|
|
|
|
| 151 |
|
| 152 |
input_shape = reader.input_shape
|
| 153 |
output_shape = reader.output_shape
|
|
|
|
|
|
|
| 154 |
|
| 155 |
detections = []
|
| 156 |
logger.info('---Detecting...')
|
|
|
|
| 171 |
# store unfiltered results
|
| 172 |
datestr = datetime.datetime.now().strftime('%Y%m%d%H%M%S%f')
|
| 173 |
output_filename = op.splitext(args.video_path)[0] + "_" + datestr + '_unfiltered.txt'
|
| 174 |
+
coord_mapping = reader.get_inv_mapping(args.downsampling_factor)
|
| 175 |
+
write_tracking_results_to_file(
|
| 176 |
+
results,
|
| 177 |
+
coord_mapping, # Scale the output back to original video size
|
| 178 |
+
output_filename=output_filename,
|
| 179 |
+
)
|
| 180 |
logger.info('---Filtering...')
|
| 181 |
|
| 182 |
# read from the file
|
|
|
|
| 184 |
filtered_results = filter_tracks(results, config_track.kappa, config_track.tau)
|
| 185 |
# store filtered results
|
| 186 |
output_filename = op.splitext(args.video_path)[0] + "_" + datestr + '_filtered.txt'
|
| 187 |
+
write_tracking_results_to_file(
|
| 188 |
+
filtered_results,
|
| 189 |
+
lambda x, y: (x, y), # No scaling, already scaled!
|
| 190 |
+
output_filename=output_filename,
|
| 191 |
+
)
|
| 192 |
|
| 193 |
return filtered_results
|
| 194 |
|
|
|
|
| 229 |
|
| 230 |
# Generate new video
|
| 231 |
generate_video_with_annotations(reader, output_json, output_path,
|
| 232 |
+
config_track.skip_frames, config_track.downscale_output,
|
| 233 |
+
logger, gps_data=gps_data, labels2icons=labels2icons)
|
|
|
|
| 234 |
output_label = count_objects(output_json, id_categories)
|
| 235 |
|
| 236 |
|
requirements.txt
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
-
plastic-origins==1.
|
| 2 |
-
yolov5
|
| 3 |
gradio>3.0.20
|
| 4 |
osmnx
|
| 5 |
folium
|
|
|
|
| 1 |
+
plastic-origins==2.1.0
|
| 2 |
+
yolov5
|
| 3 |
gradio>3.0.20
|
| 4 |
osmnx
|
| 5 |
folium
|