private void btnCancel_Click(object sender, RoutedEventArgs e) { if (CancelEvent != null) { CancelEvent.Invoke(); } }
/// <summary> /// The constructor. /// </summary> /// <param name="param">Specifies the creation parameters.</param> /// <param name="log">Specifies the output log.</param> /// <param name="evtCancel">Specfies the cancel event used to cancel the process.</param> public VOCDataLoader(VOCDataParameters param, Log log, CancelEvent evtCancel) { m_param = param; m_log = log; m_evtCancel = evtCancel; m_evtCancel.Reset(); }
protected override async Task DoAction() { Label = DownloadingLabel; try { if (CancelEvent.WaitOne(0)) { return; } Downloader downloader = new Downloader(CancelEvent); downloader.DownloadProgress += OnDownloadProgress; HttpFileInfo fileInfo = _latestTranslationInfo.Value; Maximum = fileInfo.ContentLength; await downloader.Download(fileInfo.Url, PatcherService.ArchiveFileName); if (fileInfo.LastModified != null) { File.SetLastWriteTime(PatcherService.ArchiveFileName, fileInfo.LastModified.Value); } SubLabel = null; } finally { Label = DownloadLabel; } }
public void HandleCancelJobs(CancelEvent <IEnumerable <Job> > evt) { IEnumerable <Job> jobs = evt.Object; if (jobs == null || !jobs.Any()) { CancelCurrentJob(); evt.ReturnValue = true; } else { foreach (Job job in jobs) { if (job == ViewModel.CurrentJob.Model) { CancelCurrentJob(); } else { job.State = JobState.Cancelled; } } evt.ReturnValue = true; } }
/// <summary> /// The constructor. /// </summary> /// <param name="fmt">Specifies the WaveFormat.</param> /// <param name="rgrgSamples">Specifies the WAV file frequency samples.</param> /// <param name="log">Specifies the output log.</param> /// <param name="evtCancel">Specifies the event used to cancel processes.</param> public WAVProcessor(WaveFormat fmt, List <double[]> rgrgSamples, Log log, CancelEvent evtCancel) { m_fmt = fmt; m_rgrgSamples = rgrgSamples; m_log = log; m_evtCancel = evtCancel; }
private async Task<string> DownloadLatestPatcher() { Label = DownloadingLabel; try { if (CancelEvent.WaitOne(0)) return null; Downloader downloader = new Downloader(CancelEvent); downloader.DownloadProgress += OnDownloadProgress; HttpFileInfo latest = await GetLatestPatcherUrl(downloader); if (latest == null) throw new Exception("Не удалось найти свежую версию программы установки. Проверьте файл конфигурации."); Maximum = latest.ContentLength; string filePath = Path.GetTempFileName(); await downloader.Download(latest.Url, filePath); return filePath; } finally { Label = InstallLabel; } }
private string ComputeHash(CancelEvent eventEntry) { return(GetSha256Hash(SHA256.Create(), (eventEntry.TokenGet + eventEntry.AmountGet + eventEntry.TokenGive + eventEntry.AmountGive + eventEntry.Expires + eventEntry.Nonce + eventEntry.User).ToLowerInvariant())); }
public void TestAlexNetCiFar() { CancelEvent evtCancel = new CancelEvent(); SettingsCaffe settings = new SettingsCaffe(); settings.ImageDbLoadMethod = IMAGEDB_LOAD_METHOD.LOAD_ON_DEMAND; settings.EnableRandomInputSelection = true; settings.GpuIds = getGpuIds(); Trace.WriteLine("Running TestAlexNetCiFar on GPU " + settings.GpuIds); ProjectEx p = getProject(); MyCaffeControl <T> ctrl = new MyCaffeControl <T>(settings, m_log, evtCancel); try { ctrl.Load(Phase.TRAIN, p); ctrl.OnTrainingIteration += ctrl_OnTrainingIteration; ctrl.Train(); } catch (Exception excpt) { throw excpt; } finally { ctrl.Dispose(); } }
public TestLSTMSimpleLayer(Log log, CancelEvent evtCancel, string strParams) { m_log = log; m_evtCancel = evtCancel; m_strParams = strParams; if (m_strParams != null) { string[] rgstr = m_strParams.Split(); if (rgstr.Length > 4 && rgstr[4].Trim(',') != "T") { m_bDisableDouble = true; } if (rgstr.Length > 5 && rgstr[5].Trim(',') != "T") { m_bDisableFloat = true; } if (rgstr.Length > 6 && rgstr[6].Trim(',') != "S") { m_bShortModel = false; } } }
public void TestCreateTrainingModel() { ModelBuilder builder = create(); NetParameter net_param = builder.CreateModel(); RawProto proto = net_param.ToProto("root"); string strNet = proto.ToString(); RawProto proto2 = RawProto.Parse(strNet); NetParameter net_param2 = NetParameter.FromProto(proto2); m_log.CHECK(net_param2.Compare(net_param), "The two net parameters should be the same!"); // verify creating the model. SolverParameter solver = builder.CreateSolver(); RawProto protoSolver = solver.ToProto("root"); string strSolver = protoSolver.ToString(); SettingsCaffe settings = new SettingsCaffe(); CancelEvent evtCancel = new CancelEvent(); MyCaffeControl <T> mycaffe = new MyCaffeControl <T>(settings, m_log, evtCancel); save(strNet, strSolver, false); // mycaffe.LoadLite(Phase.TRAIN, strSolver, strNet, null); mycaffe.Dispose(); }
private void State_CancelEvent() { if (CancelEvent == null || CancelEvent.Invoke()) { Dispose(); } }
/// <summary> /// The constructor. /// </summary> /// <param name="cuda">Specifies the instance of CudaDnn to use.</param> /// <param name="log">Specifies the output log.</param> /// <param name="evtCancel">Specifies the cancel event used to abort processing.</param> /// <param name="strModelType">Specifies the model type: 'vgg19', 'vgg16'</param> /// <param name="strModel">Specifies the network model to use.</param> /// <param name="rgWeights">Optionally, specifies the weights to use (or <i>null</i> to ignore).</param> /// <param name="bCaffeModel">Specifies whether or not the weights are in the caffe (<i>true</i>) or mycaffe (<i>false</i>) format.</param> /// <param name="solverType">Optionally, specifies the solver type to use (default = LBFGS).</param> /// <param name="dfLearningRate">Optionally, specifies the solver learning rate (default = 1.0).</param> public NeuralStyleTransfer(CudaDnn <T> cuda, Log log, CancelEvent evtCancel, string strModelType, string strModel, byte[] rgWeights, bool bCaffeModel, SolverParameter.SolverType solverType = SolverParameter.SolverType.LBFGS, double dfLearningRate = 1.0) { m_cuda = cuda; m_log = log; m_evtCancel = evtCancel; m_rgWeights = rgWeights; m_solverType = solverType; m_dfLearningRate = dfLearningRate; if (m_evtCancel != null) { m_evtCancel.Reset(); } RawProto proto = RawProto.Parse(strModel); m_param = NetParameter.FromProto(proto); add_input_layer(m_param); m_rgstrUsedLayers = load_layers(strModelType); prune(m_param, m_rgstrUsedLayers); add_gram_layers(m_param); m_transformationParam = new TransformationParameter(); m_transformationParam.color_order = (bCaffeModel) ? TransformationParameter.COLOR_ORDER.BGR : TransformationParameter.COLOR_ORDER.RGB; m_transformationParam.scale = 1.0; m_transformationParam.mean_value = m_rgMeanValues; m_persist = new PersistCaffe <T>(m_log, false); }
/// <summary> /// The RmsPropSolver constructor. /// </summary> /// <param name="cuda">Specifies the instance of CudaDnn to use.</param> /// <param name="log">Specifies the Log for output.</param> /// <param name="p">Specifies teh SolverParameter.</param> /// <param name="evtCancel">Specifies a CancelEvent used to cancel the current operation (e.g. training, testing) for which the Solver is performing.</param> /// <param name="evtForceSnapshot">Specifies an automatic reset event that causes the Solver to perform a Snapshot when set.</param> /// <param name="evtForceTest">Specifies an automatic reset event that causes teh Solver to run a testing cycle when set.</param> /// <param name="imgDb">Specifies the CaffeImageDatabase.</param> /// <param name="persist">Specifies the peristence used for loading and saving weights.</param> /// <param name="nSolverCount">Specifies the number of Solvers participating in a multi-GPU session.</param> /// <param name="nSolverRank">Specifies the rank of this Solver in a multi-GPU session.</param> public RmsPropSolver(CudaDnn <T> cuda, Log log, SolverParameter p, CancelEvent evtCancel, AutoResetEvent evtForceSnapshot, AutoResetEvent evtForceTest, IXImageDatabase imgDb, IXPersist <T> persist, int nSolverCount = 1, int nSolverRank = 0) : base(cuda, log, p, evtCancel, evtForceSnapshot, evtForceTest, imgDb, persist, nSolverCount, nSolverRank) { m_log.CHECK_EQ(0, m_param.momentum, "Momentum cannot be used with RmsProp."); m_log.CHECK_GE(m_param.rms_decay, 0, "rms_decay should lie between 0 and 1."); m_log.CHECK_LT(m_param.rms_decay, 1, "rms_decay should lie between 0 and 1."); }
private Dictionary<string, string> ReadStrings(DirectoryInfo translationDir) { String[] strings = Directory.GetFiles(Path.Combine(translationDir.FullName, "Strings"), "*.strings", SearchOption.AllDirectories); Dictionary<string, string> result = new Dictionary<string, string>(16000); Maximum = strings.Length; for (int i = 0; i < strings.Length; i++) { if (CancelEvent.IsSet()) return result; using (FileStream input = File.OpenRead(strings[i])) { string name; ZtrTextReader unpacker = new ZtrTextReader(input, StringsZtrFormatter.Instance); ZtrFileEntry[] entries = unpacker.Read(out name); foreach (ZtrFileEntry entry in entries) { string key = entry.Key; string value = entry.Value; result[key] = value; } } } return result; }
/// <summary> /// The LBFGSSolver constructor. /// </summary> /// <param name="cuda">Specifies the instance of CudaDnn to use.</param> /// <param name="log">Specifies the Log for output.</param> /// <param name="p">Specifies teh SolverParameter.</param> /// <param name="evtCancel">Specifies a CancelEvent used to cancel the current operation (e.g. training, testing) for which the Solver is performing.</param> /// <param name="evtForceSnapshot">Specifies an automatic reset event that causes the Solver to perform a Snapshot when set.</param> /// <param name="evtForceTest">Specifies an automatic reset event that causes teh Solver to run a testing cycle when set.</param> /// <param name="imgDb">Specifies the CaffeImageDatabase.</param> /// <param name="persist">Specifies the peristence used for loading and saving weights.</param> /// <param name="nSolverCount">Specifies the number of Solvers participating in a multi-GPU session.</param> /// <param name="nSolverRank">Specifies the rank of this Solver in a multi-GPU session.</param> public LBFGSSolver(CudaDnn <T> cuda, Log log, SolverParameter p, CancelEvent evtCancel, AutoResetEvent evtForceSnapshot, AutoResetEvent evtForceTest, IXImageDatabase imgDb, IXPersist <T> persist, int nSolverCount = 1, int nSolverRank = 0) : base(cuda, log, p, evtCancel, evtForceSnapshot, evtForceTest, imgDb, persist, nSolverCount, nSolverRank) { m_tZero = (T)Convert.ChangeType(0, typeof(T)); m_tOne = (T)Convert.ChangeType(1, typeof(T)); m_tMinusOne = (T)Convert.ChangeType(-1, typeof(T)); PreSolve(); }
public async Task <ApiResult> Cancel(CancelEvent request) { request.CompanyUid = await _currentCompanyProvider.GetCompanyUid(); request.UserUid = _currentUserProvider.GetUserUid(); return(await _mediator.Send(request)); }
/// <summary> /// The LBFGSSolver constructor. /// </summary> /// <param name="cuda">Specifies the instance of CudaDnn to use.</param> /// <param name="log">Specifies the Log for output.</param> /// <param name="p">Specifies teh SolverParameter.</param> /// <param name="evtCancel">Specifies a CancelEvent used to cancel the current operation (e.g. training, testing) for which the Solver is performing.</param> /// <param name="evtForceSnapshot">Specifies an automatic reset event that causes the Solver to perform a Snapshot when set.</param> /// <param name="evtForceTest">Specifies an automatic reset event that causes teh Solver to run a testing cycle when set.</param> /// <param name="imgDb">Specifies the MyCaffeImageDatabase.</param> /// <param name="persist">Specifies the peristence used for loading and saving weights.</param> /// <param name="nSolverCount">Specifies the number of Solvers participating in a multi-GPU session.</param> /// <param name="nSolverRank">Specifies the rank of this Solver in a multi-GPU session.</param> /// <param name="shareNet">Optionally, specifies the net to share when creating the training network (default = null, meaning no share net is used).</param> /// <param name="getws">Optionally, specifies the handler for getting the workspace.</param> /// <param name="setws">Optionally, specifies the handler for setting the workspace.</param> public LBFGSSolver(CudaDnn <T> cuda, Log log, SolverParameter p, CancelEvent evtCancel, AutoResetEvent evtForceSnapshot, AutoResetEvent evtForceTest, IXImageDatabaseBase imgDb, IXPersist <T> persist, int nSolverCount = 1, int nSolverRank = 0, Net <T> shareNet = null, onGetWorkspace getws = null, onSetWorkspace setws = null) : base(cuda, log, p, evtCancel, evtForceSnapshot, evtForceTest, imgDb, persist, nSolverCount, nSolverRank, shareNet, getws, setws) { m_tZero = (T)Convert.ChangeType(0, typeof(T)); m_tOne = (T)Convert.ChangeType(1, typeof(T)); m_tMinusOne = (T)Convert.ChangeType(-1, typeof(T)); PreSolve(); }
void OnCancelEvent(CancelEvent e) { if (!Enabled) { Trace.Script("Disabled!", this); return; } this.Cancel(); }
/// <summary> /// Executed when the Esc button is pressed and the Escape property is true /// </summary> public virtual void OnEscape() { ModalResult = ModalWindowResult.Cancel; if (MainWindow.ActiveWindow == this) { Close(); } CancelEvent?.Invoke(); }
void OnCancelEvent(CancelEvent e) { if (!Enabled) { StratusDebug.Log("Disabled!", this); return; } this.Cancel(); }
/// <summary> /// The constructor. /// </summary> /// <param name="nIdx">Specifies the index of the thread.</param> /// <param name="mycaffe">Specifies the MyCaffeControl used.</param> /// <param name="log">Specifies the output log to use.</param> /// <param name="evtCancel">Specifies the cancel event.</param> /// <param name="bReset">Specifies to reset the environment.</param> /// <param name="nAction">Specifies the action to run. If less than zero this parameter is ignored.</param> /// <param name="bAllowUi">Optionally, specifies whether or not to allow the user interface.</param> public GetDataArgs(int nIdx, Component mycaffe, Log log, CancelEvent evtCancel, bool bReset, int nAction = -1, bool bAllowUi = true) { m_nIndex = nIdx; m_nAction = nAction; m_caffe = mycaffe; m_log = log; m_evtCancel = evtCancel; m_bReset = bReset; }
/// <summary> /// cancels the popup /// </summary> public virtual void ExecuteCancel() { if (!Interactable) { return; } Interactable = false; CancelEvent?.Invoke(); Destroy(); }
/// <summary> /// The ActionStateArgs constructor. /// </summary> /// <param name="cuda">Specifies the CudaDnn connection to Cuda.</param> /// <param name="log">Specifies the Log for output.</param> /// <param name="evtCancel">Specifies the CancelEvent that when Set signals to DoWork that it should terminate.</param> /// <param name="nDeviceID">Optionally, specifies the DeviceID.</param> /// <param name="arg">Optionally, specifies an argument defined by the caller.</param> /// <param name="nInitialDelay">Optionally, specifies an initial delay for the thread in ms. (default = 0).</param> public ActionStateArgs(CudaDnn <T> cuda, Log log, CancelEvent evtCancel, int nDeviceID = 0, object arg = null, int nInitialDelay = 0) : base() { m_log = log; m_cuda = cuda; m_evtCancel = evtCancel; m_nDeviceID = nDeviceID; m_arg = arg; m_nInitialDelay = nInitialDelay; }
private void GridWindow_OnMouseUp(object sender, MouseButtonEventArgs e) { if (okImageState == ImageState.Focus) { OkEvent?.Invoke(sender, new OkEventArgs()); } else if (cancelImageState == ImageState.Focus) { CancelEvent?.Invoke(sender, new OkEventArgs()); } }
/// <summary> /// The constructor. /// </summary> /// <param name="param">Specifies the creation parameters.</param> /// <param name="log">Specifies the output log used to show status updates.</param> /// <param name="evtCancel">Specifies the cancel event used to abort the creation process.</param> public MnistDataLoader(MnistDataParameters param, Log log, CancelEvent evtCancel) { m_extractor = new MnistDataLoaderLite(Path.GetDirectoryName(param.TrainImagesFile)); m_extractor.OnProgress += m_extractor_OnProgress; m_extractor.OnError += m_extractor_OnError; m_param = param; m_log = log; m_evtCancel = evtCancel; m_evtCancel.Reset(); }
/// <summary> /// The DataLayer constructor. /// </summary> /// <param name="cuda">Specifies the CudaDnn connection to Cuda.</param> /// <param name="log">Specifies the Log for output.</param> /// <param name="p">Specifies the LayerParameter with the batchdata_param.</param> /// <param name="db">Specifies the external database to use.</param> /// <param name="evtCancel">Specifies the CancelEvent used to cancel any pre-fetching operations.</param> /// <param name="fnSet">Specifies the delegate used to set the input data.</param> public BatchDataLayer(CudaDnn <T> cuda, Log log, LayerParameter p, IXImageDatabase db, CancelEvent evtCancel, TransferInput.fnSetInputData fnSet) : base(cuda, log, p, db) { log.CHECK(p.type == LayerParameter.LayerType.BATCHDATA, "The layer type should be BATCHDATA."); m_type = LayerParameter.LayerType.BATCHDATA; m_evtCancel = evtCancel; m_fnSetInput = fnSet; m_batch = new layers.Batch <T>(m_cuda, m_log); m_internalThread = new common.InternalThread <T>(); m_internalThread.DoWork += m_internalThread_DoWork; }
/// <summary> /// The ModelDataLayer constructor. /// </summary> /// <param name="cuda">Specifies the CudaDnn connection to Cuda.</param> /// <param name="log">Specifies the Log for output.</param> /// <param name="p"> /// Provides ModelDataParameter model_data_param with options: /// - source. The data source(s) where the source is the data input table who's RawImageResults table contains the data for training. /// /// - batch_size. The batch size (currently only 1 supported). /// /// - time_steps. The maximum number of time steps. /// /// - input_dim. The input dimension of the encoder input. /// /// - sample_size. The number of samples to load for training. /// /// - shuffle. Whether or not to shuffle the data. /// </param> /// <param name="db">Specifies the external database to use.</param> /// <param name="evtCancel">Specifies the CancelEvent used to cancel any pre-fetching operations.</param> public ModelDataLayer(CudaDnn <T> cuda, Log log, LayerParameter p, IXImageDatabaseBase db, CancelEvent evtCancel) : base(cuda, log, p) { m_db = db as IXImageDatabase2; if (m_db == null) { throw new Exception("The ModelDataLayer requires the ImageDatabase V2 or higher."); } m_evtCancel = evtCancel; m_type = LayerParameter.LayerType.MODEL_DATA; }
private DirectoryInfo ExtractZipToTempFolder(string zipPath) { using (ZipArchive zipFile = ZipFile.OpenRead(zipPath)) { if (CancelEvent.IsSet()) return null; DirectoryInfo dir = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString())); zipFile.ExtractToDirectory(dir.FullName); return dir; } }
/// <summary> /// The RecurrentLayer constructor. /// </summary> /// <param name="cuda">Specifies the CudaDnn connection to Cuda.</param> /// <param name="log">Specifies the Log for output.</param> /// <param name="p">Specifies the LayerParameter of type LSTM or RNN. /// </param> /// <param name="evtCancel">Specifies the CancelEvent used to cancel training operations.</param> public RecurrentLayer(CudaDnn <T> cuda, Log log, LayerParameter p, CancelEvent evtCancel) : base(cuda, log, p) { m_evtCancel = evtCancel; if (p.type == LayerParameter.LayerType.LSTM) { m_rnnMode = RNN_MODE.LSTM; } else { m_rnnMode = RNN_MODE.RNN_RELU; } }
private async void DownLoadExtraPic(DetailMovie dm) { List <string> urlList = dm.extraimageurl?.Split(';').Where(arg => arg.IsProperUrl()).ToList(); bool dlimageSuccess = false; string cookies = ""; for (int i = 0; i < urlList.Count(); i++) { HttpStatusCode sc = HttpStatusCode.Forbidden; if (cts.IsCancellationRequested) { CancelEvent?.Invoke(this, EventArgs.Empty); break; } string filepath = ""; filepath = BasePicPath + "ExtraPic\\" + dm.id + "\\" + Path.GetFileName(new Uri(urlList[i]).LocalPath); if (!File.Exists(filepath)) { (dlimageSuccess, cookies) = await Task.Run(() => { return(MyNet.DownLoadImage(urlList[i], ImageType.ExtraImage, dm.id, Cookie: cookies, callback: (statuscode) => { sc = (HttpStatusCode)statuscode; })); }); if (dlimageSuccess) { ExtraImageDownLoadCompleted?.Invoke(this, new MessageCallBackEventArgs(filepath)); if (urlList[i].IndexOf("dmm") > 0) { Thread.Sleep(Delay.MEDIUM); } else { Thread.Sleep(Delay.SHORT_3); } } else { Logger.LogN($" {Jvedio.Language.Resources.Preview} {i + 1} {Jvedio.Language.Resources.Message_Fail}:{urlList[i]}, {Jvedio.Language.Resources.Reason} : {sc.ToStatusMessage()}"); MessageCallBack?.Invoke(this, new MessageCallBackEventArgs($" {Jvedio.Language.Resources.Preview} {i + 1} {Jvedio.Language.Resources.Message_Fail},{Jvedio.Language.Resources.Reason} :{sc.ToStatusMessage()} ,{Jvedio.Language.Resources.Message_ViewLog}")); } } lock (lockobject) Value += 1; InfoUpdate?.Invoke(this, new DetailMovieEventArgs() { DetailMovie = dm, value = Value, maximum = Maximum }); } lock (lockobject) Value = Maximum; InfoUpdate?.Invoke(this, new DetailMovieEventArgs() { DetailMovie = dm, value = Value, maximum = Maximum }); IsDownLoading = false; }