Skip to content

Commit

Permalink
fixing bug when open dir doesn't open the first image
Browse files Browse the repository at this point in the history
  • Loading branch information
0ssamaak0 committed Aug 29, 2023
1 parent 97b2e6c commit 18558db
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions DLTA_AI_app/labelme/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2592,6 +2592,32 @@ def model_explorer(self):
selected_model_name, config, checkpoint)
self.updateSamControls()

def openNextImg(self, _value=False, load=True):
self.refresh_image_MODE()
keep_prev = self._config["keep_prev"]
if not self.mayContinue():
return

if len(self.imageList) <= 0:
return

filename = None
if self.filename is None:
filename = self.imageList[0]
else:
currIndex = self.imageList.index(self.filename)
if currIndex + 1 < len(self.imageList):
filename = self.imageList[currIndex + 1]
else:
filename = self.imageList[-1]
self.filename = filename

if self.filename and load:
self.loadFile(self.filename)

self._config["keep_prev"] = keep_prev
self.refresh_image_MODE()

def openFile(self, _value=False):

self.actions.export.setEnabled(False)
Expand Down Expand Up @@ -3164,6 +3190,8 @@ def importDroppedImageFiles(self, imageFiles):
item.setCheckState(Qt.CheckState.Unchecked)
self.fileListWidget.addItem(item)

self.openNextImg()

def importDirImages(self, dirpath, pattern=None, load=True):

self.actions.export.setEnabled(True)
Expand Down Expand Up @@ -3191,6 +3219,7 @@ def importDirImages(self, dirpath, pattern=None, load=True):
else:
item.setCheckState(Qt.CheckState.Unchecked)
self.fileListWidget.addItem(item)
self.openNextImg(load=load)
self.fileListWidget.horizontalScrollBar().setValue(
self.fileListWidget.horizontalScrollBar().maximum()
)
Expand Down

0 comments on commit 18558db

Please sign in to comment.