Spaces:
Runtime error
Runtime error
Commit
·
4a67929
1
Parent(s):
912e28c
Update main.py
Browse files
main.py
CHANGED
|
@@ -12,6 +12,7 @@ import torch
|
|
| 12 |
import os
|
| 13 |
import time
|
| 14 |
|
|
|
|
| 15 |
app = FastAPI()
|
| 16 |
|
| 17 |
# Mount the static directory to serve HTML, JavaScript, and CSS files
|
|
@@ -106,8 +107,9 @@ def predict_next_frame(previous_frames: List[np.ndarray], previous_actions: List
|
|
| 106 |
x, y = pos
|
| 107 |
norm_x = int(round(x / 256 * 1024)) #x + (1920 - 256) / 2
|
| 108 |
norm_y = int(round(y / 256 * 640)) #y + (1080 - 256) / 2
|
| 109 |
-
|
| 110 |
-
|
|
|
|
| 111 |
action_descriptions.append(f"{(norm_x-prev_x):.0f}~{(norm_y-prev_y):.0f}")
|
| 112 |
prev_x = norm_x
|
| 113 |
prev_y = norm_y
|
|
@@ -155,10 +157,12 @@ async def websocket_endpoint(websocket: WebSocket):
|
|
| 155 |
mouse_position = data.get("mouse_position")
|
| 156 |
|
| 157 |
# Store the actions
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
|
|
|
|
|
|
| 162 |
previous_actions.append((action_type, mouse_position))
|
| 163 |
|
| 164 |
# Log the start time
|
|
|
|
| 12 |
import os
|
| 13 |
import time
|
| 14 |
|
| 15 |
+
DEBUG = True
|
| 16 |
app = FastAPI()
|
| 17 |
|
| 18 |
# Mount the static directory to serve HTML, JavaScript, and CSS files
|
|
|
|
| 107 |
x, y = pos
|
| 108 |
norm_x = int(round(x / 256 * 1024)) #x + (1920 - 256) / 2
|
| 109 |
norm_y = int(round(y / 256 * 640)) #y + (1080 - 256) / 2
|
| 110 |
+
if DEBUG:
|
| 111 |
+
norm_x = x
|
| 112 |
+
norm_y = y
|
| 113 |
action_descriptions.append(f"{(norm_x-prev_x):.0f}~{(norm_y-prev_y):.0f}")
|
| 114 |
prev_x = norm_x
|
| 115 |
prev_y = norm_y
|
|
|
|
| 157 |
mouse_position = data.get("mouse_position")
|
| 158 |
|
| 159 |
# Store the actions
|
| 160 |
+
if DEBUG:
|
| 161 |
+
position = positions[0]
|
| 162 |
+
positions = positions[1:]
|
| 163 |
+
mouse_position = position.split('~')
|
| 164 |
+
mouse_position = [int(item) for item in mouse_position]
|
| 165 |
+
|
| 166 |
previous_actions.append((action_type, mouse_position))
|
| 167 |
|
| 168 |
# Log the start time
|