-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdemo.py
More file actions
66 lines (51 loc) · 1.44 KB
/
demo.py
File metadata and controls
66 lines (51 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
56
57
58
59
60
61
62
63
64
65
66
"""
Demo script for the PWP package
This script demonstrates how to use the PWP environment and benchmarks.
"""
import time
from pwp.env import PwP
from pwp.bench import PwPBench
def demo_env():
"""
Demo of using the PwP environment
"""
# Create an environment
env = PwP(image_name='pwp_env')
# Take a screenshot
env.reset()
observation = env.render()
# Run a command
env.step("xdotool mousemove 100 100 click 1")
time.sleep(2)
# Take another screenshot
observation = env.render()
# Clean up
env.stop()
env.remove()
def demo_bench():
"""
Demo of using the PwP benchmark
"""
# Create a benchmark
bench = PwPBench(task_name='humaneval')
# Get the dataset
dataset = bench.get_dataset()
# Print the first example
if dataset and len(dataset) > 0:
print("First benchmark example:", dataset[0])
else:
print("No benchmark examples found.")
task_env = bench.get_env(dataset[0])
observation = task_env.render()
# Optionally save the observation to a file
task_env.step("xdotool mousemove 100 100 click 1")
time.sleep(2)
observation = task_env.render()
observation.save('demo_observation.png')
task_env.stop()
task_env.remove()
if __name__ == "__main__":
print("Running PWP Environment Demo...")
demo_env()
print("\nRunning PWP Benchmark Demo...")
demo_bench()