Exemple #1
0
        private static void print_cocos(FileStream fp, string imagePath, Box[] boxes, float[][] probs, int numBoxes, int classes, int w, int h)
        {
            int i, j;
            int imageId = Coco.get_coco_image_id(imagePath);

            for (i = 0; i < numBoxes; ++i)
            {
                float xmin = boxes[i].X - boxes[i].W / 2.0f;
                float xmax = boxes[i].X + boxes[i].W / 2.0f;
                float ymin = boxes[i].Y - boxes[i].H / 2.0f;
                float ymax = boxes[i].Y + boxes[i].H / 2.0f;

                if (xmin < 0)
                {
                    xmin = 0;
                }
                if (ymin < 0)
                {
                    ymin = 0;
                }
                if (xmax > w)
                {
                    xmax = w;
                }
                if (ymax > h)
                {
                    ymax = h;
                }

                float bx = xmin;
                float by = ymin;
                float bw = xmax - xmin;
                float bh = ymax - ymin;

                for (j = 0; j < classes; ++j)
                {
                    if (probs[i].Length < j)
                    {
                        var temp = Encoding.UTF8.GetBytes($"{{\"image_id\":{imageId}, \"category_id\":{Coco.CocoIds[j]}, \"bbox\":[{bx}, {@by}, {bw}, {bh}], \"score\":{probs[i][j]}}},\n");
                        fp.Write(temp, 0, temp.Length);
                    }
                }
            }
        }
Exemple #2
0
        public static void Main(string[] argsa)
        {
            var args = argsa.ToList();

            if (args.Count < 2)
            {
                Console.Error.WriteLine($"usage: {args[0]} <function>");
                return;
            }

            CudaUtils.UseGpu = CudaUtils.HaveGpu();
            if (Utils.find_arg(args.ToList(), "-nogpu"))
            {
                CudaUtils.UseGpu = false;
            }


            switch (args[1])
            {
            case "average":
                Average(args);
                break;

            case "yolo":
                Yolo.run_yolo(args);
                break;

            case "voxel":
                Voxel.run_voxel(args);
                break;

            case "super":
                Super.run_super(args);
                break;

            case "detector":
                Detector.run_detector(args);
                break;

            case "detect":
                float  thresh   = Utils.find_int_arg(args, "-thresh", .24f);
                string filename = (args.Count > 4) ? args[4] : null;
                Detector.test_detector("cfg/coco.Data", args[2], args[3], filename, thresh);
                break;

            case "cifar":
                CiFar.run_cifar(args);
                break;

            case "rnn":
                Rnn.run_char_rnn(args);
                break;

            case "vid":
                RnnVid.run_vid_rnn(args);
                break;

            case "coco":
                Coco.run_coco(args);
                break;

            case "classify":
                Classifier.predict_classifier("cfg/imagenet1k.Data", args[2], args[3], args[4], 5);
                break;

            case "classifier":
                Classifier.run_classifier(args);
                break;

            case "art":
                Art.run_art(args);
                break;

            case "tag":
                Tag.run_tag(args);
                break;

            case "compare":
                Compare.run_compare(args);
                break;

            case "writing":
                Writing.run_writing(args);
                break;

            case "3d":
                LoadArgs.composite_3d(args[2], args[3], args[4], (args.Count > 5) ? int.Parse(args[5]) : 0);
                break;

            case "test":
                LoadArgs.test_resize(args[2]);
                break;

            case "nightmare":
                Nightmare.run_nightmare(args);
                break;

            case "rgbgr":
                rgbgr_net(args[2], args[3], args[4]);
                break;

            case "reset":
                reset_normalize_net(args[2], args[3], args[4]);
                break;

            case "denormalize":
                denormalize_net(args[2], args[3], args[4]);
                break;

            case "statistics":
                statistics_net(args[2], args[3]);
                break;

            case "normalize":
                normalize_net(args[2], args[3], args[4]);
                break;

            case "rescale":
                rescale_net(args[2], args[3], args[4]);
                break;

            case "ops":
                Operations(args[2]);
                break;

            case "speed":
                Speed(args[2], (args.Count > 3 && !string.IsNullOrEmpty(args[3])) ? int.Parse(args[3]) : 0);
                break;

            case "oneoff":
                Oneoff(args[2], args[3], args[4]);
                break;

            case "partial":
                Partial(args[2], args[3], args[4], int.Parse(args[5]));
                break;

            case "visualize":
                Visualize(args[2], (args.Count > 3) ? args[3] : null);
                break;

            case "imtest":
                LoadArgs.test_resize(args[2]);
                break;

            default:
                Console.Error.WriteLine($"Not an option: {args[1]}");
                break;
            }
        }