private static async Task PredictLabelsAndUpdateGitHub(string ModelPath) { Console.WriteLine(".............Retrieving Issues from GITHUB repo, predicting label/s and assigning predicted label/s......"); var token = Configuration["GitHubToken"]; var repoOwner = Configuration["GitHubRepoOwner"]; //IMPORTANT: This can be a GitHub User or a GitHub Organization var repoName = Configuration["GitHubRepoName"]; if (string.IsNullOrEmpty(token) || token == "YOUR - GUID - GITHUB - TOKEN" || string.IsNullOrEmpty(repoOwner) || repoOwner == "YOUR-REPO-USER-OWNER-OR-ORGANIZATION" || string.IsNullOrEmpty(repoName) || repoName == "YOUR-REPO-SINGLE-NAME") { Console.Error.WriteLine(); Console.Error.WriteLine("Error: please configure the credentials in the appsettings.json file"); Console.ReadLine(); return; } //This "Labeler" class could be used in a different End-User application (Web app, other console app, desktop app, etc.) var labeler = new Labeler(ModelPath, repoOwner, repoName, token); await labeler.LabelAllNewIssuesInGitHubRepo(); Console.WriteLine("Labeling completed"); Console.ReadLine(); }
//main method public Floor Build() { List <LabeledOutline> outlineLabels = Labeler.GetOutlineLabel(ParentFloor.Outline, ParentFloor.Cores.First(), ParentFloor.Corridors); List <List <Room> > allocatedRooms = RoomAllocator.AllocateToOutlineParts(ParentFloor.Rooms, outlineLabels); RoomP1Builder builder = new RoomP1Builder(); builder.OutlineLabels = outlineLabels; builder.AllocatedRoom = allocatedRooms; ParentFloor.Rooms = builder.Build(); return(ParentFloor); }
/// <summary> /// Compares the specified first image. /// </summary> /// <param name="firstImage">The first image.</param> /// <param name="secondImage">The second image.</param> /// <returns></returns> /// <exception cref="ArgumentException">Bitmaps must be the same size.</exception> public Image Compare(Image firstImage, Image secondImage) { Guard.AssertNotNull(firstImage, nameof(firstImage)); Guard.AssertNotNull(secondImage, nameof(secondImage)); if (firstImage.Width != secondImage.Width || firstImage.Height != secondImage.Height) { throw new ArgumentException("Bitmaps must be the same size."); } var differenceMap = BitmapAnalyzer.Analyze(firstImage, secondImage); var differenceLabels = Labeler.Label(differenceMap); var boundingBoxes = BoundingBoxIdentifier.CreateBoundingBoxes(differenceLabels); var differenceBitmap = CreateImageWithBoundingBoxes(secondImage, boundingBoxes); return(differenceBitmap); }
private void Canvas_Draw(CanvasControl sender, CanvasDrawEventArgs args) { args.DrawingSession.Transform = System.Numerics.Matrix3x2.CreateTranslation(0, 5); EnsureResources(sender, sender.Size); FontMetricsHolder fmh = new FontMetricsHolder(args.DrawingSession); textLayout.DrawToTextRenderer(fmh, new System.Numerics.Vector2(0, 0)); args.DrawingSession.DrawTextLayout(textLayout, 0, 0, Colors.White); if (ShowGlyphRunBounds) { foreach (var metrics in fmh.GlyphRunMetrics) { args.DrawingSession.DrawRectangle(metrics.Bounds, Colors.Cyan); } } float baselineInWorldSpace = (float)textLayout.LayoutBounds.Top + textLayout.LineMetrics[0].Baseline; Labeler.DrawBaseline(args.DrawingSession, sender.Size.ToVector2(), baselineInWorldSpace); if (UniformStyle) { Labeler l = new Labeler(CurrentFontSize, sizeDim, sender.Size.ToVector2(), textLayout.LayoutBounds, baselineInWorldSpace, fmh.GlyphRunMetrics[0], args.DrawingSession); l.DrawAscent(); l.DrawLineGap(); l.DrawDescent(); l.DrawCapitalHeight(); l.DrawLowercaseHeight(); } else { Labeler l1 = new Labeler(CurrentUppercaseFontSize, sizeDim, sender.Size.ToVector2(), textLayout.LayoutBounds, baselineInWorldSpace, fmh.GlyphRunMetrics[0], args.DrawingSession); l1.DrawLineGap(); l1.DrawCapitalHeight(); l1.DrawAscent(); Labeler l2 = new Labeler(CurrentLowercaseFontSize, sizeDim, sender.Size.ToVector2(), textLayout.LayoutBounds, baselineInWorldSpace, fmh.GlyphRunMetrics[fmh.GlyphRunMetrics.Count - 1], args.DrawingSession); l2.DrawLineGap(); l2.DrawLowercaseHeight(); l2.DrawDescent(); } }
public Bitmap Compare(Bitmap firstImage, Bitmap secondImage) { if (firstImage == null) { throw new ArgumentNullException("firstImage"); } if (secondImage == null) { throw new ArgumentNullException("secondImage"); } if (firstImage.Width != secondImage.Width || firstImage.Height != secondImage.Height) { throw new ArgumentException("Bitmaps must be the same size."); } var differenceMap = BitmapAnalyzer.Analyze(firstImage, secondImage); var differenceLabels = Labeler.Label(differenceMap); var boundingBoxes = BoundingBoxIdentifier.CreateBoundingBoxes(differenceLabels); var differenceBitmap = CreateImageWithBoundingBoxes(secondImage, boundingBoxes); return(differenceBitmap); }
protected bool AssignDefaultName() { string defaultName; for (int index = 0; index < Tournament.Rounds.Count; ++index) { bool roundAlreadyAddedToTournament = Tournament.Rounds[index].Id == Id; if (roundAlreadyAddedToTournament) { --index; bool renameFailed = true; do { defaultName = "Round " + Labeler.GetLabelForIndex(++index); renameFailed = !RenameTo(defaultName); }while (renameFailed); } } defaultName = "Round " + Labeler.GetLabelForIndex(Tournament.Rounds.Count); return(RenameTo(defaultName)); }
private static void TestSingleLabelPrediction(string modelFilePathName) { var labeler = new Labeler(modelPath: ModelPath); labeler.TestPredictionForSingleIssue(); }
public void Initialize() { if (Config != null) { throw new Exception("BackupOperationManager is already initialized."); } Config = new Configuration(); USBHandler = new USBInsertionEventHandler(); DTHandler = new DateTimeEventHandler(); LogonHandler = new LogonEventHandler(); USBWorker = new BackgroundWorker(); USBWorker.WorkerSupportsCancellation = true; USBWorker.DoWork += RunUSBHandler; DTWorker = new BackgroundWorker(); DTWorker.WorkerSupportsCancellation = true; DTWorker.DoWork += RunDateTimeHandler; try { LoadConfig(); foreach (var trigger in Config.Triggers.Where(ev => ev.Enabled)) { List <Callback> callBacks = new List <Callback>(); foreach (var backop in Config.BackupOperations.Where(x => x.Triggers.Contains(trigger.Id)).Where(x => x.Enabled).ToList()) { foreach (var dest in backop.Destinations) { callBacks.Add(new Callback(() => { // Save original path string ogname = dest.Path.AbsolutePath; // Label the destination. // It is important that the original be labeled and not the copy // because we modify the destination information and save the configuration. // If we modified a copy, we would lose those modifications and end up with // adverse effects. Labeler.Label(dest.Path, dest.Label); // Make a copy of the destination var labeledCopy = new Path(dest.Path); // Reset the original path because we only need the label for the copy dest.Path.AbsolutePath = ogname; FileTransferManager.Copy(new Path(backop.Source), labeledCopy, backop.CopySubDirs, true); })); } } var triggerType = trigger.GetType(); // Send event to appropriate handler based on the event type if (triggerType == typeof(USBInsertionEvent)) { USBHandler.AddEvent(trigger, callBacks.ToList()); } else if (triggerType == typeof(DateTimeEvent)) { DTHandler.AddEvent(trigger, callBacks.ToList()); } else if (triggerType == typeof(LogonEvent)) { LogonHandler.AddEvent(trigger, callBacks.ToList()); } else { ReportIO.WriteStatement("Invalid trigger type defined in configuration."); } } } catch (Exception e) { ReportIO.WriteStatement(e.Message); Reload(); } }
protected void AssignDefaultName() { Name = "Group " + Labeler.GetLabelForIndex(Round.Groups.Count); MarkAsModified(); }
public static Hashtable LabelNodes(MethodBodyBlock graph, ILGenerator generator) { Labeler labeler = new Labeler(generator); ForEachVisitor.ForEach(graph, new ForEachCallback(labeler.Label) ); return(labeler.labels); }