Spaces:
Runtime error
Runtime error
Commit
Β·
f3feb7a
1
Parent(s):
318c231
Update app.py
Browse filesTest the new version of the app with a video selector.
app.py
CHANGED
|
@@ -1,7 +1,40 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
def
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 7 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
def replay(name):
|
| 4 |
+
# Get the correct model
|
| 5 |
+
if (option == "LunarLander-v2 ππ©βπ"):
|
| 6 |
+
return "./LunarLander-v2.mp4"
|
| 7 |
+
elif(option == "CartPole-v1 πΉοΈ"):
|
| 8 |
+
return "./CartPole-v1.mp4"
|
| 9 |
+
elif(option == "Atari Space Invaders πΎ")
|
| 10 |
+
return "./SpaceInvadersNoFrameskip-v4.mp4"
|
| 11 |
+
|
| 12 |
+
"""
|
| 13 |
+
TODO: Next version with live video generation
|
| 14 |
+
def replay_classical(hf_model_filename, hf_model_id):
|
| 15 |
+
import gym
|
| 16 |
+
from stable_baselines3 import PPO
|
| 17 |
+
from stable_baselines3.common.evaluation import evaluate_policy
|
| 18 |
+
|
| 19 |
+
model = PPO.load_from_huggingface(hf_model_id,hf_model_filename)
|
| 20 |
+
|
| 21 |
+
eval_env = gym.make(option)
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def replay_atari(hf_model_filename, hf_model_id):
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
#iface = gr.Interface(fn=, inputs="dropdown", outputs="text")
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
iface = gr.Interface(
|
| 32 |
+
replay,
|
| 33 |
+
[
|
| 34 |
+
gr.inputs.Dropdown(["Atari Space Invaders πΎ", "CartPole-v1 πΉοΈ", "LunarLander-v2 ππ©βπ "]),
|
| 35 |
+
],
|
| 36 |
+
"playable_video"
|
| 37 |
+
|
| 38 |
+
)
|
| 39 |
|
|
|
|
| 40 |
iface.launch()
|