From dd6d756233fffc471ddf3c66ee678cfab86229fb Mon Sep 17 00:00:00 2001 From: TAMARA JERINIC Date: Mon, 23 May 2022 00:52:30 +0200 Subject: Dodat datum kreiranja prediktora u arhivu i margina u form-model. --- frontend/src/app/_elements/form-model/form-model.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'frontend/src/app/_elements/form-model') diff --git a/frontend/src/app/_elements/form-model/form-model.component.html b/frontend/src/app/_elements/form-model/form-model.component.html index b986e154..1133eb52 100644 --- a/frontend/src/app/_elements/form-model/form-model.component.html +++ b/frontend/src/app/_elements/form-model/form-model.component.html @@ -189,7 +189,7 @@ -
+
-- cgit v1.2.3 From 305dac6f0e327a2582dc4f93e83794b5169d7c8f Mon Sep 17 00:00:00 2001 From: Danijel Anđelković Date: Wed, 25 May 2022 23:45:24 +0200 Subject: Popravio dosta bugova vezane za prebacivanje izmedju novog dataseta, i postojeceg dataseta, isto i za modele, u folderu. Popravio presporo prebacivanje sa jednog taba na drugi u folderu. Popravio pogresan tip stope normalizacije na backendu. --- .gitignore | 2 + backend/api/api/Models/Model.cs | 4 +- backend/api/api/Services/FillAnEmptyDb.cs | 36 ++--- .../src/app/_elements/folder/folder.component.html | 19 ++- .../src/app/_elements/folder/folder.component.ts | 160 ++++++++++++--------- .../_elements/form-model/form-model.component.html | 2 +- 6 files changed, 129 insertions(+), 94 deletions(-) (limited to 'frontend/src/app/_elements/form-model') diff --git a/.gitignore b/.gitignore index 247afbd9..e11b4739 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ backend/microservice/api/__pycache__/ production/app/node_modules/ production/app/dist/ backend/microservice/api/temp/ +backend/microservice/Boston.csv +backend/microservice/diamonds.csv diff --git a/backend/api/api/Models/Model.cs b/backend/api/api/Models/Model.cs index bbbf201e..6278cf8a 100644 --- a/backend/api/api/Models/Model.cs +++ b/backend/api/api/Models/Model.cs @@ -44,7 +44,7 @@ namespace api.Models { - public Layer(int layerNumber, string activationFunction, int neurons, string regularisation, float regularisationRate) + public Layer(int layerNumber, string activationFunction, int neurons, string regularisation, string regularisationRate) { this.layerNumber = layerNumber; this.activationFunction = activationFunction; @@ -57,7 +57,7 @@ namespace api.Models public string activationFunction { get; set; } public int neurons { get; set; } public string regularisation { get; set; } - public float regularisationRate { get; set; } + public string regularisationRate { get; set; } } } diff --git a/backend/api/api/Services/FillAnEmptyDb.cs b/backend/api/api/Services/FillAnEmptyDb.cs index cd35dc78..c74de67d 100644 --- a/backend/api/api/Services/FillAnEmptyDb.cs +++ b/backend/api/api/Services/FillAnEmptyDb.cs @@ -117,10 +117,10 @@ namespace api.Services model.outputNeurons = 0; model.layers = new[] { - new Layer ( 0,"sigmoid", 3,"l1", 1f ), - new Layer ( 1,"sigmoid", 3,"l1", 1f ), - new Layer ( 2,"sigmoid", 3,"l1", 1f ), - new Layer ( 3,"sigmoid", 3,"l1", 1f ), + new Layer ( 0,"sigmoid", 3,"l1", "0" ), + new Layer ( 1,"sigmoid", 3,"l1", "0" ), + new Layer ( 2,"sigmoid", 3,"l1", "0" ), + new Layer ( 3,"sigmoid", 3,"l1", "0" ), }; model.outputLayerActivationFunction = "sigmoid"; model.metrics = new string[] { }; @@ -281,11 +281,11 @@ namespace api.Services model.outputNeurons = 0; model.layers = new[] { - new Layer ( 0,"softmax", 3,"l1", 3f ), - new Layer ( 1,"softmax", 3,"l1", 3f ), - new Layer ( 2,"softmax", 3,"l1", 3f ), - new Layer ( 3,"softmax", 3,"l1", 3f ), - new Layer ( 4,"softmax", 3,"l1", 3f ) + new Layer ( 0,"softmax", 3,"l1", "0" ), + new Layer ( 1,"softmax", 3,"l1", "0" ), + new Layer ( 2,"softmax", 3,"l1", "0" ), + new Layer ( 3,"softmax", 3,"l1", "0" ), + new Layer ( 4,"softmax", 3,"l1", "0" ) }; model.outputLayerActivationFunction = "softmax"; model.metrics = new string[] { }; @@ -435,9 +435,9 @@ namespace api.Services model.outputNeurons = 0; model.layers = new[] { - new Layer ( 0,"relu", 3,"l1", 1f ), - new Layer ( 1,"relu", 3,"l1", 1f ), - new Layer ( 2,"relu", 3,"l1", 1f ) + new Layer ( 0,"relu", 3,"l1", "0" ), + new Layer ( 1,"relu", 3,"l1", "0" ), + new Layer ( 2,"relu", 3,"l1", "0" ) }; model.outputLayerActivationFunction = "relu"; model.metrics = new string[] { }; @@ -593,10 +593,10 @@ namespace api.Services model.outputNeurons = 0; model.layers = new[] { - new Layer ( 0,"sigmoid", 3,"l1", 1f ), - new Layer ( 1,"sigmoid", 3,"l1", 1f ), - new Layer ( 2,"sigmoid", 3,"l1", 1f ), - new Layer ( 3,"sigmoid", 3,"l1", 1f ) + new Layer ( 0,"sigmoid", 3,"l1", "0" ), + new Layer ( 1,"sigmoid", 3,"l1", "0" ), + new Layer ( 2,"sigmoid", 3,"l1", "0" ), + new Layer ( 3,"sigmoid", 3,"l1", "0" ) }; model.outputLayerActivationFunction = "sigmoid"; model.metrics = new string[] { }; @@ -748,8 +748,8 @@ namespace api.Services model.outputNeurons = 0; model.layers = new[] { - new Layer ( 0,"relu", 3,"l1", 1f ), - new Layer ( 1,"relu", 3,"l1", 1f ) + new Layer ( 0,"relu", 3,"l1", "0" ), + new Layer ( 1,"relu", 3,"l1", "0" ) }; model.outputLayerActivationFunction = "relu"; model.metrics = new string[] { }; diff --git a/frontend/src/app/_elements/folder/folder.component.html b/frontend/src/app/_elements/folder/folder.component.html index afb6085d..ebee92d2 100644 --- a/frontend/src/app/_elements/folder/folder.component.html +++ b/frontend/src/app/_elements/folder/folder.component.html @@ -58,8 +58,13 @@
- - + + + + + +
@@ -105,7 +110,7 @@
-
+
@@ -152,17 +157,17 @@
- - -
+
- +
\ No newline at end of file diff --git a/frontend/src/app/_elements/folder/folder.component.ts b/frontend/src/app/_elements/folder/folder.component.ts index 93ef9043..de1dfae9 100644 --- a/frontend/src/app/_elements/folder/folder.component.ts +++ b/frontend/src/app/_elements/folder/folder.component.ts @@ -23,8 +23,10 @@ import isEqual from 'lodash.isequal'; }) export class FolderComponent implements AfterViewInit { - @ViewChild(FormDatasetComponent) formDataset!: FormDatasetComponent; - @ViewChild(FormModelComponent) formModel!: FormModelComponent; + @ViewChild('selectedDataset') formDataset!: FormDatasetComponent; + @ViewChild('selectedModel') formModel!: FormModelComponent; + @ViewChild('newDataset') formNewDataset!: FormDatasetComponent; + @ViewChild('newModel') formNewModel!: FormModelComponent; @Input() folderName: string = 'Moji podaci'; @Input() files!: FolderFile[] @@ -41,8 +43,6 @@ export class FolderComponent implements AfterViewInit { selectedFile?: FolderFile; hoveringOverFileIndex: number = -1; - fileToDisplay?: FolderFile; - @Output() selectedFileChanged: EventEmitter = new EventEmitter(); @Output() fileFromRoute: EventEmitter = new EventEmitter(); @Output() okPressed: EventEmitter = new EventEmitter(); @@ -68,59 +68,70 @@ export class FolderComponent implements AfterViewInit { } displayFile() { - if (this.type == FolderType.Dataset) { - this.formDataset.dataset = this.fileToDisplay; - this.formDataset.existingFlag = false; - } - else if (this.type == FolderType.Model) - this.formModel.newModel = this.fileToDisplay; - } - - hoverOverFile(i: number) { - /*this.hoveringOverFileIndex = i; - if (i != -1) { - this.fileToDisplay = this.files[i]; + if (this.newFileSelected) { + if (this.type == FolderType.Dataset) { + this.formNewDataset.dataset = this.newFile; + this.formNewDataset.existingFlag = false; + } + else if (this.type == FolderType.Model) + this.formNewModel.newModel = this.newFile; } else { - if (this.newFileSelected) { - this.fileToDisplay = this.newFile; - } else { - this.fileToDisplay = this.files[this.selectedFileIndex]; + if (this.type == FolderType.Dataset) { + this.formDataset.dataset = this.selectedFile; + this.formDataset.existingFlag = false; } + else if (this.type == FolderType.Model) + this.formModel.newModel = this.selectedFile; } - this.displayFile();*/ } selectNewFile() { if (!this.newFile) { this.createNewFile(); } - this.fileToDisplay = this.newFile; this.newFileSelected = true; this.listView = false; this.displayFile(); + + this.selectedTab = TabType.NewFile; + if (this.type == FolderType.Dataset) { - this.formDataset.clear(); + this.formNewDataset.clear(); } } selectFile(file?: FolderFile) { this.formDataset.resetPagging(); this.selectedFile = file; - Object.assign(this.lastFileData, this.selectedFile); - this.fileToDisplay = file; + this.updateLastFileData(file); if (this.type == FolderType.Experiment && file) { this.router.navigate(['/experiment/' + file._id]); } this.newFileSelected = false; this.listView = false; this.selectedFileChanged.emit(this.selectedFile); - this.selectTab(TabType.File); this.displayFile(); + this.selectedTab = TabType.File; + if (this.type == FolderType.Dataset) this.formDataset.loadExisting(); } + updateLastFileData(file: FolderFile | undefined) { + if (!file) return; + + Object.assign(this.lastFileData, file); + if (this.type == FolderType.Model) { + const lastModel = (this.lastFileData) + lastModel.layers = []; + (file).layers.forEach(layer => { + const clone = Object.assign({}, layer); + lastModel.layers.push(clone); + }) + } + } + goToExperimentPageWithPredictor(file: FolderFile, predictor: Predictor) { this.router.navigate(['/experiment/p/' + predictor._id]); } @@ -172,7 +183,7 @@ export class FolderComponent implements AfterViewInit { if (!this._initialized) { this.files = this.folders[this.startingTab]; this.filteredFiles = []; - this.selectTab(this.startingTab); + setTimeout(() => this.selectTab(this.startingTab)); this._initialized = true; } } @@ -238,7 +249,7 @@ export class FolderComponent implements AfterViewInit { this.loadingAction = true; switch (this.type) { case FolderType.Dataset: - this.formDataset!.uploadDataset((dataset: Dataset) => { + this.formNewDataset!.uploadDataset((dataset: Dataset) => { this.newFile = undefined; this.loadingAction = false; this.okPressed.emit(); @@ -250,7 +261,7 @@ export class FolderComponent implements AfterViewInit { }); break; case FolderType.Model: - this.formModel.newModel.type = this.formModel.forProblemType; + this.formNewModel.newModel.type = this.formModel.forProblemType; this.modelsService.addModel(this.formModel.newModel).subscribe(model => { this.newFile = undefined; this.loadingAction = false; @@ -300,10 +311,29 @@ export class FolderComponent implements AfterViewInit { onFileChange() { setTimeout(() => { - this.selectedFileHasChanges = !((this.selectedTab == TabType.NewFile) || isEqual(this.selectedFile, this.lastFileData)); + this.selectedFileHasChanges = !((this.selectedTab == TabType.NewFile) || this.checkFileDataEqualToLastFileData()); }); } + checkFileDataEqualToLastFileData() { + if (this.type == FolderType.Model) { + let layersEqual = true; + const oldModel = (this.lastFileData); + const selectedModel = (this.selectedFile) + const oldLayers = oldModel.layers; + oldModel.layers = selectedModel.layers; + const objEqual = isEqual(this.selectedFile, oldModel); + oldLayers.forEach((layer, index) => { + if (!isEqual(layer, selectedModel.layers[index])) { + layersEqual = false; + } + }); + return objEqual && layersEqual; + } else { + return isEqual(this.selectedFile, this.lastFileData); + } + } + updateFile() { const file = this.selectedFile; this.loadingAction = true; @@ -324,7 +354,7 @@ export class FolderComponent implements AfterViewInit { fileUpdatedSuccess() { this.loadingAction = false; this.selectedFileHasChanges = false; - Object.assign(this.lastFileData, this.selectedFile); + this.updateLastFileData(this.selectedFile); this.refreshFiles(); this.selectedFileChanged.emit(this.selectedFile); } @@ -336,16 +366,16 @@ export class FolderComponent implements AfterViewInit { case FolderType.Dataset: const dataset = file; Shared.openYesNoDialog("Obriši izvor podataka", "Eksperimenti i trenirani modeli nad ovim izvorom podataka će takođe biti obrisani, da li ste sigurni da želite da obrišete izvor: " + dataset.name + "?", () => { - if(this.selectedTab==TabType.MyDatasets){ - this.filteredFiles.splice(this.filteredFiles.indexOf(file), 1); - this.files.splice(this.files.indexOf(file), 1); + if (this.selectedTab == TabType.MyDatasets) { + this.filteredFiles.splice(this.filteredFiles.indexOf(file), 1); + this.files.splice(this.files.indexOf(file), 1); } this.loadingAction = true; this.datasetsService.deleteDataset(dataset).subscribe((response) => { this.loadingAction = false; - if(this.selectedTab==TabType.File){ + if (this.selectedTab == TabType.File) { this.refreshDatasets(null); - this.selectedFile=undefined!; + this.selectedFile = undefined!; setTimeout(() => { this.selectTab(TabType.MyDatasets); }); @@ -357,16 +387,16 @@ export class FolderComponent implements AfterViewInit { case FolderType.Model: const model = file; Shared.openYesNoDialog("Obriši konfiguraciju neuronske mreže", "Trenirani modeli za ovu konfiguraciju će takođe biti obrisani, da li ste sigurni da želite da obrišete konfiguraciju: " + model.name + "?", () => { - if(this.selectedTab==TabType.MyModels){ - this.filteredFiles.splice(this.filteredFiles.indexOf(file), 1); - this.files.splice(this.files.indexOf(file), 1); + if (this.selectedTab == TabType.MyModels) { + this.filteredFiles.splice(this.filteredFiles.indexOf(file), 1); + this.files.splice(this.files.indexOf(file), 1); } this.loadingAction = true; this.modelsService.deleteModel(file).subscribe((response) => { this.loadingAction = false; - if(this.selectedTab==TabType.File){ + if (this.selectedTab == TabType.File) { this.refreshModels(null); - this.selectedFile=undefined!; + this.selectedFile = undefined!; setTimeout(() => { this.selectTab(TabType.MyModels); }); @@ -389,20 +419,20 @@ export class FolderComponent implements AfterViewInit { } else { const experiment = file; Shared.openYesNoDialog("Obriši eksperiment", "Trenirani modeli za ovaj eksperiment će takođe biti obrisani, da li ste sigurni da želite da obrišete eksperiment: " + experiment.name + "?", () => { - if(this.selectedTab==TabType.MyExperiments){ - this.filteredFiles.splice(this.filteredFiles.indexOf(file), 1); - this.files.splice(this.files.indexOf(file), 1); + if (this.selectedTab == TabType.MyExperiments) { + this.filteredFiles.splice(this.filteredFiles.indexOf(file), 1); + this.files.splice(this.files.indexOf(file), 1); } this.loadingAction = true; this.experimentsService.deleteExperiment(experiment).subscribe((response) => { - this.loadingAction = false; - if(this.selectedTab==TabType.File){ - this.refreshExperiments(); - this.selectedFile=undefined!; - setTimeout(() => { - this.selectTab(TabType.MyExperiments); - }); - } + this.loadingAction = false; + if (this.selectedTab == TabType.File) { + this.refreshExperiments(); + this.selectedFile = undefined!; + setTimeout(() => { + this.selectTab(TabType.MyExperiments); + }); + } }); }); } @@ -489,21 +519,19 @@ export class FolderComponent implements AfterViewInit { hoverTab: TabType = TabType.None; selectTab(tab: TabType) { - setTimeout(() => { - if (tab == TabType.NewFile) { - this.selectNewFile(); - this.selectedFile=undefined!; - } - - this.listView = this.getListView(tab); - this.type = this.getFolderType(tab); - this.privacy = this.getPrivacy(tab); - this.selectedTab = tab; - this.files = this.folders[tab]; + if (tab == TabType.NewFile) { + this.selectNewFile(); + } else if (tab == TabType.File) { + this.selectFile(this.selectedFile); + } + this.listView = this.getListView(tab); + this.type = this.getFolderType(tab); + this.privacy = this.getPrivacy(tab); + this.selectedTab = tab; + this.files = this.folders[tab]; - if (tab !== TabType.File && tab !== TabType.NewFile) - this.searchTermsChanged(); - }); + if (tab !== TabType.File && tab !== TabType.NewFile) + this.searchTermsChanged(); } getListView(tab: TabType) { diff --git a/frontend/src/app/_elements/form-model/form-model.component.html b/frontend/src/app/_elements/form-model/form-model.component.html index 1133eb52..9051a2d4 100644 --- a/frontend/src/app/_elements/form-model/form-model.component.html +++ b/frontend/src/app/_elements/form-model/form-model.component.html @@ -229,7 +229,7 @@ Stopa regularizacije - + {{ optionName }} -- cgit v1.2.3 From 854e21f08d1c876cf62c7a360bd5bd142675d705 Mon Sep 17 00:00:00 2001 From: Danijel Anđelković Date: Fri, 3 Jun 2022 22:17:06 +0200 Subject: Dodao mogucnost download-ovanja H5 fajla za prediktor. Popravio bug kada se tooltipovi nisu uvak pojavljivali kada bi trebalo. Popravio bug sa layout-om grafa modela. --- .../_charts/line-chart/line-chart.component.css | 45 +++- .../_charts/line-chart/line-chart.component.html | 29 +-- .../_charts/line-chart/line-chart.component.ts | 230 +++++++++++---------- .../src/app/_elements/folder/folder.component.html | 22 +- .../_elements/form-model/form-model.component.html | 6 +- .../_pages/experiment/experiment.component.html | 2 +- .../app/_pages/experiment/experiment.component.ts | 8 +- frontend/src/app/_services/predictors.service.ts | 4 + 8 files changed, 200 insertions(+), 146 deletions(-) (limited to 'frontend/src/app/_elements/form-model') diff --git a/frontend/src/app/_elements/_charts/line-chart/line-chart.component.css b/frontend/src/app/_elements/_charts/line-chart/line-chart.component.css index 7dbbde7a..9694119d 100644 --- a/frontend/src/app/_elements/_charts/line-chart/line-chart.component.css +++ b/frontend/src/app/_elements/_charts/line-chart/line-chart.component.css @@ -1,17 +1,46 @@ -canvas{ +.canvas-container { + height: 50%; + margin: 5px; +} + +.bottom { + height: 10%; +} - width:100% !important; - height:100% !important; +canvas { + max-height: 100%; border: 1px solid var(--ns-primary); background-color: var(--ns-bg-dark-100); border-radius: 5px; margin: 0; font-size: 11 !important; padding: 0; - } -.ns-col{ - margin: 5px; } -.hide{ - display: none; + +.ns-col { + margin: 5px; +} + +.hide { + display: none; } + +.dl-button { + position: relative; + color: var(--offwhite); + border-radius: 4px; + border: 1px solid var(--ns-primary); + background-color: var(--ns-bg-dark-50); + margin: 5px; + padding: 10px; + cursor: pointer; + z-index: 1001; + display: flex; + flex-direction: row; + align-items: center; + justify-content: center; +} + +.dl-button:hover { + background-color: var(--ns-primary); +} \ No newline at end of file diff --git a/frontend/src/app/_elements/_charts/line-chart/line-chart.component.html b/frontend/src/app/_elements/_charts/line-chart/line-chart.component.html index e36d0dcf..a81f9dc4 100644 --- a/frontend/src/app/_elements/_charts/line-chart/line-chart.component.html +++ b/frontend/src/app/_elements/_charts/line-chart/line-chart.component.html @@ -1,24 +1,29 @@ -
-
-
- +
+
+
+
-
- +
+
-
-
- +
+
+
-
- +
+
+
+ +
+
-
\ No newline at end of file diff --git a/frontend/src/app/_elements/_charts/line-chart/line-chart.component.ts b/frontend/src/app/_elements/_charts/line-chart/line-chart.component.ts index 2b97d6b4..ceff02bd 100644 --- a/frontend/src/app/_elements/_charts/line-chart/line-chart.component.ts +++ b/frontend/src/app/_elements/_charts/line-chart/line-chart.component.ts @@ -1,7 +1,10 @@ -import { Component, AfterViewInit, ElementRef, ViewChild, Input } from '@angular/core'; +import { Component, AfterViewInit, ElementRef, ViewChild, Input, ViewChildren, QueryList } from '@angular/core'; import { Chart } from 'chart.js'; +import FileSaver from 'file-saver'; import Experiment from 'src/app/_data/Experiment'; import Model, { ProblemType } from 'src/app/_data/Model'; +import Predictor from 'src/app/_data/Predictor'; +import { PredictorsService } from 'src/app/_services/predictors.service'; @Component({ selector: 'app-line-chart', @@ -15,19 +18,34 @@ export class LineChartComponent implements AfterViewInit { dataMAE: number[] = []; dataMSE: number[] = []; dataLOSS: number[] = []; - dataValAcc:number[]=[]; - dataValMAE:number[]=[]; - dataValMSE:number[]=[]; - dataValLoss:number[]=[]; + dataValAcc: number[] = []; + dataValMAE: number[] = []; + dataValMSE: number[] = []; + dataValLoss: number[] = []; dataEpoch: number[] = []; @ViewChild('wrapper') wrapper!: ElementRef; - @ViewChild('canvas') - canvas!: ElementRef; - @Input() experiment!:Experiment; - constructor() { - + @ViewChildren('canvas') + canvas!: QueryList; + @Input() experiment!: Experiment; + @Input() predictor?: Predictor; + + + downloadFile() { + if (!this.predictor) { + return; + } + + const fileId = this.predictor.h5FileId; + if (fileId != undefined) + this.predictorsService.downloadH5(fileId).subscribe((response) => { + FileSaver.saveAs(response, fileId + '.h5'); + }); + } + + constructor(private predictorsService: PredictorsService) { + } width = 700; height = 400; @@ -36,18 +54,13 @@ export class LineChartComponent implements AfterViewInit { myChartMae!: Chart; myChartMse!: Chart; myChartLoss!: Chart; - ProblemType=ProblemType; + ProblemType = ProblemType; resize() { - this.width = this.wrapper.nativeElement.offsetWidth; + //this.width = this.wrapper.nativeElement.offsetWidth; this.height = this.wrapper.nativeElement.offsetHeight; - - if (this.canvas) { - this.canvas.nativeElement.width = this.width; - this.canvas.nativeElement.height = this.height; - } } - update(myEpochs: number[], myAcc: number[], myLoss: number[], myMae: number[], myMse: number[], myValAcc:number[],myValLoss:number[],myValMae:number[],myValMse:number[]) { - + update(myEpochs: number[], myAcc: number[], myLoss: number[], myMae: number[], myMse: number[], myValAcc: number[], myValLoss: number[], myValMae: number[], myValMse: number[]) { + this.dataEpoch.length = 0; this.dataEpoch.push(...myEpochs); @@ -80,7 +93,7 @@ export class LineChartComponent implements AfterViewInit { this.myChartMae.update(); this.myChartMse.update(); } - updateAll(history: any[],totalEpochs:number) { + updateAll(history: any[], totalEpochs: number) { const myAcc: number[] = []; const myMae: number[] = []; const myMse: number[] = []; @@ -93,11 +106,10 @@ export class LineChartComponent implements AfterViewInit { const myEpochs: number[] = []; this.history = history; this.history.forEach((metrics, epoch) => { - if(totalEpochs>100) - { - let epochEstimate=epoch*Math.round(Math.sqrt(totalEpochs)) - if(epochEstimate>totalEpochs) - epochEstimate=totalEpochs; + if (totalEpochs > 100) { + let epochEstimate = epoch * Math.round(Math.sqrt(totalEpochs)) + if (epochEstimate > totalEpochs) + epochEstimate = totalEpochs; myEpochs.push(epochEstimate); } else @@ -131,10 +143,10 @@ export class LineChartComponent implements AfterViewInit { } }); - this.update(myEpochs, myAcc, myLoss, myMae, myMse, myValAcc,myValLoss,myValMAE,myValMSE); + this.update(myEpochs, myAcc, myLoss, myMae, myMse, myValAcc, myValLoss, myValMAE, myValMSE); } ngAfterViewInit(): void { - + window.addEventListener('resize', () => { this.resize() }); this.resize(); this.myChartAcc = new Chart("myChartacc", @@ -147,27 +159,27 @@ export class LineChartComponent implements AfterViewInit { label: 'Accuracy', data: this.dataAcc, borderWidth: 1, - + }, { label: 'Val_Accuracy', data: this.dataValAcc, borderWidth: 1 - } + } ] }, options: { - responsive: true, - maintainAspectRatio: true, + //responsive: true, + //maintainAspectRatio: true, plugins: { legend: { - labels: { - // This more specific font property overrides the global property - color:'white', - font: { - size: 10 - } + labels: { + // This more specific font property overrides the global property + color: 'white', + font: { + size: 10 } + } } }, scales: { @@ -181,14 +193,14 @@ export class LineChartComponent implements AfterViewInit { title: { display: true, text: 'Epoha', - color:"white" + color: "white" } }, y: { beginAtZero: true, ticks: { color: 'white' - + }, grid: { color: "rgba(0, 99, 171, 0.5)" @@ -196,7 +208,7 @@ export class LineChartComponent implements AfterViewInit { title: { display: true, text: 'Vrednost', - color:"white" + color: "white" } } @@ -207,40 +219,40 @@ export class LineChartComponent implements AfterViewInit { } }, - + ); - if(this.experiment.type==ProblemType.BinaryClassification || this.experiment.type==ProblemType.MultiClassification){} + if (this.experiment.type == ProblemType.BinaryClassification || this.experiment.type == ProblemType.MultiClassification) { } this.myChartLoss = new Chart("myChartloss", { type: 'line', data: { labels: this.dataEpoch, datasets: [ - { - label: 'Loss', - data: this.dataLOSS, - borderWidth: 1 - }, - { - label: 'Val_Loss', - data: this.dataValLoss, - borderWidth: 1 - }, + { + label: 'Loss', + data: this.dataLOSS, + borderWidth: 1 + }, + { + label: 'Val_Loss', + data: this.dataValLoss, + borderWidth: 1 + }, ] }, options: { - responsive: true, - maintainAspectRatio: true, + //responsive: true, + //maintainAspectRatio: true, plugins: { legend: { - labels: { - // This more specific font property overrides the global property - color:'white', - font: { - size: 10 - } + labels: { + // This more specific font property overrides the global property + color: 'white', + font: { + size: 10 } + } } }, scales: { @@ -254,14 +266,14 @@ export class LineChartComponent implements AfterViewInit { title: { display: true, text: 'Epoha', - color:"white" + color: "white" } }, y: { beginAtZero: true, ticks: { color: 'white' - + }, grid: { color: "rgba(0, 99, 171, 0.5)" @@ -269,7 +281,7 @@ export class LineChartComponent implements AfterViewInit { title: { display: true, text: 'Vrednost', - color:"white" + color: "white" } } @@ -280,7 +292,7 @@ export class LineChartComponent implements AfterViewInit { } }, - + ); this.myChartMse = new Chart("myChartmse", { @@ -288,31 +300,31 @@ export class LineChartComponent implements AfterViewInit { data: { labels: this.dataEpoch, datasets: [ - { - label: 'MSE', - data: this.dataMSE, - borderWidth: 1 - }, - { - label: 'Val_MSE', - data: this.dataValMSE, - borderWidth: 1 - } + { + label: 'MSE', + data: this.dataMSE, + borderWidth: 1 + }, + { + label: 'Val_MSE', + data: this.dataValMSE, + borderWidth: 1 + } ] }, options: { - responsive: true, - maintainAspectRatio: true, + //responsive: true, + //maintainAspectRatio: true, plugins: { legend: { - labels: { - // This more specific font property overrides the global property - color:'white', - font: { - size: 10 - } + labels: { + // This more specific font property overrides the global property + color: 'white', + font: { + size: 10 } + } } }, scales: { @@ -326,14 +338,14 @@ export class LineChartComponent implements AfterViewInit { title: { display: true, text: 'Epoha', - color:"white" + color: "white" } }, y: { beginAtZero: true, ticks: { color: 'white' - + }, grid: { color: "rgba(0, 99, 171, 0.5)" @@ -341,7 +353,7 @@ export class LineChartComponent implements AfterViewInit { title: { display: true, text: 'Vrednost', - color:"white" + color: "white" } } @@ -352,7 +364,7 @@ export class LineChartComponent implements AfterViewInit { } }, - + ); this.myChartMae = new Chart("myChartmae", { @@ -360,31 +372,31 @@ export class LineChartComponent implements AfterViewInit { data: { labels: this.dataEpoch, datasets: [ - { - label: 'MAE', - data: this.dataMAE, - borderWidth: 1 - }, - { - label: 'Val_MAE', - data: this.dataValMAE, - borderWidth: 1 - }, + { + label: 'MAE', + data: this.dataMAE, + borderWidth: 1 + }, + { + label: 'Val_MAE', + data: this.dataValMAE, + borderWidth: 1 + }, ] }, options: { - responsive: true, - maintainAspectRatio: true, + //responsive: true, + //maintainAspectRatio: true, plugins: { legend: { - labels: { - // This more specific font property overrides the global property - color:'white', - font: { - size: 10 - } + labels: { + // This more specific font property overrides the global property + color: 'white', + font: { + size: 10 } + } } }, scales: { @@ -398,14 +410,14 @@ export class LineChartComponent implements AfterViewInit { title: { display: true, text: 'Epoha', - color:"white" + color: "white" } }, y: { beginAtZero: true, ticks: { color: 'white' - + }, grid: { color: "rgba(0, 99, 171, 0.5)" @@ -413,7 +425,7 @@ export class LineChartComponent implements AfterViewInit { title: { display: true, text: 'Vrednost', - color:"white" + color: "white" } } @@ -424,9 +436,9 @@ export class LineChartComponent implements AfterViewInit { } }, - + ); - + } } diff --git a/frontend/src/app/_elements/folder/folder.component.html b/frontend/src/app/_elements/folder/folder.component.html index 34cd4693..5d5e7822 100644 --- a/frontend/src/app/_elements/folder/folder.component.html +++ b/frontend/src/app/_elements/folder/folder.component.html @@ -76,16 +76,16 @@ {{file.lastUpdated | date}}
- -
-
+
@@ -122,11 +122,11 @@
- -
-
-
+
+
diff --git a/frontend/src/app/_pages/experiment/experiment.component.html b/frontend/src/app/_pages/experiment/experiment.component.html index abb5a6d5..2e5a269c 100644 --- a/frontend/src/app/_pages/experiment/experiment.component.html +++ b/frontend/src/app/_pages/experiment/experiment.component.html @@ -67,7 +67,7 @@
- +
- + +
diff --git a/frontend/src/app/_elements/graph/graph.component.css b/frontend/src/app/_elements/graph/graph.component.css index 456a8df1..f8604125 100644 --- a/frontend/src/app/_elements/graph/graph.component.css +++ b/frontend/src/app/_elements/graph/graph.component.css @@ -10,11 +10,14 @@ /*border: 1px solid red;*/ transform: translate(-50%, -50%); } - -.node-text:not(.inputs) { +.output{ + font-weight: bold; + color: var(--offwhite); +} +.node-text:not(.output) { color: transparent; } -.node-text:not(.inputs):hover { +.node-text:not(.output):hover { color: var(--offwhite); -} \ No newline at end of file +} diff --git a/frontend/src/app/_elements/graph/graph.component.html b/frontend/src/app/_elements/graph/graph.component.html index 411e8b53..2ba42eba 100644 --- a/frontend/src/app/_elements/graph/graph.component.html +++ b/frontend/src/app/_elements/graph/graph.component.html @@ -1,8 +1,10 @@
- +
+ +
+ {{ i == 0 ? (inputColumns && inputColumns.length >= j ? inputColumns[j] : 'nepoznato') : (i > 0 && i + < layers.length - 1 ? model!.layers[i-1].activationFunction : (i==layers.length - 1 ? " "+outputColumn : '')) }}
+
+
\ No newline at end of file diff --git a/frontend/src/app/_elements/graph/graph.component.ts b/frontend/src/app/_elements/graph/graph.component.ts index 04be9f04..f14e54e7 100644 --- a/frontend/src/app/_elements/graph/graph.component.ts +++ b/frontend/src/app/_elements/graph/graph.component.ts @@ -28,7 +28,8 @@ export class GraphComponent implements AfterViewInit { @Input() outputNodeColor: string = '#dfd7d7'; private ctx!: CanvasRenderingContext2D; - @Input() inputColumns?: string[]; + @Input() inputColumns?: string[]=[]; + @Input() outputColumn?:string=""; constructor() { } @@ -81,7 +82,7 @@ export class GraphComponent implements AfterViewInit { this.layers.push([new Node(outX, outY, this.outputNodeColor)]) this.draw(); } - + draw() { this.ctx.clearRect(0, 0, this.canvas.nativeElement.width, this.canvas.nativeElement.height); -- cgit v1.2.3 From 09a33e72501affb6d07507e396151f02d16daf9a Mon Sep 17 00:00:00 2001 From: Danijel Anđelković Date: Mon, 6 Jun 2022 02:45:47 +0200 Subject: Dodao deljenje datasetova i modela, dialog za podesavanje opcija za deljenje (isPublic accessibleByLink), sa mogucnoscu kopiranja linka za deljenje. Dodao stranice za prikaz javnih datasetova / modela. --- backend/api/api/Controllers/DatasetController.cs | 32 ++++++++++ backend/api/api/Controllers/ModelController.cs | 32 ++++++++++ backend/api/api/Interfaces/IDatasetService.cs | 3 + backend/api/api/Interfaces/IModelService.cs | 3 + backend/api/api/Services/DatasetService.cs | 20 +++++- backend/api/api/Services/ModelService.cs | 16 +++++ docs/SpecifikacijaDizajnaSoftvera.docx | Bin 0 -> 5793452 bytes .../_charts/line-chart/line-chart.component.css | 3 +- .../_charts/line-chart/line-chart.component.html | 10 ++- .../src/app/_elements/folder/folder.component.html | 10 ++- .../src/app/_elements/folder/folder.component.ts | 36 ++++++++++- .../form-dataset/form-dataset.component.html | 8 +-- .../form-dataset/form-dataset.component.ts | 1 + .../_elements/form-model/form-model.component.ts | 2 + .../share-dialog/share-dialog.component.css | 0 .../share-dialog/share-dialog.component.html | 14 +++++ .../share-dialog/share-dialog.component.spec.ts | 25 ++++++++ .../_modals/share-dialog/share-dialog.component.ts | 70 +++++++++++++++++++++ .../_pages/page-dataset/page-dataset.component.css | 0 .../page-dataset/page-dataset.component.html | 4 ++ .../page-dataset/page-dataset.component.spec.ts | 25 ++++++++ .../_pages/page-dataset/page-dataset.component.ts | 45 +++++++++++++ .../app/_pages/page-model/page-model.component.css | 0 .../_pages/page-model/page-model.component.html | 4 ++ .../_pages/page-model/page-model.component.spec.ts | 25 ++++++++ .../app/_pages/page-model/page-model.component.ts | 41 ++++++++++++ frontend/src/app/_services/datasets.service.ts | 8 +++ frontend/src/app/_services/models.service.ts | 8 +++ frontend/src/app/app-routing.module.ts | 4 ++ frontend/src/app/app.module.ts | 8 ++- frontend/src/styles/layout.css | 12 +++- 31 files changed, 449 insertions(+), 20 deletions(-) create mode 100644 docs/SpecifikacijaDizajnaSoftvera.docx create mode 100644 frontend/src/app/_modals/share-dialog/share-dialog.component.css create mode 100644 frontend/src/app/_modals/share-dialog/share-dialog.component.html create mode 100644 frontend/src/app/_modals/share-dialog/share-dialog.component.spec.ts create mode 100644 frontend/src/app/_modals/share-dialog/share-dialog.component.ts create mode 100644 frontend/src/app/_pages/page-dataset/page-dataset.component.css create mode 100644 frontend/src/app/_pages/page-dataset/page-dataset.component.html create mode 100644 frontend/src/app/_pages/page-dataset/page-dataset.component.spec.ts create mode 100644 frontend/src/app/_pages/page-dataset/page-dataset.component.ts create mode 100644 frontend/src/app/_pages/page-model/page-model.component.css create mode 100644 frontend/src/app/_pages/page-model/page-model.component.html create mode 100644 frontend/src/app/_pages/page-model/page-model.component.spec.ts create mode 100644 frontend/src/app/_pages/page-model/page-model.component.ts (limited to 'frontend/src/app/_elements/form-model') diff --git a/backend/api/api/Controllers/DatasetController.cs b/backend/api/api/Controllers/DatasetController.cs index c93ac9db..9a3c3d86 100644 --- a/backend/api/api/Controllers/DatasetController.cs +++ b/backend/api/api/Controllers/DatasetController.cs @@ -282,5 +282,37 @@ namespace api.Controllers return Ok($"Dataset with ID = {id} deleted"); } + + [HttpPut("UpdateAccessibleByLink/{datasetId}")] + [Authorize(Roles = "User")] + public ActionResult UpdateAccessibleByLink(string datasetId, [FromBody] bool accessibleByLink) + { + string uploaderId = getUserId(); + + Dataset dataset = _datasetService.GetOneDataset(datasetId); + + if (uploaderId != dataset.uploaderId) + return Unauthorized(); + + _datasetService.UpdateAccessibleByLink(datasetId, accessibleByLink); + + return Ok(dataset.accessibleByLink); + } + + [HttpPut("UpdateIsPublic/{datasetId}")] + [Authorize(Roles = "User")] + public ActionResult UpdateIsPublic(string datasetId, [FromBody] bool isPublic) + { + string uploaderId = getUserId(); + + Dataset dataset = _datasetService.GetOneDataset(datasetId); + + if (uploaderId != dataset.uploaderId) + return Unauthorized(); + + _datasetService.UpdateIsPublic(datasetId, isPublic); + + return Ok(dataset.isPublic); + } } } \ No newline at end of file diff --git a/backend/api/api/Controllers/ModelController.cs b/backend/api/api/Controllers/ModelController.cs index c574de28..c7dfe89c 100644 --- a/backend/api/api/Controllers/ModelController.cs +++ b/backend/api/api/Controllers/ModelController.cs @@ -312,6 +312,38 @@ namespace api.Controllers } + [HttpPut("UpdateAccessibleByLink/{modelId}")] + [Authorize(Roles = "User")] + public ActionResult UpdateAccessibleByLink(string modelId, [FromBody] bool accessibleByLink) + { + string uploaderId = getUserId(); + + Model model = _modelService.GetOneModel(modelId); + + if (uploaderId != model.uploaderId) + return Unauthorized(); + + _modelService.UpdateAccessibleByLink(modelId, accessibleByLink); + + return Ok(model.accessibleByLink); + } + + [HttpPut("UpdateIsPublic/{modelId}")] + [Authorize(Roles = "User")] + public ActionResult UpdateIsPublic(string modelId, [FromBody] bool isPublic) + { + string uploaderId = getUserId(); + + Model model = _modelService.GetOneModel(modelId); + + if (uploaderId != model.uploaderId) + return Unauthorized(); + + _modelService.UpdateIsPublic(modelId, isPublic); + + return Ok(model.isPublic); + } + } public class TrainModelObject diff --git a/backend/api/api/Interfaces/IDatasetService.cs b/backend/api/api/Interfaces/IDatasetService.cs index 2f7d0010..5a91c82b 100644 --- a/backend/api/api/Interfaces/IDatasetService.cs +++ b/backend/api/api/Interfaces/IDatasetService.cs @@ -19,5 +19,8 @@ namespace api.Services public void Update(Dataset dataset); string GetDatasetId(string fileId); //bool CheckDb(); + + public void UpdateAccessibleByLink(string datasetId, bool accessibleByLink); + public void UpdateIsPublic(string datasetId, bool isPublic); } } diff --git a/backend/api/api/Interfaces/IModelService.cs b/backend/api/api/Interfaces/IModelService.cs index 41cd279c..949c7278 100644 --- a/backend/api/api/Interfaces/IModelService.cs +++ b/backend/api/api/Interfaces/IModelService.cs @@ -19,6 +19,9 @@ namespace api.Services void Delete(string userId, string name); bool CheckHyperparameters(int inputNeurons, int hiddenLayerNeurons, int hiddenLayers, int outputNeurons); bool CheckDb(); + + public void UpdateAccessibleByLink(string modelId, bool accessibleByLink); + public void UpdateIsPublic(string modelId, bool isPublic); } } diff --git a/backend/api/api/Services/DatasetService.cs b/backend/api/api/Services/DatasetService.cs index 0b84721e..cd27f275 100644 --- a/backend/api/api/Services/DatasetService.cs +++ b/backend/api/api/Services/DatasetService.cs @@ -75,7 +75,7 @@ namespace api.Services public Dataset GetOneDataset(string userId, string id) { - return _dataset.Find(dataset => dataset.uploaderId == userId && dataset._id == id && dataset.isPreProcess).FirstOrDefault(); + return _dataset.Find(dataset => (dataset.uploaderId == userId || dataset.isPublic || dataset.accessibleByLink) && dataset._id == id && dataset.isPreProcess).FirstOrDefault(); } public Dataset GetOneDatasetN(string userId, string name) { @@ -104,6 +104,22 @@ namespace api.Services return dataset._id; } - + + public void UpdateAccessibleByLink(string datasetId, bool accessibleByLink) + { + Dataset dataset = _dataset.Find(dataset => dataset._id == datasetId).FirstOrDefault(); + dataset.accessibleByLink = accessibleByLink; + + _dataset.ReplaceOne(dataset => dataset._id == datasetId, dataset); + } + + public void UpdateIsPublic(string datasetId, bool isPublic) + { + Dataset dataset = _dataset.Find(dataset => dataset._id == datasetId).FirstOrDefault(); + dataset.isPublic = isPublic; + + _dataset.ReplaceOne(dataset => dataset._id == datasetId, dataset); + } + } } diff --git a/backend/api/api/Services/ModelService.cs b/backend/api/api/Services/ModelService.cs index 71db6340..1c690ca7 100644 --- a/backend/api/api/Services/ModelService.cs +++ b/backend/api/api/Services/ModelService.cs @@ -106,5 +106,21 @@ namespace api.Services return true; } + + public void UpdateAccessibleByLink(string modelId, bool accessibleByLink) + { + Model model = _model.Find(model => model._id == modelId).FirstOrDefault(); + model.accessibleByLink = accessibleByLink; + + _model.ReplaceOne(model => model._id == modelId, model); + } + + public void UpdateIsPublic(string modelId, bool isPublic) + { + Model model = _model.Find(model => model._id == modelId).FirstOrDefault(); + model.isPublic = isPublic; + + _model.ReplaceOne(model => model._id == modelId, model); + } } } diff --git a/docs/SpecifikacijaDizajnaSoftvera.docx b/docs/SpecifikacijaDizajnaSoftvera.docx new file mode 100644 index 00000000..dfc5345b Binary files /dev/null and b/docs/SpecifikacijaDizajnaSoftvera.docx differ diff --git a/frontend/src/app/_elements/_charts/line-chart/line-chart.component.css b/frontend/src/app/_elements/_charts/line-chart/line-chart.component.css index 862a86e1..60b341d0 100644 --- a/frontend/src/app/_elements/_charts/line-chart/line-chart.component.css +++ b/frontend/src/app/_elements/_charts/line-chart/line-chart.component.css @@ -22,7 +22,8 @@ canvas { } .hide { - display: none; + display: none !important; + background-color: red; } .dl-button { diff --git a/frontend/src/app/_elements/_charts/line-chart/line-chart.component.html b/frontend/src/app/_elements/_charts/line-chart/line-chart.component.html index cc1c0121..505dd50b 100644 --- a/frontend/src/app/_elements/_charts/line-chart/line-chart.component.html +++ b/frontend/src/app/_elements/_charts/line-chart/line-chart.component.html @@ -1,5 +1,5 @@
-
+
@@ -9,18 +9,16 @@
-
-
+
+
-
+
- -

Model treniran za konfiguraciju: {{modelName}}Model se trenira za konfiguraciju: {{modelName}}

+ @@ -122,12 +125,15 @@
- - +