public async Task TestStylize() { StylizeGraph stylizeGraph = new StylizeGraph(); await stylizeGraph.Init(); Tensor image = ImageIO.ReadTensorFromImageFile <float>("surfers.jpg"); Tensor stylizedImage = stylizeGraph.Stylize(image, 0); }
public override void OnButtonClicked(Object sender, EventArgs args) { base.OnButtonClicked(sender, args); if (_buttonMode == ButtonMode.WaitingModelDownload) { _stylizeGraph.Init(); } else { LoadImages(new string[] { "surfers.jpg" }); } }
partial void stylizeClicked(NSObject sender) { SetMessage("Please wait while we download Stylize model from internet..."); SetImage(null); if (_stylizeGraph == null) { _stylizeGraph = new StylizeGraph(); _stylizeGraph.OnDownloadProgressChanged += OnDownloadProgressChanged; _stylizeGraph.OnDownloadCompleted += stylizeGraph_OnDownloadCompleted; } _stylizeGraph.Init(); }
async void stylizeClicked(NSObject sender) { SetMessage("Please wait while we download Stylize model from internet..."); SetImage(null); if (_stylizeGraph == null) { _stylizeGraph = new StylizeGraph(); _stylizeGraph.OnDownloadProgressChanged += OnDownloadProgressChanged; //_stylizeGraph.OnDownloadCompleted += stylizeGraph_OnDownloadCompleted; } await _stylizeGraph.Init(); SetMessage(""); byte[] jpeg = _stylizeGraph.StylizeToJpeg("surfers.jpg", 0); using (System.IO.Stream s = new System.IO.MemoryStream(jpeg)) { NSImage newImg = NSImage.FromStream(s); SetImage(newImg); } }