Exemple #1
0
 ///<summary>Инициализирует главную форму приложения и нейросети.</summary>
 public MainForm() : base()
 {
     this.InitializeComponent();
     this.Closing += this.CloseWindowHandler;
     // Encoders
     this.encoder = new Encoder(Assembly.GetExecutingAssembly().GetManifestResourceStream("vgg_normalised.model"));
     // Decoders
     this.decoder = new Decoder(Assembly.GetExecutingAssembly().GetManifestResourceStream("decoder.model"));
     // SANet
     this.SANet = new SANet(Assembly.GetExecutingAssembly().GetManifestResourceStream("SANet.model"));
     StyleTransfer.OnStepDone        += this.ChangeProgressValue;
     this.Stylized                    = false;
     this.OpenContent.Click          += this.OpenContentHandler;
     this.OpenStyle.Click            += this.OpenStyleHandler;
     this.GenerateOrSaveResult.Click += this.StartProcess;
 }
        public static Tensor Stylize(Encoder Encoder,
                                     Decoder Decoder,
                                     SANet SANet,
                                     Tensor Content,
                                     Tensor Style)
        {
            Encoder.Step += FixStep;
            Decoder.Step += FixStep;
            SANet.Step   += FixStep;
            TotalSteps    = 0f;
            LastPercent   = 0;
            var C      = Encoder.Encode(Content);
            var S      = Encoder.Encode(Style);
            var CS     = SANet.Stylize(C.Item1, S.Item1, C.Item2, S.Item2);
            var Result = Decoder.Decode(CS);

            // Uninstall
            Encoder.Step -= FixStep;
            Decoder.Step -= FixStep;
            SANet.Step   -= FixStep;
            return(Result);
        }