Esempio n. 1
0
    def on_wyPlot_clicked(self):
        # self.matplotlibwidget_static_2.hide()

        # Show the structure of the model and plot the weights
        if len(self.openfile_name) != 0:
            if self.radioButton.isChecked() == True:
                if len(self.chosenLayerName) != 0:

                    self.W_F = 'w'
                    # show the weights
                    if self.modelDimension == '2D':
                        if hasattr(self.LayerWeights[self.chosenLayerName],
                                   "ndim"):

                            if self.LayerWeights[
                                    self.chosenLayerName].ndim == 4:
                                self.lcdNumberPatch.hide()
                                self.lcdNumberSlice.hide()
                                self.horizontalSliderPatch.hide()
                                self.horizontalSliderSlice.hide()
                                self.labelPatch.hide()
                                self.labelSlice.hide()

                                self.overlay = Overlay(self.centralWidget(
                                ))  # self.scrollArea self.centralWidget()
                                self.overlay.setGeometry(
                                    QtCore.QRect(500, 350, 171, 141))
                                self.overlay.show()

                                self.matplotlibwidget_static.mpl.getLayersWeights(
                                    self.LayerWeights)
                                from loadf import loadImage_weights_plot_2D
                                self.wyPlot.setDisabled(True)
                                self.newW2D = loadImage_weights_plot_2D(
                                    self.matplotlibwidget_static,
                                    self.chosenLayerName)
                                self.newW2D.trigger.connect(self.loadEnd)
                                self.newW2D.start()

                                # self.matplotlibwidget_static.mpl.weights_plot_2D(self.chosenLayerName)
                                self.matplotlibwidget_static.show()
                            # elif self.LayerWeights[self.chosenLayerName].ndim==0:
                            #     self.showNoWeights()
                            else:
                                self.showWeightsDimensionError()

                        elif self.LayerWeights[self.chosenLayerName] == 0:
                            self.showNoWeights()

                    elif self.modelDimension == '3D':
                        if hasattr(self.LayerWeights[self.chosenLayerName],
                                   "ndim"):

                            if self.LayerWeights[
                                    self.chosenLayerName].ndim == 5:

                                self.w = self.LayerWeights[
                                    self.chosenLayerName]
                                self.totalWeights = self.w.shape[0]
                                # self.totalWeightsSlices=self.w.shape[2]
                                self.horizontalSliderPatch.setMinimum(1)
                                self.horizontalSliderPatch.setMaximum(
                                    self.totalWeights)
                                # self.horizontalSliderSlice.setMinimum(1)
                                # self.horizontalSliderSlice.setMaximum(self.totalWeightsSlices)
                                self.chosenWeightNumber = 1
                                self.horizontalSliderPatch.setValue(
                                    self.chosenWeightNumber)

                                self.overlay = Overlay(self.centralWidget(
                                ))  # self.scrollArea self.centralWidget()
                                self.overlay.setGeometry(
                                    QtCore.QRect(500, 350, 171, 141))
                                self.overlay.show()

                                from loadf import loadImage_weights_plot_3D
                                self.wyPlot.setDisabled(True)
                                self.newW3D = loadImage_weights_plot_3D(
                                    self.matplotlibwidget_static, self.w,
                                    self.chosenWeightNumber, self.totalWeights,
                                    self.totalWeightsSlices)
                                self.newW3D.trigger.connect(self.loadEnd)
                                self.newW3D.start()

                                # self.matplotlibwidget_static.mpl.weights_plot_3D(self.w,self.chosenWeightNumber,self.totalWeights,self.totalWeightsSlices)

                                self.matplotlibwidget_static.show()
                                self.horizontalSliderSlice.hide()
                                self.horizontalSliderPatch.show()
                                self.labelPatch.show()
                                self.labelSlice.hide()
                                self.lcdNumberSlice.hide()
                                self.lcdNumberPatch.show()
                            # elif self.LayerWeights[self.chosenLayerName].ndim==0:
                            #     self.showNoWeights()
                            else:
                                self.showWeightsDimensionError3D()

                        elif self.LayerWeights[self.chosenLayerName] == 0:
                            self.showNoWeights()

                    else:
                        print('the dimesnion should be 2D or 3D')

                else:
                    self.showChooseLayerDialog()

            elif self.radioButton_2.isChecked() == True:
                if len(self.chosenLayerName) != 0:
                    self.W_F = 'f'
                    if self.modelDimension == '2D':
                        if self.act[self.chosenLayerName].ndim == 4:
                            self.activations = self.act[self.chosenLayerName]
                            self.totalPatches = self.activations.shape[0]

                            self.matplotlibwidget_static.mpl.getLayersFeatures(
                                self.activations, self.totalPatches)

                            # show the features
                            self.chosenPatchNumber = 1
                            self.horizontalSliderPatch.setMinimum(1)
                            self.horizontalSliderPatch.setMaximum(
                                self.totalPatches)
                            self.horizontalSliderPatch.setValue(
                                self.chosenPatchNumber)

                            self.overlay = Overlay(self.centralWidget(
                            ))  # self.scrollArea self.centralWidget()
                            self.overlay.setGeometry(
                                QtCore.QRect(500, 350, 171, 141))
                            self.overlay.show()

                            from loadf import loadImage_features_plot
                            self.wyPlot.setDisabled(True)
                            self.newf = loadImage_features_plot(
                                self.matplotlibwidget_static,
                                self.chosenPatchNumber)
                            self.newf.trigger.connect(self.loadEnd)
                            self.newf.start()

                            # self.matplotlibwidget_static.mpl.features_plot(self.chosenPatchNumber)
                            self.matplotlibwidget_static.show()
                            self.horizontalSliderSlice.hide()
                            self.horizontalSliderPatch.show()
                            self.labelPatch.show()
                            self.labelSlice.hide()
                            self.lcdNumberPatch.show()
                            self.lcdNumberSlice.hide()
                        else:
                            self.showNoFeatures()

                    elif self.modelDimension == '3D':
                        a = self.act[self.chosenLayerName]
                        if self.act[self.chosenLayerName].ndim == 5:
                            self.activations = self.act[self.chosenLayerName]
                            self.totalPatches = self.activations.shape[0]
                            self.totalPatchesSlices = self.activations.shape[1]

                            self.matplotlibwidget_static.mpl.getLayersFeatures_3D(
                                self.activations, self.totalPatches,
                                self.totalPatchesSlices)

                            self.chosenPatchNumber = 1
                            self.chosenPatchSliceNumber = 1
                            self.horizontalSliderPatch.setMinimum(1)
                            self.horizontalSliderPatch.setMaximum(
                                self.totalPatches)
                            self.horizontalSliderPatch.setValue(
                                self.chosenPatchNumber)
                            self.horizontalSliderSlice.setMinimum(1)
                            self.horizontalSliderSlice.setMaximum(
                                self.totalPatchesSlices)
                            self.horizontalSliderSlice.setValue(
                                self.chosenPatchSliceNumber)

                            self.overlay = Overlay(self.centralWidget(
                            ))  # self.scrollArea self.centralWidget()
                            self.overlay.setGeometry(
                                QtCore.QRect(500, 350, 171, 141))
                            self.overlay.show()

                            from loadf import loadImage_features_plot_3D
                            self.wyPlot.setDisabled(True)
                            self.newf = loadImage_features_plot_3D(
                                self.matplotlibwidget_static,
                                self.chosenPatchNumber,
                                self.chosenPatchSliceNumber)
                            self.newf.trigger.connect(self.loadEnd)
                            self.newf.start()

                            # self.matplotlibwidget_static.mpl.features_plot_3D(self.chosenPatchNumber,self.chosenPatchSliceNumber)
                            self.horizontalSliderSlice.show()
                            self.horizontalSliderPatch.show()
                            self.labelPatch.show()
                            self.labelSlice.show()
                            self.lcdNumberPatch.show()
                            self.lcdNumberSlice.show()
                            self.matplotlibwidget_static.show()
                        else:
                            self.showNoFeatures()

                    else:
                        print('the dimesnion should be 2D or 3D')

                else:
                    self.showChooseLayerDialog()

            else:
                self.showChooseButtonDialog()

        else:
            self.showChooseFileDialog()
Esempio n. 2
0
    def sliderValue(self):
        if self.W_F == 'w':

            self.chosenWeightNumber = self.horizontalSliderPatch.value()
            self.overlay = Overlay(
                self.centralWidget())  # self.scrollArea self.centralWidget()
            self.overlay.setGeometry(QtCore.QRect(700, 350, 171, 141))
            self.overlay.show()

            from loadf import loadImage_weights_plot_3D
            self.wyPlot.setDisabled(True)
            self.newW3D = loadImage_weights_plot_3D(
                self.matplotlibwidget_static, self.w, self.chosenWeightNumber,
                self.totalWeights, self.totalWeightsSlices)
            self.newW3D.trigger.connect(self.loadEnd)
            self.newW3D.start()

            # self.matplotlibwidget_static.mpl.weights_plot_3D(self.w, self.chosenWeightNumber, self.totalWeights,self.totalWeightsSlices)
        elif self.W_F == 'f':

            if self.modelDimension == '2D':
                self.chosenPatchNumber = self.horizontalSliderPatch.value()
                self.overlay = Overlay(self.centralWidget(
                ))  # self.scrollArea self.centralWidget()
                self.overlay.setGeometry(QtCore.QRect(700, 350, 171, 141))
                self.overlay.show()

                from loadf import loadImage_features_plot
                self.wyPlot.setDisabled(True)
                self.newf = loadImage_features_plot(
                    self.matplotlibwidget_static, self.chosenPatchNumber)
                self.newf.trigger.connect(self.loadEnd)
                self.newf.start()
                # self.matplotlibwidget_static.mpl.features_plot(self.chosenPatchNumber)
            elif self.modelDimension == '3D':

                self.chosenPatchNumber = self.horizontalSliderPatch.value()
                self.chosenPatchSliceNumber = self.horizontalSliderSlice.value(
                )
                self.overlay = Overlay(self.centralWidget(
                ))  # self.scrollArea self.centralWidget()
                self.overlay.setGeometry(QtCore.QRect(700, 350, 171, 141))
                self.overlay.show()

                from loadf import loadImage_features_plot_3D
                self.wyPlot.setDisabled(True)
                self.newf = loadImage_features_plot_3D(
                    self.matplotlibwidget_static, self.chosenPatchNumber,
                    self.chosenPatchSliceNumber)
                self.newf.trigger.connect(self.loadEnd)
                self.newf.start()
                # self.matplotlibwidget_static.mpl.features_plot_3D(self.chosenPatchNumber,self.chosenPatchSliceNumber)
        elif self.W_F == 's':

            self.chosenSSNumber = self.horizontalSliderPatch.value()
            self.overlay = Overlay(
                self.centralWidget())  # self.scrollArea self.centralWidget()
            self.overlay.setGeometry(QtCore.QRect(700, 350, 171, 141))
            self.overlay.show()

            from loadf import loadImage_subset_selection_plot
            self.wyPlot.setDisabled(True)
            self.newf = loadImage_subset_selection_plot(
                self.matplotlibwidget_static, self.chosenSSNumber)
            self.newf.trigger.connect(self.loadEnd)
            self.newf.start()
            # self.matplotlibwidget_static.mpl.subset_selection_plot(self.chosenSSNumber)

        else:
            pass