Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option disable_progress_grid to user arguments #161

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions discoart/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def create(
use_vertical_symmetry: Optional[bool] = False,
visualize_cuts: Optional[bool] = False,
width_height: Optional[List[int]] = [1280, 768],
disable_progress_grid: Optional[bool] = False,
) -> Optional['DocumentArray']:

...
Expand Down
21 changes: 13 additions & 8 deletions discoart/persist.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,23 @@ def _save_progress_thread(*args):
return t


def _save_progress(da, da_gif, _nb, output_dir, fps, size_ratio):
def _save_progress(da, da_gif, _nb, output_dir, fps, size_ratio, disable_progress_grid):
with threading.Lock():
try:
for idx, d in enumerate(da):
if d.chunks:
# only print the first image of the minibatch in progress
d.chunks.plot_image_sprites(
os.path.join(output_dir, f'{_nb}-progress-{idx}.png'),
skip_empty=True,
show_index=True,
keep_aspect_ratio=True,
)
if disable_progress_grid:
#save only the latest image
file_name = os.path.join(output_dir, f'{_nb}-progress.png')
d.load_uri_to_image_tensor().save_image_tensor_to_file(file_name)
else:
# only print the first image of the minibatch in progress
d.chunks.plot_image_sprites(
os.path.join(output_dir, f'{_nb}-progress-{idx}.png'),
skip_empty=True,
show_index=True,
keep_aspect_ratio=True,
)
for idx, d_gif in enumerate(da_gif):
if d_gif.chunks and fps > 0:
d_gif.chunks.save_gif(
Expand Down
3 changes: 2 additions & 1 deletion discoart/resources/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,5 @@ text_clip_on_cpu: False
truncate_overlength_prompt: False
image_output: True
visualize_cuts: False
display_rate: 1
display_rate: 1
disable_progress_grid: False
1 change: 1 addition & 0 deletions discoart/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ def cond_fn(x, t, **kwargs):
output_dir,
args.gif_fps,
args.gif_size_ratio,
args.disable_progress_grid,
)
)

Expand Down