-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviewnpz.py
More file actions
59 lines (36 loc) · 1.44 KB
/
viewnpz.py
File metadata and controls
59 lines (36 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from numpy import load
from matplotlib import pyplot as plt
import cv2
import numpy as np
def showimgObservation(np3DArray):
plt.imshow(np3DArray, interpolation='nearest')
plt.show()
return
def createMovie(data,item):
output_video = 'output_video.mp4'
# Define the dimensions of the images
image_width = 64
image_height = 64
# Define the codec and create VideoWriter object
fourcc = cv2.VideoWriter_fourcc(*'mp4v') # Specify the codec
fps = 30 # Frames per second
video_writer = cv2.VideoWriter(output_video, fourcc, fps, (image_width, image_height))
# Loop through each image array and write it to the video
for img_array in data[item]:
# Convert the NumPy array to uint8 format (assuming pixel values are in the range [0, 255])
img_uint8 = np.uint8(img_array)
# Resize the image to fit the video dimensions (if needed)
# img_resized = cv2.resize(img_uint8, (image_width, image_height))
# Write the frame to the video
video_writer.write(img_uint8)
# Release the VideoWriter object
video_writer.release()
print("Video creation completed.")
data = load('/Users/athmajanvivekananthan/WCE/JEPA - MARL/World Models/world-models/datasets/carracing/thread_1/rollout_0.npz')
lst = data.files
item = lst[0] # observations
print(item)
print(len(data[item]))
obs0 = data[item][500]
#createMovie(data,item)
#showimgObservation(obs0)