Skip to content

Commit

Permalink
no pygame
Browse files Browse the repository at this point in the history
  • Loading branch information
syrkis committed Jul 31, 2024
1 parent 1cdf9e8 commit 7de67fd
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 56 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ dist/
cache/
pyrightconfig.json
.venv
output
Binary file removed output/parabellum.gif
Binary file not shown.
Binary file removed output/parabellum_0.gif
Binary file not shown.
12 changes: 8 additions & 4 deletions parabellum/vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# Standard library imports
from functools import partial
from typing import Optional, List, Tuple
from contextlib import contextmanager
import cv2
from PIL import Image

# JAX and JAX-related imports
import jax
Expand All @@ -21,7 +21,7 @@
# Third-party imports
import numpy as np
import pygame
from moviepy.editor import ImageSequenceClip
import cv2
from tqdm import tqdm

# Local imports
Expand Down Expand Up @@ -70,8 +70,12 @@ def animate_fn(env, skin, image, state_seq, action_seq, save_fname):
frames = []
for idx, (state_tup, action) in enumerate(zip(state_seq, action_seq)):
frames += [frame_fn(env, skin, image, state_tup[1], action, idx)]
# ImageSequenceClip(frames, fps=skin.fps).write_gif(save_fname, fps=skin.fps)
ImageSequenceClip(frames, fps=skin.fps).write_videofile(save_fname, fps=skin.fps)
# use cv2 to write frames to video
fourcc = cv2.VideoWriter_fourcc(*'mp4v') # type: ignore
out = cv2.VideoWriter(save_fname, fourcc, skin.fps, (skin.size + skin.pad * 2, skin.size + skin.pad * 2))
for frame in frames:
out.write(cv2.cvtColor(frame, cv2.COLOR_RGB2BGR))
out.release()
pygame.quit()


Expand Down
104 changes: 52 additions & 52 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7de67fd

Please sign in to comment.