private static Image save_reconstruction(Network net, Image init, float[] feat, string name, int i) { Image recon; if (init != null) { recon = new Image(init); } else { recon = LoadArgs.make_random_image(net.W, net.H, 3); } Image update = new Image(net.W, net.H, 3); Nightmare.reconstruct_picture(net, feat, recon, update, .01f, .9f, .1f, 2, 50); string buff = $"{name}{i}"; LoadArgs.save_image(recon, buff); return(recon); }
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; } }