Spaces:
Runtime error
Runtime error
Commit
·
a9930a8
1
Parent(s):
eccb2f0
Update main.py
Browse files
main.py
CHANGED
@@ -30,6 +30,7 @@ def draw_trace(image: np.ndarray, previous_actions: List[Tuple[str, List[int]]])
|
|
30 |
pil_image = Image.fromarray(image)
|
31 |
draw = ImageDraw.Draw(pil_image)
|
32 |
flag = True
|
|
|
33 |
for i, (action_type, position) in enumerate(previous_actions):
|
34 |
color = (255, 0, 0) if action_type == "move" else (0, 255, 0)
|
35 |
x, y = position
|
@@ -42,7 +43,7 @@ def draw_trace(image: np.ndarray, previous_actions: List[Tuple[str, List[int]]])
|
|
42 |
y = y * 256 / 1024
|
43 |
draw.ellipse([x-2, y-2, x+2, y+2], fill=color)
|
44 |
|
45 |
-
if
|
46 |
#prev_x, prev_y = previous_actions[i-1][1]
|
47 |
draw.line([prev_x, prev_y, x, y], fill=color, width=1)
|
48 |
prev_x, prev_y = x, y
|
|
|
30 |
pil_image = Image.fromarray(image)
|
31 |
draw = ImageDraw.Draw(pil_image)
|
32 |
flag = True
|
33 |
+
prev_x, prev_y = None, None
|
34 |
for i, (action_type, position) in enumerate(previous_actions):
|
35 |
color = (255, 0, 0) if action_type == "move" else (0, 255, 0)
|
36 |
x, y = position
|
|
|
43 |
y = y * 256 / 1024
|
44 |
draw.ellipse([x-2, y-2, x+2, y+2], fill=color)
|
45 |
|
46 |
+
if prev_x is not None:
|
47 |
#prev_x, prev_y = previous_actions[i-1][1]
|
48 |
draw.line([prev_x, prev_y, x, y], fill=color, width=1)
|
49 |
prev_x, prev_y = x, y
|