File size: 684 Bytes
90f90d6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import tensorflow as tf
import base64
from PIL import Image
import io
from tqdm import tqdm

filenames = tf.io.gfile.glob('./android_control*')
raw_dataset = tf.data.TFRecordDataset(filenames, compression_type='GZIP')
dataset_iterator = tf.compat.v1.data.make_one_shot_iterator(raw_dataset)


for data in tqdm(dataset_iterator):
    example = tf.train.Example.FromString(data.numpy())
    episode_id = example.features.feature['episode_id'].int64_list.value
    # Save images to png files
    for i, image_data in enumerate(screenshots):
        image = Image.open(io.BytesIO(image_data))
        image.save(f"./images/android_control_episode_{str(episode_id)}_{str(i)}.png")