def buildMenu(self, pos=None): self.nodeMenu = QtGui.QMenu() self.subMenus = [] for section, nodes in library.getNodeTree().items(): menu = QtGui.QMenu(section) #print section self.nodeMenu.addMenu(menu) for name in nodes: act = menu.addAction(name) act.nodeType = name act.pos = pos self.subMenus.append(menu) self.nodeMenu.triggered.connect(self.nodeMenuTriggered) return self.nodeMenu
def buildToolbox(self): self.nodeToolbox = QtGui.QToolBox() for section, nodes in library.getNodeTree().items(): tbwid = QtGui.QWidget() tbl = QtGui.QGridLayout() tbwid.setLayout(tbl) row = 0 col = 0 for name in nodes: itm = QtGui.QPushButton(name) itm.clicked.connect(partial(self.nodeButtonPushed, name)) tbl.addWidget(itm, row, col) col = col + 1 if col > 1: row = row + 1 col = 0 #tbl.addStretch() self.nodeToolbox.addItem(tbwid, section) #self.nodeMenu.triggered.connect(self.nodeMenuTriggered) self.nodeToolbox.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) return self.nodeToolbox
from pyqtgraph import configfile from pyqtgraph.flowchart.Flowchart import Flowchart from caffe.proto.caffe_pb2 import NetParameter as NetProto import toposort from pyqtgraph.flowchart.library import getNodeTree from caffeViz.netTerminal import NetConnectionItem, NetTerminal from caffeViz.protobufUtils import parsePrototxt displayNodes = tuple(getNodeTree()['Display'].values()) from pyqtgraph.widgets.FileDialog import FileDialog from caffeViz.nodes.LayerNodes import LayerNode __author__ = 'ellery' from pyqtgraph.Qt import QtGui, QtCore import caffe class NetFlowchart(Flowchart): """An extension of pyqtgraph's flowchart for Caffe-based Neural Nets""" sigDisplayNodeAdded = QtCore.Signal(object) # node def __init__(self, prototxt=None, weights=None): """ A flowchart that enables visualizing, editing, and running a caffe neural network model :param prototxt: string
from pyqtgraph.widgets.FileDialog import FileDialog import pyqtgraph as pg from pyqtgraph import dockarea from pyqtgraph import QtCore, QtGui from pyqtgraph.flowchart.library import getNodeTree from caffeViz.views import MainViewTemplate as MView from caffeViz.views import DisplayControlWidgetTemplate as DispCtrl from caffeViz.flowcharts import NetFlowchart from caffeViz.nodes.SolverNode import SolverNode __author__ = "ellery" displayNodes = tuple(getNodeTree()["Display"].values()) class MainView(QtGui.QMainWindow): """The main view of the application""" def __init__(self, modelFile=None, weightsFile=None, solverFile=None, directory=None): """ The top-level GUI object, containing three main tabs: Configure: for graphically editing a network backed by a caffe prototxt file Train: for monitoring the training process and plotting the accuracies Test: for visualizing the activations at different points in a (hopefully) trained network :param modelFile: str The .prototxt file defining the network architecture :param weightsFile: str The .caffemodel file containing the learned network weights :param solverFile: str The .prototxt file defining the solver parameters