File size: 2,283 Bytes
821e8de
4b8b1d0
 
821e8de
4b8b1d0
 
f3feb7a
 
4b8b1d0
f3feb7a
4b8b1d0
cbdef19
4b8b1d0
f3feb7a
4b8b1d0
 
 
 
 
 
f3feb7a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4b8b1d0
f3feb7a
4b8b1d0
 
 
 
 
1ac8371
4b8b1d0
 
 
 
 
 
 
 
 
 
 
f3feb7a
821e8de
4b8b1d0
 
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
56
57
58
59
60
61
62
import gradio as gr
import os
from moviepy.editor import *

def replay(option):
	path = ""
	# Get the correct model
	if (option == "LunarLander-v2 πŸš€πŸ‘©β€πŸš€"):
  		path = "./LunarLander-v2.mp4"
	elif(option == "CartPole-v1 πŸ•ΉοΈ"):
  		path = "./CartPole-v1.mp4"
	elif(option == "Atari Space Invaders πŸ‘Ύ"):
  		path = "./SpaceInvadersNoFrameskip-v4.mp4"
	
	
  	# The only turnaround I found (Base64 video pb)
	videoclip = VideoFileClip(path)
	videoclip.write_videofile("new_filename.mp4")
	return 'new_filename.mp4'

"""
TODO: Next version with live video generation
def replay_classical(hf_model_filename, hf_model_id):
	import gym
	from stable_baselines3 import PPO
	from stable_baselines3.common.evaluation import evaluate_policy

	model = PPO.load_from_huggingface(hf_model_id,hf_model_filename)

	eval_env = gym.make(option)


def replay_atari(hf_model_filename, hf_model_id):
"""

iface = gr.Interface(
    replay,
    [
        gr.inputs.Dropdown(["Atari Space Invaders πŸ‘Ύ", "CartPole-v1 πŸ•ΉοΈ", "LunarLander-v2 πŸš€πŸ‘©β€πŸš€"]),
    ],
    "video",
     title = 'Stable Baselines 3 with πŸ€—',
            description = '',
             article = 
                        '''<div>
                        	<p style="text-align: center">This version of the RL library allows you to load models directly from the Hugging Face Hub</p>
                            <p style="text-align: center"> Select the trained agent you want to watch perform.
                            These models are from <a href="https://github.com/araffin/rl-baselines-zoo">Stable Baseline Zoo</a></p>
                            <p>
                            There are currently 3 models:
                            <ul>
                            	<li><a href="https://huggingface.co/ThomasSimonini/stable-baselines3-ppo-SpaceInvadersNoFrameskip-v4">PPO SpaceInvadersNoFrameskip-v4</a></li>
                            	<li><a href="https://huggingface.co/ThomasSimonini/stable-baselines3-ppo-LunarLander-v2">PPO LunarLander-v2</a></li>
                            	<li><a href="https://huggingface.co/ThomasSimonini/stable-baselines3-ppo-CartPole-v1">PPO CartPole-v1</a></li>
                            </ul>
                        </div>'''
            )
   

iface.launch()