Skip to content

Commit 8a7ed76

Browse files
committed
- 为视频分割功能添加了进度条
1 parent b35a0f6 commit 8a7ed76

File tree

3 files changed

+55
-12
lines changed

3 files changed

+55
-12
lines changed

ISAT/segment_any/model_zoo.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
'https://www.modelscope.cn/api/v1/models/yatengLG/ISAT_with_segment_anything_checkpoints/repo?Revision=master&FilePath=checkpoints/sam2_hiera_large.pt'
120120
],
121121
'memory': '4000M',
122-
'bf16_memory': '2500M',
122+
'bf16_memory': '2800M',
123123
'params': '900M'
124124
},
125125
'sam2_hiera_base_plus.pt':
@@ -128,8 +128,8 @@
128128
'https://huggingface.co/yatengLG/ISAT_with_segment_anything_checkpoints/resolve/main/sam2_hiera_base_plus.pt',
129129
'https://www.modelscope.cn/api/v1/models/yatengLG/ISAT_with_segment_anything_checkpoints/repo?Revision=master&FilePath=checkpoints/sam2_hiera_base_plus.pt'
130130
],
131-
'memory': '4000M',
132-
'bf16_memory': '2000M',
131+
'memory': '2800M',
132+
'bf16_memory': '2200M',
133133
'params': '324M'
134134
},
135135
'sam2_hiera_small.pt':
@@ -138,8 +138,8 @@
138138
'https://huggingface.co/yatengLG/ISAT_with_segment_anything_checkpoints/resolve/main/sam2_hiera_small.pt',
139139
'https://www.modelscope.cn/api/v1/models/yatengLG/ISAT_with_segment_anything_checkpoints/repo?Revision=master&FilePath=checkpoints/sam2_hiera_small.pt'
140140
],
141-
'memory': '3000M',
142-
'bf16_memory': '1500M',
141+
'memory': '2500M',
142+
'bf16_memory': '1800M',
143143
'params': '185M'
144144
},
145145
'sam2_hiera_tiny.pt':
@@ -148,8 +148,8 @@
148148
'https://huggingface.co/yatengLG/ISAT_with_segment_anything_checkpoints/resolve/main/sam2_hiera_tiny.pt',
149149
'https://www.modelscope.cn/api/v1/models/yatengLG/ISAT_with_segment_anything_checkpoints/repo?Revision=master&FilePath=checkpoints/sam2_hiera_tiny.pt'
150150
],
151-
'memory': '2400M',
152-
'bf16_memory': '1200M',
151+
'memory': '2200M',
152+
'bf16_memory': '1500M',
153153
'params': '156M'
154154
},
155155
}

ISAT/widgets/mainwindow.py

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,26 @@
3737
from skimage.draw.draw import polygon
3838

3939

40+
class QtBoxStyleProgressBar(QtWidgets.QProgressBar):
41+
# copy from qtbox
42+
def __init__(self):
43+
super(QtBoxStyleProgressBar, self).__init__()
44+
self.setTextVisible(False)
45+
self.setStyleSheet("""
46+
QProgressBar {
47+
border: 2px solid #888783;
48+
border-radius: 5px;
49+
}
50+
51+
QProgressBar::chunk {
52+
background-color: #74d65f;
53+
border-radius: 2px;
54+
width: 9px;
55+
margin: 0.5px;
56+
}
57+
""")
58+
59+
4060
def calculate_area(points):
4161
area = 0
4262
num_points = len(points)
@@ -146,6 +166,11 @@ def run(self):
146166
print('self.start_frame_idx: ', self.start_frame_idx)
147167
print('self.max_frame_num_to_track: ', self.max_frame_num_to_track)
148168

169+
if self.max_frame_num_to_track is not None:
170+
total = self.max_frame_num_to_track
171+
else:
172+
total = len(self.mainwindow.files_list) - self.start_frame_idx + 1
173+
149174
with torch.inference_mode(), torch.autocast(self.mainwindow.segany_video.device,
150175
dtype=self.mainwindow.segany_video.model_dtype):
151176

@@ -194,7 +219,7 @@ def run(self):
194219
group_object_dict[group]['mask'] = group_object_dict[group]['mask'] + mask
195220

196221
if len(group_object_dict) < 1:
197-
self.tag.emit(0, self.max_frame_num_to_track, True, True, 'Please label objects before video segment.')
222+
self.tag.emit(0, total, True, True, 'Please label objects before video segment.')
198223
return
199224
try:
200225
for group, object_dict in group_object_dict.items():
@@ -274,12 +299,12 @@ def run(self):
274299

275300
annotation.objects = objects
276301
annotation.save_annotation()
277-
self.tag.emit(index, self.max_frame_num_to_track, False, False, '')
302+
self.tag.emit(index, total, False, False, '')
278303

279-
self.tag.emit(index, self.max_frame_num_to_track, True, False, '')
304+
self.tag.emit(index, total, True, False, '')
280305

281306
except Exception as e:
282-
self.tag.emit(index, self.max_frame_num_to_track, True, True, '{}'.format(e))
307+
self.tag.emit(index, total, True, True, '{}'.format(e))
283308

284309

285310
class InitSegAnyThread(QThread):
@@ -531,6 +556,7 @@ def seg_video_start(self, max_frame_num_to_track=None):
531556
return
532557

533558
self.setEnabled(False)
559+
self.statusbar_change_status(is_message=False)
534560
self.segany_video_thread.start_frame_idx = self.current_index
535561
self.segany_video_thread.max_frame_num_to_track=max_frame_num_to_track
536562
self.segany_video_thread.start()
@@ -540,7 +566,11 @@ def seg_video_finish(self, current, total, finished, is_error, message):
540566
QtWidgets.QMessageBox.warning(self, 'warning', message)
541567

542568
print('Segment video: {}/{}'.format(current, total))
569+
self.progressbar.setMaximum(total)
570+
self.progressbar.setValue(current)
543571
if finished:
572+
self.statusbar_change_status(is_message=True)
573+
self.progressbar.setValue(0)
544574
self.setEnabled(True)
545575

546576

@@ -629,6 +659,12 @@ def init_ui(self):
629659
""")
630660
self.statusbar.addPermanentWidget(self.modeState)
631661

662+
self.progressbar = QtBoxStyleProgressBar()
663+
self.progressbar.setTextVisible(False)
664+
self.progressbar.setFixedWidth(500)
665+
self.progressbar.setVisible(False)
666+
self.statusbar.addPermanentWidget(self.progressbar)
667+
632668
self.update_menuSAM()
633669

634670
# mask alpha
@@ -697,6 +733,13 @@ def init_ui(self):
697733

698734
self.trans = QtCore.QTranslator()
699735

736+
def statusbar_change_status(self, is_message:bool=True):
737+
self.labelGPUResource.setVisible(is_message)
738+
self.labelData.setVisible(is_message)
739+
self.labelCoord.setVisible(is_message)
740+
self.modeState.setVisible(is_message)
741+
self.progressbar.setVisible(not is_message)
742+
700743
def update_menuSAM(self):
701744
#
702745
self.menuSAM_model.clear()

ISAT/widgets/model_manager_dialog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def __init__(self, parent, mainwindow):
113113
self.download_thread_dict = {}
114114
self.init_gui()
115115

116-
self.tableWidget.setColumnWidth(0, 200)
116+
self.tableWidget.setColumnWidth(0, 300)
117117
self.pushButton_clear_tmp.clicked.connect(self.clear_tmp)
118118
self.checkBox_use_bfloat16.stateChanged.connect(self.use_bfloat16)
119119

0 commit comments

Comments
 (0)