Exemplo n.º 1
0
        void UpdatePix2Pix()
        {
            if (_itr == null)
            {
                ImageFilter.Preprocess(_sourceTexture, _sourceTensor);
                _itr = Generator.Apply(_sourceTensor, _weightTable, _resultTensor);
            }

            while (_spent < _budget)
            {
                if (!_itr.MoveNext())
                {
                    ImageFilter.Deprocess(_resultTensor, _resultTexture);
                    _spent += _itr.Current;

                    ImageFilter.Preprocess(_sourceTexture, _sourceTensor);
                    _itr = Generator.Apply(_sourceTensor, _weightTable, _resultTensor);
                }
                else
                {
                    _spent += _itr.Current;
                }
            }

            _spent -= _budget;

            _budget -= Mathf.Max(Time.deltaTime * 60 - 1.2f, 0) * 5;
            _budget  = Mathf.Max(150, _budget);

            _textDisplay.text = "Refresh rate: " +
                                (60 * Mathf.Min(1.0f, _budget / 1000)).ToString("0.0") +
                                " Hz (" + _levels[(int)Mathf.Min(5, _budget / 100)] + ")";
        }
Exemplo n.º 2
0
        void UpdatePix2Pix()
        {
            ImageFilter.Preprocess(_sourceTexture, _sourceTensor);
            var generated = Generator.Apply(_sourceTensor, _weightTable);

            ImageFilter.Deprocess(generated, _resultTexture);
            generated.Dispose();

            //ImageFilter.Deprocess(_sourceTensor, _resultTexture);
        }
Exemplo n.º 3
0
        void Start()
        {
            var weights = Path.Combine(Application.streamingAssetsPath, _weightFileName);

            var stopwatch = new System.Diagnostics.Stopwatch();

            stopwatch.Start();

            var result = ImageFilter.Deprocess(
                Generator.Apply(
                    ImageFilter.Preprocess(_sourceTexture),
                    WeightReader.ReadFromFile(weights)
                    )
                );

            stopwatch.Stop();
            Debug.Log("Done. Total inference time is " + stopwatch.Elapsed);

            GetComponent <MeshRenderer>().material.mainTexture = result;
        }