Spaces:
Runtime error
Runtime error
Commit
·
929432c
1
Parent(s):
b6d2a31
Update main.py
Browse files
main.py
CHANGED
@@ -13,7 +13,7 @@ import os
|
|
13 |
import time
|
14 |
|
15 |
DEBUG = False
|
16 |
-
DEBUG_TEACHER_FORCING =
|
17 |
app = FastAPI()
|
18 |
|
19 |
# Mount the static directory to serve HTML, JavaScript, and CSS files
|
@@ -45,7 +45,7 @@ def parse_action_string(action_str):
|
|
45 |
|
46 |
return x, y, action_type
|
47 |
|
48 |
-
def create_position_and_click_map(pos,action_type,
|
49 |
"""Convert cursor position to a binary position map
|
50 |
Args:
|
51 |
x, y: Original cursor positions
|
@@ -57,17 +57,17 @@ def create_position_and_click_map(pos,action_type,image_size=64, original_width=
|
|
57 |
"""
|
58 |
x, y = pos
|
59 |
if x is None:
|
60 |
-
return torch.zeros((1,
|
61 |
# Scale the positions to new size
|
62 |
#x_scaled = int((x / original_width) * image_size)
|
63 |
#y_scaled = int((y / original_height) * image_size)
|
64 |
-
screen_width, screen_height =
|
65 |
-
video_width, video_height = 512,
|
66 |
|
67 |
-
x_scaled = x - (screen_width / 2 - video_width / 2)
|
68 |
-
y_scaled = y - (screen_height / 2 - video_height / 2)
|
69 |
-
x_scaled = int(
|
70 |
-
y_scaled = int(
|
71 |
|
72 |
# Clamp values to ensure they're within bounds
|
73 |
x_scaled = max(0, min(x_scaled, image_size - 1))
|
|
|
13 |
import time
|
14 |
|
15 |
DEBUG = False
|
16 |
+
DEBUG_TEACHER_FORCING = False
|
17 |
app = FastAPI()
|
18 |
|
19 |
# Mount the static directory to serve HTML, JavaScript, and CSS files
|
|
|
45 |
|
46 |
return x, y, action_type
|
47 |
|
48 |
+
def create_position_and_click_map(pos,action_type, image_height=48, image_width=64, original_width=512, original_height=384):
|
49 |
"""Convert cursor position to a binary position map
|
50 |
Args:
|
51 |
x, y: Original cursor positions
|
|
|
57 |
"""
|
58 |
x, y = pos
|
59 |
if x is None:
|
60 |
+
return torch.zeros((1, image_height, image_width)), torch.zeros((1, image_height, image_width)), None, None
|
61 |
# Scale the positions to new size
|
62 |
#x_scaled = int((x / original_width) * image_size)
|
63 |
#y_scaled = int((y / original_height) * image_size)
|
64 |
+
#screen_width, screen_height = 512, 384
|
65 |
+
#video_width, video_height = 512, 384
|
66 |
|
67 |
+
#x_scaled = x - (screen_width / 2 - video_width / 2)
|
68 |
+
#y_scaled = y - (screen_height / 2 - video_height / 2)
|
69 |
+
x_scaled = int(x / original_width * image_width)
|
70 |
+
y_scaled = int(y / original_height * image_height)
|
71 |
|
72 |
# Clamp values to ensure they're within bounds
|
73 |
x_scaled = max(0, min(x_scaled, image_size - 1))
|