traincv 0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. traincv/__init__.py +1 -0
  2. traincv/app.py +40 -0
  3. traincv/common/__init__.py +0 -0
  4. traincv/common/gpu_util.py +532 -0
  5. traincv/configs/__init__.py +0 -0
  6. traincv/configs/labelme_config.yaml +115 -0
  7. traincv/configs/yolov5_data.yaml +8 -0
  8. traincv/models/__init__.py +0 -0
  9. traincv/models/project.py +25 -0
  10. traincv/models/tablemodel.py +94 -0
  11. traincv/resources/__init__.py +0 -0
  12. traincv/resources/resources.py +40 -0
  13. traincv/services/__init__.py +0 -0
  14. traincv/services/system_monitor.py +49 -0
  15. traincv/services/yolov5.py +174 -0
  16. traincv/storage.py +3 -0
  17. traincv/trainer/__init__.py +0 -0
  18. traincv/trainer/core/__init__.py +0 -0
  19. traincv/trainer/core/constants.py +0 -0
  20. traincv/trainer/core/exceptions.py +2 -0
  21. traincv/trainer/core/project.py +104 -0
  22. traincv/trainer/core/tasks.py +12 -0
  23. traincv/trainer/data/__init__.py +0 -0
  24. traincv/trainer/data/data_preparation.py +261 -0
  25. traincv/trainer/data/data_subset_preparator.py +89 -0
  26. traincv/views/__init__.py +0 -0
  27. traincv/views/common/__init__.py +0 -0
  28. traincv/views/common/tableview.py +48 -0
  29. traincv/views/common/toaster.py +260 -0
  30. traincv/views/labeling/__init__.py +0 -0
  31. traincv/views/labeling/labeling_wrapper.py +22 -0
  32. traincv/views/labeling/labelme/__init__.py +12 -0
  33. traincv/views/labeling/labelme/__main__.py +192 -0
  34. traincv/views/labeling/labelme/config.py +82 -0
  35. traincv/views/labeling/labelme/icons/app.icns +0 -0
  36. traincv/views/labeling/labelme/icons/app.png +0 -0
  37. traincv/views/labeling/labelme/icons/app.svg +30 -0
  38. traincv/views/labeling/labelme/icons/brain.png +0 -0
  39. traincv/views/labeling/labelme/icons/cancel.png +0 -0
  40. traincv/views/labeling/labelme/icons/cartesian.png +0 -0
  41. traincv/views/labeling/labelme/icons/circle.png +0 -0
  42. traincv/views/labeling/labelme/icons/color-line.png +0 -0
  43. traincv/views/labeling/labelme/icons/color.png +0 -0
  44. traincv/views/labeling/labelme/icons/color_line.png +0 -0
  45. traincv/views/labeling/labelme/icons/copy.png +0 -0
  46. traincv/views/labeling/labelme/icons/delete.png +0 -0
  47. traincv/views/labeling/labelme/icons/done.png +0 -0
  48. traincv/views/labeling/labelme/icons/done.svg +400 -0
  49. traincv/views/labeling/labelme/icons/edit.png +0 -0
  50. traincv/views/labeling/labelme/icons/expert.png +0 -0
  51. traincv/views/labeling/labelme/icons/expert1.png +0 -0
  52. traincv/views/labeling/labelme/icons/expert2.png +0 -0
  53. traincv/views/labeling/labelme/icons/eye.png +0 -0
  54. traincv/views/labeling/labelme/icons/feBlend-icon.png +0 -0
  55. traincv/views/labeling/labelme/icons/file.png +0 -0
  56. traincv/views/labeling/labelme/icons/fit-width.png +0 -0
  57. traincv/views/labeling/labelme/icons/fit-window.png +0 -0
  58. traincv/views/labeling/labelme/icons/fit.png +0 -0
  59. traincv/views/labeling/labelme/icons/format_createml.png +0 -0
  60. traincv/views/labeling/labelme/icons/format_voc.png +0 -0
  61. traincv/views/labeling/labelme/icons/format_yolo.png +0 -0
  62. traincv/views/labeling/labelme/icons/help.png +0 -0
  63. traincv/views/labeling/labelme/icons/icon.icns +0 -0
  64. traincv/views/labeling/labelme/icons/icon.ico +0 -0
  65. traincv/views/labeling/labelme/icons/icon.png +0 -0
  66. traincv/views/labeling/labelme/icons/labels.png +0 -0
  67. traincv/views/labeling/labelme/icons/labels.svg +819 -0
  68. traincv/views/labeling/labelme/icons/line-strip.png +0 -0
  69. traincv/views/labeling/labelme/icons/line.png +0 -0
  70. traincv/views/labeling/labelme/icons/new.png +0 -0
  71. traincv/views/labeling/labelme/icons/next.png +0 -0
  72. traincv/views/labeling/labelme/icons/objects.png +0 -0
  73. traincv/views/labeling/labelme/icons/open.png +0 -0
  74. traincv/views/labeling/labelme/icons/paste.png +0 -0
  75. traincv/views/labeling/labelme/icons/point.png +0 -0
  76. traincv/views/labeling/labelme/icons/polygon.png +0 -0
  77. traincv/views/labeling/labelme/icons/prev.png +0 -0
  78. traincv/views/labeling/labelme/icons/quit.png +0 -0
  79. traincv/views/labeling/labelme/icons/rectangle.png +0 -0
  80. traincv/views/labeling/labelme/icons/resetall.png +0 -0
  81. traincv/views/labeling/labelme/icons/save-as.png +0 -0
  82. traincv/views/labeling/labelme/icons/save.png +0 -0
  83. traincv/views/labeling/labelme/icons/undo-cross.png +0 -0
  84. traincv/views/labeling/labelme/icons/undo.png +0 -0
  85. traincv/views/labeling/labelme/icons/upload_brain.png +0 -0
  86. traincv/views/labeling/labelme/icons/verify.png +0 -0
  87. traincv/views/labeling/labelme/icons/zoom-in.png +0 -0
  88. traincv/views/labeling/labelme/icons/zoom-out.png +0 -0
  89. traincv/views/labeling/labelme/icons/zoom.png +0 -0
  90. traincv/views/labeling/labelme/label_file.py +202 -0
  91. traincv/views/labeling/labelme/labelme_widget.py +2301 -0
  92. traincv/views/labeling/labelme/logger.py +69 -0
  93. traincv/views/labeling/labelme/shape.py +321 -0
  94. traincv/views/labeling/labelme/testing.py +35 -0
  95. traincv/views/labeling/labelme/tracker.py +81 -0
  96. traincv/views/labeling/labelme/utils/__init__.py +10 -0
  97. traincv/views/labeling/labelme/utils/_io.py +23 -0
  98. traincv/views/labeling/labelme/utils/image.py +100 -0
  99. traincv/views/labeling/labelme/utils/opencv.py +31 -0
  100. traincv/views/labeling/labelme/utils/qt.py +98 -0
  101. traincv/views/labeling/labelme/utils/shape.py +109 -0
  102. traincv/views/labeling/labelme/widgets/__init__.py +11 -0
  103. traincv/views/labeling/labelme/widgets/brightness_contrast_dialog.py +50 -0
  104. traincv/views/labeling/labelme/widgets/canvas.py +1139 -0
  105. traincv/views/labeling/labelme/widgets/color_dialog.py +31 -0
  106. traincv/views/labeling/labelme/widgets/escapable_qlist_widget.py +11 -0
  107. traincv/views/labeling/labelme/widgets/file_dialog_preview.py +75 -0
  108. traincv/views/labeling/labelme/widgets/label_dialog.py +233 -0
  109. traincv/views/labeling/labelme/widgets/label_list_widget.py +186 -0
  110. traincv/views/labeling/labelme/widgets/toolbar.py +34 -0
  111. traincv/views/labeling/labelme/widgets/unique_label_qlist_widget.py +44 -0
  112. traincv/views/labeling/labelme/widgets/zoom_widget.py +20 -0
  113. traincv/views/maintabs.py +32 -0
  114. traincv/views/mainwindow.py +44 -0
  115. traincv/views/workspace/__init__.py +4 -0
  116. traincv/views/workspace/data_preparation/__init__.py +0 -0
  117. traincv/views/workspace/data_preparation/data_preparation.py +43 -0
  118. traincv/views/workspace/data_preparation/data_preparation.ui +377 -0
  119. traincv/views/workspace/data_preparation/data_subset_table.py +193 -0
  120. traincv/views/workspace/data_preparation/data_subset_table.ui +244 -0
  121. traincv/views/workspace/evaluation/__init__.py +0 -0
  122. traincv/views/workspace/evaluation/evaluation.py +154 -0
  123. traincv/views/workspace/evaluation/evaluation.ui +210 -0
  124. traincv/views/workspace/experiment_wizard.py +84 -0
  125. traincv/views/workspace/export/__init__.py +0 -0
  126. traincv/views/workspace/export/export.py +20 -0
  127. traincv/views/workspace/export/export.ui +104 -0
  128. traincv/views/workspace/project_dialog/__init__.py +0 -0
  129. traincv/views/workspace/project_dialog/project_dialog.py +45 -0
  130. traincv/views/workspace/project_dialog/project_dialog.ui +130 -0
  131. traincv/views/workspace/sidebar/__init__.py +0 -0
  132. traincv/views/workspace/sidebar/experiment_table_model.py +25 -0
  133. traincv/views/workspace/sidebar/sidebar.py +66 -0
  134. traincv/views/workspace/sidebar/sidebar.ui +209 -0
  135. traincv/views/workspace/training/__init__.py +0 -0
  136. traincv/views/workspace/training/training.py +61 -0
  137. traincv/views/workspace/training/training.ui +386 -0
  138. traincv/views/workspace/training/training_state.py +7 -0
  139. traincv/views/workspace/workspace.py +34 -0
  140. traincv/views/workspace/workspace_wrapper.py +23 -0
  141. traincv-0.0.1.dist-info/LICENSE.md +675 -0
  142. traincv-0.0.1.dist-info/METADATA +122 -0
  143. traincv-0.0.1.dist-info/RECORD +146 -0
  144. traincv-0.0.1.dist-info/WHEEL +5 -0
  145. traincv-0.0.1.dist-info/entry_points.txt +3 -0
  146. traincv-0.0.1.dist-info/top_level.txt +1 -0
traincv/__init__.py ADDED
@@ -0,0 +1 @@
1
+ __version__ = "0.0.1"
traincv/app.py ADDED
@@ -0,0 +1,40 @@
1
+ import os
2
+ import sys
3
+
4
+ import pyqtgraph as pg
5
+ from PyQt5 import QtCore, QtWidgets
6
+ from PyQt5.QtWidgets import QApplication
7
+
8
+ sys.path.append(os.path.dirname(os.path.abspath(__file__)))
9
+ sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
10
+ sys.path.append(".")
11
+
12
+ from traincv.resources.resources import *
13
+ from traincv.views.mainwindow import MainWindow
14
+
15
+
16
+ def main():
17
+ # Enable scaling for high dpi screens
18
+ QtWidgets.QApplication.setAttribute(
19
+ QtCore.Qt.AA_EnableHighDpiScaling, True
20
+ ) # enable highdpi scaling
21
+ QtWidgets.QApplication.setAttribute(
22
+ QtCore.Qt.AA_UseHighDpiPixmaps, True
23
+ ) # use highdpi icons
24
+
25
+ # Setup pyqtgraph default bg/fg colors
26
+ pg.setConfigOption("background", "w")
27
+ pg.setConfigOption("foreground", "k")
28
+
29
+ QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_ShareOpenGLContexts)
30
+ app = QApplication(sys.argv)
31
+ app.processEvents()
32
+
33
+ main_win = MainWindow(app)
34
+
35
+ main_win.show()
36
+ sys.exit(app.exec_())
37
+
38
+
39
+ if __name__ == "__main__":
40
+ main()
File without changes
@@ -0,0 +1,532 @@
1
+ import math
2
+ import os
3
+ import platform
4
+ import random
5
+ import time
6
+ from distutils import spawn
7
+ from subprocess import PIPE, Popen
8
+
9
+
10
+ class GPU:
11
+ def __init__(
12
+ self,
13
+ id,
14
+ uuid,
15
+ load,
16
+ memory_total,
17
+ memory_used,
18
+ memory_free,
19
+ driver,
20
+ gpu_name,
21
+ serial,
22
+ display_mode,
23
+ display_active,
24
+ temp_gpu,
25
+ ):
26
+ self.id = id
27
+ self.uuid = uuid
28
+ self.load = load
29
+ self.memory_util = float(memory_used) / float(memory_total)
30
+ self.memory_total = memory_total
31
+ self.memory_used = memory_used
32
+ self.memory_free = memory_free
33
+ self.driver = driver
34
+ self.name = gpu_name
35
+ self.serial = serial
36
+ self.display_mode = display_mode
37
+ self.display_active = display_active
38
+ self.temperature = temp_gpu
39
+
40
+ def to_dict(self):
41
+ return {
42
+ "id": self.id,
43
+ "uuid": self.uuid,
44
+ "load": self.load,
45
+ "memory_util": self.memory_util,
46
+ "memory_total": self.memory_total,
47
+ "memory_used": self.memory_used,
48
+ "memory_free": self.memory_free,
49
+ "driver": self.driver,
50
+ "name": self.name,
51
+ "serial": self.serial,
52
+ "display_mode": self.display_mode,
53
+ "display_active": self.display_active,
54
+ "temperature": self.temperature,
55
+ }
56
+
57
+
58
+ def safe_float_cast(str_number):
59
+ try:
60
+ number = float(str_number)
61
+ except ValueError:
62
+ number = float("nan")
63
+ return number
64
+
65
+
66
+ def get_gp_us():
67
+ if platform.system() == "Windows":
68
+ # If the platform is Windows and nvidia-smi
69
+ # could not be found from the environment path,
70
+ # try to find it from system drive with default installation path
71
+ nvidia_smi = spawn.find_executable("nvidia-smi")
72
+ if nvidia_smi is None:
73
+ nvidia_smi = (
74
+ f"{os.environ['systemdrive']}\\Program Files\\"
75
+ "NVIDIA Corporation\\NVSMI\\nvidia-smi.exe"
76
+ )
77
+ else:
78
+ nvidia_smi = "nvidia-smi"
79
+
80
+ # Get ID, processing and memory utilization for all gp_us
81
+ try:
82
+ with Popen(
83
+ [
84
+ nvidia_smi,
85
+ "--query-gpu=index,uuid,utilization.gpu,memory.total,memory.used,memory.free,"
86
+ "driver_version,name,gpu_serial,display_active,display_mode,temperature.gpu",
87
+ "--format=csv,noheader,nounits",
88
+ ],
89
+ stdout=PIPE,
90
+ ) as p:
91
+ stdout, _ = p.communicate()
92
+ except BaseException:
93
+ return []
94
+ output = stdout.decode("UTF-8")
95
+ lines = output.split(os.linesep)
96
+ num_devices = len(lines) - 1
97
+ gp_us = []
98
+ for g in range(num_devices):
99
+ line = lines[g]
100
+ vals = line.split(", ")
101
+ for i in range(12):
102
+ if i == 0:
103
+ try:
104
+ device_ids = int(vals[i])
105
+ except BaseException:
106
+ return []
107
+ elif i == 1:
108
+ uuid = vals[i]
109
+ elif i == 2:
110
+ gpu_util = safe_float_cast(vals[i]) / 100
111
+ elif i == 3:
112
+ mem_total = safe_float_cast(vals[i])
113
+ elif i == 4:
114
+ mem_used = safe_float_cast(vals[i])
115
+ elif i == 5:
116
+ mem_free = safe_float_cast(vals[i])
117
+ elif i == 6:
118
+ driver = vals[i]
119
+ elif i == 7:
120
+ gpu_name = vals[i]
121
+ elif i == 8:
122
+ serial = vals[i]
123
+ elif i == 9:
124
+ display_active = vals[i]
125
+ elif i == 10:
126
+ display_mode = vals[i]
127
+ elif i == 11:
128
+ temp_gpu = safe_float_cast(vals[i])
129
+ gp_us.append(
130
+ GPU(
131
+ device_ids,
132
+ uuid,
133
+ gpu_util,
134
+ mem_total,
135
+ mem_used,
136
+ mem_free,
137
+ driver,
138
+ gpu_name,
139
+ serial,
140
+ display_mode,
141
+ display_active,
142
+ temp_gpu,
143
+ )
144
+ )
145
+ return gp_us # (deviceIds, gpuUtil, memUtil)
146
+
147
+
148
+ def get_available(
149
+ order="first",
150
+ limit=1,
151
+ max_load=0.5,
152
+ max_memory=0.5,
153
+ memory_free=0,
154
+ include_nan=False,
155
+ exclude_id=None,
156
+ exclude_uuid=None,
157
+ ):
158
+
159
+ if exclude_id is None:
160
+ exclude_id = []
161
+ if exclude_uuid is None:
162
+ exclude_uuid = []
163
+
164
+ # order = first | last | random | load | memory
165
+ # first --> select the GPU with the lowest ID (DEFAULT)
166
+ # last --> select the GPU with the highest ID
167
+ # random --> select a random available GPU
168
+ # load --> select the GPU with the lowest load
169
+ # memory --> select the GPU with the most memory available
170
+ # limit = 1 (DEFAULT), 2, ..., Inf
171
+ # Limit sets the upper limit for the number of gp_us to return. E.g. if
172
+ # limit = 2, but only one is available, only one is returned.
173
+
174
+ # Get device IDs, load and memory usage
175
+ gp_us = get_gp_us()
176
+
177
+ # Determine, which gp_us are available
178
+ gp_uavailability = get_availability(
179
+ gp_us,
180
+ max_load=max_load,
181
+ max_memory=max_memory,
182
+ memory_free=memory_free,
183
+ include_nan=include_nan,
184
+ exclude_id=exclude_id,
185
+ exclude_uuid=exclude_uuid,
186
+ )
187
+ avail_able_gp_uindex = [
188
+ idx
189
+ for idx in range(0, len(gp_uavailability))
190
+ if gp_uavailability[idx] == 1
191
+ ]
192
+ # Discard unavailable gp_us
193
+ gp_us = [gp_us[g] for g in avail_able_gp_uindex]
194
+
195
+ # Sort available gp_us according to the order argument
196
+ if order == "first":
197
+ gp_us.sort(
198
+ key=lambda x: float("inf") if math.isnan(x.id) else x.id,
199
+ reverse=False,
200
+ )
201
+ elif order == "last":
202
+ gp_us.sort(
203
+ key=lambda x: float("-inf") if math.isnan(x.id) else x.id,
204
+ reverse=True,
205
+ )
206
+ elif order == "random":
207
+ gp_us = [
208
+ gp_us[g] for g in random.sample(range(0, len(gp_us)), len(gp_us))
209
+ ]
210
+ elif order == "load":
211
+ gp_us.sort(
212
+ key=lambda x: float("inf") if math.isnan(x.load) else x.load,
213
+ reverse=False,
214
+ )
215
+ elif order == "memory":
216
+ gp_us.sort(
217
+ key=lambda x: float("inf")
218
+ if math.isnan(x.memory_util)
219
+ else x.memory_util,
220
+ reverse=False,
221
+ )
222
+
223
+ # Extract the number of desired gp_us, but limited to the total number of
224
+ # available gp_us
225
+ gp_us = gp_us[0 : min(limit, len(gp_us))]
226
+
227
+ # Extract the device IDs from the gp_us and return them
228
+ device_ids = [gpu.id for gpu in gp_us]
229
+
230
+ return device_ids
231
+
232
+
233
+ def get_availability(
234
+ gp_us,
235
+ max_load=0.5,
236
+ max_memory=0.5,
237
+ memory_free=0,
238
+ include_nan=False,
239
+ exclude_id=None,
240
+ exclude_uuid=None,
241
+ ):
242
+ if exclude_id is None:
243
+ exclude_id = []
244
+ if exclude_uuid is None:
245
+ exclude_uuid = []
246
+ # Determine, which gp_us are available
247
+ gp_uavailability = [
248
+ 1
249
+ if (gpu.memory_free >= memory_free)
250
+ and (gpu.load < max_load or (include_nan and math.isnan(gpu.load)))
251
+ and (
252
+ gpu.memory_util < max_memory
253
+ or (include_nan and math.isnan(gpu.memory_util))
254
+ )
255
+ and ((gpu.id not in exclude_id) and (gpu.uuid not in exclude_uuid))
256
+ else 0
257
+ for gpu in gp_us
258
+ ]
259
+ return gp_uavailability
260
+
261
+
262
+ def get_first_available(
263
+ order="first",
264
+ max_load=0.5,
265
+ max_memory=0.5,
266
+ attempts=1,
267
+ interval=900,
268
+ verbose=False,
269
+ include_nan=False,
270
+ exclude_id=None,
271
+ exclude_uuid=None,
272
+ ):
273
+
274
+ if exclude_id is None:
275
+ exclude_id = []
276
+ if exclude_uuid is None:
277
+ exclude_uuid = []
278
+
279
+ for i in range(attempts):
280
+ if verbose:
281
+ print(
282
+ "Attempting ("
283
+ + str(i + 1)
284
+ + "/"
285
+ + str(attempts)
286
+ + ") to locate available GPU."
287
+ )
288
+ # Get first available GPU
289
+ available = get_available(
290
+ order=order,
291
+ limit=1,
292
+ max_load=max_load,
293
+ max_memory=max_memory,
294
+ include_nan=include_nan,
295
+ exclude_id=exclude_id,
296
+ exclude_uuid=exclude_uuid,
297
+ )
298
+ # If an available GPU was found, break for loop.
299
+ if available:
300
+ if verbose:
301
+ print("GPU " + str(available) + " located!")
302
+ break
303
+ # If this is not the last attempt, sleep for 'interval' seconds
304
+ if i != attempts - 1:
305
+ time.sleep(interval)
306
+ # Check if an GPU was found, or if the attempts simply ran out. Throw
307
+ # error, if no GPU was found
308
+ if not available:
309
+ raise RuntimeError(
310
+ "Could not find an available GPU after "
311
+ + str(attempts)
312
+ + " attempts with "
313
+ + str(interval)
314
+ + " seconds interval."
315
+ )
316
+
317
+ # Return found GPU
318
+ return available
319
+
320
+
321
+ def show_utilization(show_all=False, attr_list=None, use_old_code=False):
322
+ gp_us = get_gp_us()
323
+ if show_all:
324
+ if use_old_code:
325
+ print(
326
+ " ID | Name | Serial | UUID || GPU util. | Memory util. ||"
327
+ " Memory total | Memory used | Memory free || Display mode |"
328
+ " Display active |"
329
+ )
330
+ for gpu in gp_us:
331
+ print(
332
+ " {0:2d} | {1:s} | {2:s} | {3:s} || {4:3.0f}% | {5:3.0f}%"
333
+ " || {6:.0f}MB | {7:.0f}MB | {8:.0f}MB || {9:s} | {10:s}"
334
+ .format(
335
+ gpu.id,
336
+ gpu.name,
337
+ gpu.serial,
338
+ gpu.uuid,
339
+ gpu.load * 100,
340
+ gpu.memory_util * 100,
341
+ gpu.memory_total,
342
+ gpu.memory_used,
343
+ gpu.memory_free,
344
+ gpu.display_mode,
345
+ gpu.display_active,
346
+ )
347
+ )
348
+ else:
349
+ attr_list = [
350
+ [
351
+ {"attr": "id", "name": "ID"},
352
+ {"attr": "name", "name": "Name"},
353
+ {"attr": "serial", "name": "Serial"},
354
+ {"attr": "uuid", "name": "UUID"},
355
+ ],
356
+ [
357
+ {
358
+ "attr": "temperature",
359
+ "name": "GPU temperature",
360
+ "suffix": "C",
361
+ "transform": lambda x: x,
362
+ "precision": 0,
363
+ },
364
+ {
365
+ "attr": "load",
366
+ "name": "GPU util.",
367
+ "suffix": "%",
368
+ "transform": lambda x: x * 100,
369
+ "precision": 0,
370
+ },
371
+ {
372
+ "attr": "memory_util",
373
+ "name": "Memory util.",
374
+ "suffix": "%",
375
+ "transform": lambda x: x * 100,
376
+ "precision": 0,
377
+ },
378
+ ],
379
+ [
380
+ {
381
+ "attr": "memory_total",
382
+ "name": "Memory total",
383
+ "suffix": "MB",
384
+ "precision": 0,
385
+ },
386
+ {
387
+ "attr": "memory_used",
388
+ "name": "Memory used",
389
+ "suffix": "MB",
390
+ "precision": 0,
391
+ },
392
+ {
393
+ "attr": "memory_free",
394
+ "name": "Memory free",
395
+ "suffix": "MB",
396
+ "precision": 0,
397
+ },
398
+ ],
399
+ [
400
+ {"attr": "display_mode", "name": "Display mode"},
401
+ {"attr": "display_active", "name": "Display active"},
402
+ ],
403
+ ]
404
+
405
+ else:
406
+ if use_old_code:
407
+ print(" ID GPU MEM")
408
+ print("--------------")
409
+ for gpu in gp_us:
410
+ print(
411
+ " {0:2d} {1:3.0f}% {2:3.0f}%".format(
412
+ gpu.id, gpu.load * 100, gpu.memory_util * 100
413
+ )
414
+ )
415
+ elif attr_list is None:
416
+ # if `attr_list` was not specified, use the default one
417
+ attr_list = [
418
+ [
419
+ {"attr": "id", "name": "ID"},
420
+ {
421
+ "attr": "load",
422
+ "name": "GPU",
423
+ "suffix": "%",
424
+ "transform": lambda x: x * 100,
425
+ "precision": 0,
426
+ },
427
+ {
428
+ "attr": "memory_util",
429
+ "name": "MEM",
430
+ "suffix": "%",
431
+ "transform": lambda x: x * 100,
432
+ "precision": 0,
433
+ },
434
+ ],
435
+ ]
436
+
437
+ if not use_old_code:
438
+ if attr_list is not None:
439
+ header_string = ""
440
+ gp_ustrings = [""] * len(gp_us)
441
+ for attr_group in attr_list:
442
+ for attr_dict in attr_group:
443
+ header_string = (
444
+ header_string + "| " + attr_dict["name"] + " "
445
+ )
446
+ header_width = len(attr_dict["name"])
447
+ min_width = len(attr_dict["name"])
448
+
449
+ attr_precision = (
450
+ "." + str(attr_dict["precision"])
451
+ if ("precision" in attr_dict)
452
+ else ""
453
+ )
454
+ attr_suffix = (
455
+ str(attr_dict["suffix"])
456
+ if ("suffix" in attr_dict)
457
+ else ""
458
+ )
459
+ attr_transform = (
460
+ attr_dict["transform"]
461
+ if ("transform" in attr_dict)
462
+ else lambda x: x
463
+ )
464
+ for gpu in gp_us:
465
+ attr = getattr(gpu, attr_dict["attr"])
466
+
467
+ attr = attr_transform(attr)
468
+
469
+ if isinstance(attr, float):
470
+ attr_str = ("{0:" + attr_precision + "f}").format(
471
+ attr
472
+ )
473
+ elif isinstance(attr, int):
474
+ attr_str = f"{attr:d}"
475
+ elif isinstance(attr, str):
476
+ attr_str = attr
477
+ else:
478
+ raise TypeError(
479
+ "Unhandled object type ("
480
+ + str(type(attr))
481
+ + ") for attribute '"
482
+ + attr_dict["name"]
483
+ + "'"
484
+ )
485
+
486
+ attr_str += attr_suffix
487
+
488
+ min_width = max(min_width, len(attr_str))
489
+
490
+ header_string += " " * max(0, min_width - header_width)
491
+
492
+ min_width_str = str(min_width - len(attr_suffix))
493
+
494
+ for gpu_idx, gpu in enumerate(gp_us):
495
+ attr = getattr(gpu, attr_dict["attr"])
496
+
497
+ attr = attr_transform(attr)
498
+
499
+ if isinstance(attr, float):
500
+ attr_str = (
501
+ "{0:" + min_width_str + attr_precision + "f}"
502
+ ).format(attr)
503
+ elif isinstance(attr, int):
504
+ attr_str = ("{0:" + min_width_str + "d}").format(
505
+ attr
506
+ )
507
+ elif isinstance(attr, str):
508
+ attr_str = ("{0:" + min_width_str + "s}").format(
509
+ attr
510
+ )
511
+ else:
512
+ raise TypeError(
513
+ "Unhandled object type ("
514
+ + str(type(attr))
515
+ + ") for attribute '"
516
+ + attr_dict["name"]
517
+ + "'"
518
+ )
519
+
520
+ attr_str += attr_suffix
521
+
522
+ gp_ustrings[gpu_idx] += "| " + attr_str + " "
523
+
524
+ header_string = header_string + "|"
525
+ for gpu_idx, gpu in enumerate(gp_us):
526
+ gp_ustrings[gpu_idx] += "|"
527
+
528
+ header_spacing_string = "-" * len(header_string)
529
+ print(header_string)
530
+ print(header_spacing_string)
531
+ for gp_ustring in gp_ustrings:
532
+ print(gp_ustring)
File without changes
@@ -0,0 +1,115 @@
1
+ auto_save: true
2
+ display_label_popup: true
3
+ store_data: false
4
+ keep_prev: false
5
+ keep_prev_scale: false
6
+ keep_prev_brightness: false
7
+ keep_prev_contrast: false
8
+ show_cross_line: true
9
+ show_groups: true
10
+ show_texts: true
11
+ logger_level: info
12
+
13
+ flags: null
14
+ label_flags: null
15
+ labels: null
16
+ file_search: null
17
+ sort_labels: true
18
+ validate_label: null
19
+
20
+ default_shape_color: [0, 255, 0]
21
+ shape_color: auto # null, 'auto', 'manual'
22
+ shift_auto_shape_color: 0
23
+ label_colors: null
24
+
25
+ shape:
26
+ # drawing
27
+ line_color: [0, 255, 0, 128]
28
+ fill_color: [220, 220, 220, 150]
29
+ vertex_fill_color: [0, 255, 0, 255]
30
+ # selecting / hovering
31
+ select_line_color: [255, 255, 255, 255]
32
+ select_fill_color: [0, 255, 0, 155]
33
+ hvertex_fill_color: [255, 255, 255, 255]
34
+ point_size: 8
35
+
36
+ # main
37
+ flag_dock:
38
+ show: true
39
+ closable: false
40
+ movable: false
41
+ floatable: false
42
+ label_dock:
43
+ show: true
44
+ closable: false
45
+ movable: false
46
+ floatable: false
47
+ shape_dock:
48
+ show: true
49
+ closable: false
50
+ movable: false
51
+ floatable: false
52
+ file_dock:
53
+ show: true
54
+ closable: false
55
+ movable: false
56
+ floatable: false
57
+
58
+ # label_dialog
59
+ show_label_text_field: true
60
+ label_completion: startswith
61
+ fit_to_content:
62
+ column: true
63
+ row: false
64
+
65
+ # canvas
66
+ epsilon: 10.0
67
+ canvas:
68
+ # None: do nothing
69
+ # close: close polygon
70
+ double_click: close
71
+ # The max number of edits we can undo
72
+ num_backups: 10
73
+
74
+ shortcuts:
75
+ close: Ctrl+W
76
+ open: Ctrl+O
77
+ open_dir: Ctrl+U
78
+ quit: Ctrl+Q
79
+ save: Ctrl+S
80
+ save_as: Ctrl+Shift+S
81
+ save_to: null
82
+ delete_file: Ctrl+Delete
83
+
84
+ open_next: [D, Ctrl+Shift+D]
85
+ open_prev: [A, Ctrl+Shift+A]
86
+
87
+ zoom_in: [Ctrl++, Ctrl+=]
88
+ zoom_out: Ctrl+-
89
+ zoom_to_original: Ctrl+0
90
+ fit_window: Ctrl+F
91
+ fit_width: Ctrl+Shift+F
92
+
93
+ create_polygon: [P, Ctrl+N]
94
+ create_rectangle: [R, Ctrl+R]
95
+ create_circle: null
96
+ create_line: null
97
+ create_point: null
98
+ create_linestrip: null
99
+ edit_polygon: Ctrl+J
100
+ delete_polygon: Delete
101
+ duplicate_polygon: Ctrl+D
102
+ copy_polygon: Ctrl+C
103
+ paste_polygon: Ctrl+V
104
+ undo: Ctrl+Z
105
+ undo_last_point: Ctrl+Z
106
+ add_point_to_edge: Ctrl+Shift+P
107
+ edit_label: Ctrl+E
108
+ toggle_keep_prev_mode: Ctrl+P
109
+ remove_selected_point: Backspace
110
+ group_selected_shapes: G
111
+ ungroup_selected_shapes: U
112
+
113
+ tracking: T
114
+ load_ai_model: L
115
+ auto_label: I
@@ -0,0 +1,8 @@
1
+ path: # dataset root
2
+ train: # train folder
3
+ val: # val folder
4
+ test: # test folder (optional)
5
+
6
+ # Classes
7
+ nc: 1
8
+ names: [ 'object' ]
File without changes