Skip to content

Commit

Permalink
bugfix: Preview tool Don't error if too few images
Browse files Browse the repository at this point in the history
  • Loading branch information
torzdf committed Jun 18, 2023
1 parent e8a3016 commit 82e927d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions scripts/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ def _get_io_sizes(self) -> Dict[str, int]:
input_shape = [input_shape] if not isinstance(input_shape, list) else input_shape
output_shape = self._model.model.output_shape
output_shape = [output_shape] if not isinstance(output_shape, list) else output_shape
retval = dict(input=input_shape[0][1], output=output_shape[-1][1])
retval = {"input": input_shape[0][1], "output": output_shape[-1][1]}
logger.debug(retval)
return retval

Expand Down Expand Up @@ -833,7 +833,6 @@ def _get_batchsize(self, queue_size: int) -> int:
is_cpu = GPUStats().device_count == 0
batchsize = 1 if is_cpu else self._model.config["convert_batchsize"]
batchsize = min(queue_size, batchsize)
logger.debug("Batchsize: %s", batchsize)
logger.debug("Got batchsize: %s", batchsize)
return batchsize

Expand Down
3 changes: 2 additions & 1 deletion tools/preview/preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def __init__(self, app: Preview, arguments: "Namespace", sample_size: int) -> No
self._indices = self._get_indices()

self._predictor = Predict(queue_manager.get_queue("preview_predict_in"),
sample_size,
self._sample_size,
arguments)
self._app._display.set_centering(self._predictor.centering)
self.generate()
Expand Down Expand Up @@ -385,6 +385,7 @@ def _get_indices(self) -> List[List[int]]:
"""
# Remove start and end values to get a list divisible by self.sample_size
no_files = len(self._filelist)
self._sample_size = min(self._sample_size, no_files)
crop = no_files % self._sample_size
top_tail = list(range(no_files))[
crop // 2:no_files - (crop - (crop // 2))]
Expand Down

0 comments on commit 82e927d

Please sign in to comment.