This repository has been archived by the owner on Jan 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
/
__init__.py
194 lines (169 loc) · 5.84 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
__author__ = 'H'
bl_info = {
'name': 'Caffe-Gui-Tool',
'author': 'Hugh Tomkins',
'location': 'Node view - Properties panel',
'category': 'Node View'
}
# To support reload properly, try to access a package var,
# # if it's there, reload everything
if "bpy" in locals():
import imp
imp.reload(IOwriteprototxt)
imp.reload(IOcexp)
imp.reload(CGTNodes)
imp.reload(IOloadprototxt)
imp.reload(CGTArrangeHelper)
imp.reload(CGTGraph)
print("Reloaded multifiles")
else:
from . import IOwriteprototxt, CGTNodes, IOloadprototxt, CGTArrangeHelper, CGTGraph, IOcexp
print("Imported multifiles")
import bpy
import random
from bpy.props import *
def getactivefcurve():
ncurves = 0
for object in bpy.context.selected_objects:
if object.animation_data:
if object.animation_data.action:
for curve in object.animation_data.action.fcurves.items():
if curve[1].select:
ncurves += 1
activeobject = object
activecurve = curve[1]
if ncurves == 1:
return activecurve, activeobject
elif ncurves == 0:
return None, None
else:
return False, False
def initSceneProperties():
bpy.types.Scene.traintest = bpy.props.StringProperty(
name="Train Test Prototxt",
default="",
description="Get the path to the data",
subtype='FILE_PATH'
)
bpy.types.Scene.solver = bpy.props.StringProperty(
name="Solver Prototxt",
default="",
description="Get the path to the data",
subtype='FILE_PATH'
)
bpy.types.Scene.deploy = bpy.props.StringProperty(
name="Deploy (optional) Prototxt",
default="",
description="Get the path to the data",
subtype='FILE_PATH'
)
bpy.types.Scene.savetempdata = bpy.props.StringProperty(
name="Log folder",
default="",
description="Folder in which to store saved graphs and log data",
subtype='DIR_PATH'
)
bpy.types.Scene.loadtempdata = bpy.props.StringProperty(
name="Log file to Load",
default="",
description="File to load tree and curve from",
subtype='FILE_PATH'
)
bpy.types.Scene.comment = bpy.props.StringProperty(
name="Comment",
default="",
description="Add a comment that helps identify the current experiment"
)
bpy.types.Scene.filecomment = bpy.props.StringProperty(
name="Filename",
default="",
description="Add a string to beginning of filename to describe experiment"
)
bpy.types.Scene.loadtree = bpy.props.BoolProperty(
name="Load Node tree",
default=1,
description="Load the node tree from .cexp"
)
bpy.types.Scene.loadloss = bpy.props.BoolProperty(
name="Load Loss graphs",
default=1,
description="Load the loss data from .cexp"
)
bpy.types.Scene.donetraining = bpy.props.IntProperty(default=1)
return
initSceneProperties()
class LoadDialogPanel(bpy.types.Panel):
bl_label = "Load Prototxt"
bl_space_type = "NODE_EDITOR"
bl_region_type = "UI"
def draw(self, context):
scn = context.scene
self.layout.prop(scn, "traintest")
self.layout.prop(scn, "solver")
self.layout.prop(scn, "deploy")
self.layout.operator("nodes.load_solver")
class RunDialogPanel(bpy.types.Panel):
bl_label = "Run Caffe"
bl_space_type = "NODE_EDITOR"
bl_region_type = "UI"
def draw(self, context):
scn = bpy.context.scene
self.layout.operator("nodes.make_solver")
self.layout.prop(scn, "savetempdata")
self.layout.prop(scn, "filecomment")
self.layout.prop(scn, "comment")
self.layout.operator("nodes.run_solver")
self.layout.operator("nodes.cancel_solver")
class GraphInfoPanel(bpy.types.Panel):
bl_label = "Selected loss plot"
bl_space_type = "GRAPH_EDITOR"
bl_region_type = "UI"
def draw(self, context):
activecurve, activeobject = getactivefcurve()
if activecurve == None:
self.layout.label("No curve selected")
elif not activecurve:
self.layout.label("Multiple curves selected")
self.layout.label("Select a single curve to view comments")
else:
try:
self.layout.label(activeobject["comment"])
except KeyError:
self.layout.label("No comment")
self.layout.operator("nodes.load_tree_from_curve")
if activeobject["originaltree"] != '':
self.layout.label("Original tree loaded to:")
self.layout.label(activeobject["originaltree"])
class CexpLoadPanel(bpy.types.Panel):
bl_label = "Load experiment"
bl_space_type = "NODE_EDITOR"
bl_region_type = "UI"
def draw(self, context):
scn = context.scene
self.layout.prop(scn, "loadtempdata")
self.layout.prop(scn, "loadtree")
self.layout.prop(scn, "loadloss")
self.layout.operator("nodes.load_trained_solver")
def register():
bpy.utils.register_class(RunDialogPanel)
bpy.utils.register_class(LoadDialogPanel)
bpy.utils.register_class(CexpLoadPanel)
bpy.utils.register_class(GraphInfoPanel)
# bpy.utils.register_module(__name__)
CGTArrangeHelper.register()
CGTGraph.register()
IOwriteprototxt.register()
CGTNodes.register()
IOloadprototxt.register()
IOcexp.register()
def unregister():
bpy.utils.unregister_class(RunDialogPanel)
bpy.utils.unregister_class(LoadDialogPanel)
bpy.utils.unregister_class(CexpLoadPanel)
bpy.utils.unregister_class(GraphInfoPanel)
CGTArrangeHelper.unregister()
CGTGraph.unregister()
IOwriteprototxt.unregister()
CGTNodes.unregister()
IOcexp.unregister()
# bpy.utils.unregister_module(__name__)