use ansi escape sequence vt100 ESC[H ESC[J to clear screen in a portable way (win10+ supported!) (#8834)

This commit is contained in:
Stefano Sinigardi 2023-08-27 23:49:28 +02:00 committed by GitHub
parent 538c4353ff
commit a2f20d7069
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 20 deletions

View File

@ -40,8 +40,7 @@ void demo_art(char *cfgfile, char *weightfile, int cam_index)
float *p = network_predict(net, in_s.data); float *p = network_predict(net, in_s.data);
printf("\033[2J"); printf("\033[H\033[J");
printf("\033[1;1H");
float score = 0; float score = 0;
for(i = 0; i < n; ++i){ for(i = 0; i < n; ++i){

View File

@ -1129,11 +1129,8 @@ void threat_classifier(char *datacfg, char *cfgfile, char *weightfile, int cam_i
sprintf(buff, "tmp/threat_%06d", count); sprintf(buff, "tmp/threat_%06d", count);
//save_image(out, buff); //save_image(out, buff);
#ifndef _WIN32 printf("\033[H\033[J");
printf("\033[2J"); printf("\nFPS:%.0f\n", fps);
printf("\033[1;1H");
#endif
printf("\nFPS:%.0f\n",fps);
for(i = 0; i < top; ++i){ for(i = 0; i < top; ++i){
int index = indexes[i]; int index = indexes[i];
@ -1208,8 +1205,7 @@ void gun_classifier(char *datacfg, char *cfgfile, char *weightfile, int cam_inde
float *predictions = network_predict(net, in_s.data); float *predictions = network_predict(net, in_s.data);
top_predictions(net, top, indexes); top_predictions(net, top, indexes);
printf("\033[2J"); printf("\033[H\033[J");
printf("\033[1;1H");
int threat = 0; int threat = 0;
for(i = 0; i < sizeof(bad_cats)/sizeof(bad_cats[0]); ++i){ for(i = 0; i < sizeof(bad_cats)/sizeof(bad_cats[0]); ++i){
@ -1308,11 +1304,7 @@ void demo_classifier(char *datacfg, char *cfgfile, char *weightfile, int cam_ind
if(net.hierarchy) hierarchy_predictions(predictions, net.outputs, net.hierarchy, 1); if(net.hierarchy) hierarchy_predictions(predictions, net.outputs, net.hierarchy, 1);
top_predictions(net, top, indexes); top_predictions(net, top, indexes);
#ifndef _WIN32 printf("\033[H\033[J");
printf("\033[2J");
printf("\033[1;1H");
#endif
if (!benchmark) { if (!benchmark) {
printf("\rFPS: %.2f (use -benchmark command line flag for correct measurement)\n", fps); printf("\rFPS: %.2f (use -benchmark command line flag for correct measurement)\n", fps);

View File

@ -280,8 +280,7 @@ void demo(char *cfgfile, char *weightfile, float thresh, float hier_thresh, int
if (l.embedding_size) set_track_id(local_dets, local_nboxes, demo_thresh, l.sim_thresh, l.track_ciou_norm, l.track_history_size, l.dets_for_track, l.dets_for_show); if (l.embedding_size) set_track_id(local_dets, local_nboxes, demo_thresh, l.sim_thresh, l.track_ciou_norm, l.track_history_size, l.dets_for_track, l.dets_for_show);
//printf("\033[2J"); printf("\033[H\033[J");
//printf("\033[1;1H");
//printf("\nFPS:%.1f\n", fps); //printf("\nFPS:%.1f\n", fps);
printf("Objects:\n\n"); printf("Objects:\n\n");

View File

@ -314,14 +314,13 @@ void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, i
if (mean_average_precision > 0) printf("\n Last accuracy mAP@%0.2f = %2.2f %%, best = %2.2f %% ", iou_thresh, mean_average_precision * 100, best_map * 100); if (mean_average_precision > 0) printf("\n Last accuracy mAP@%0.2f = %2.2f %%, best = %2.2f %% ", iou_thresh, mean_average_precision * 100, best_map * 100);
} }
#ifndef WIN32 printf("\033[H\033[J");
if (mean_average_precision > 0.0) { if (mean_average_precision > 0.0) {
printf("\033]2;%d/%d: loss=%0.1f map=%0.2f best=%0.2f hours left=%0.1f\007", iteration, net.max_batches, loss, mean_average_precision, best_map, avg_time); printf("%d/%d: loss=%0.1f map=%0.2f best=%0.2f hours left=%0.1f\007", iteration, net.max_batches, loss, mean_average_precision, best_map, avg_time);
} }
else { else {
printf("\033]2;%d/%d: loss=%0.1f hours left=%0.1f\007", iteration, net.max_batches, loss, avg_time); printf("%d/%d: loss=%0.1f hours left=%0.1f\007", iteration, net.max_batches, loss, avg_time);
} }
#endif
if (net.cudnn_half) { if (net.cudnn_half) {
if (iteration < net.burn_in * 3) fprintf(stderr, "\n Tensor Cores are disabled until the first %d iterations are reached.\n", 3 * net.burn_in); if (iteration < net.burn_in * 3) fprintf(stderr, "\n Tensor Cores are disabled until the first %d iterations are reached.\n", 3 * net.burn_in);