Commit
·
d96d68b
1
Parent(s):
d3c262e
app.py updates
Browse files
app.py
CHANGED
@@ -28,10 +28,8 @@ if "points" not in st.session_state:
|
|
28 |
|
29 |
#"## Click on image"
|
30 |
|
31 |
-
if r not in vars():
|
32 |
-
r=0
|
33 |
|
34 |
-
|
35 |
current_image=ds[r]['image']
|
36 |
|
37 |
def button_click():
|
@@ -40,38 +38,40 @@ def button_click():
|
|
40 |
#st.write(str(r))
|
41 |
st.session_state["points"] = []
|
42 |
|
|
|
43 |
|
44 |
-
with current_image as img:
|
45 |
-
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
|
57 |
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
|
63 |
-
|
64 |
|
65 |
-
|
66 |
-
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
|
72 |
|
73 |
-
|
74 |
-
|
|
|
75 |
|
76 |
#else:
|
77 |
# st.write('Gohuhuhubye')
|
|
|
28 |
|
29 |
#"## Click on image"
|
30 |
|
|
|
|
|
31 |
|
32 |
+
r=0#np.random.randint(100)
|
33 |
current_image=ds[r]['image']
|
34 |
|
35 |
def button_click():
|
|
|
38 |
#st.write(str(r))
|
39 |
st.session_state["points"] = []
|
40 |
|
41 |
+
while True:
|
42 |
|
43 |
+
with current_image as img:
|
44 |
+
draw = ImageDraw.Draw(img)
|
45 |
|
46 |
+
def get_ellipse_coords(point):# tuple[int, int]) -> tuple[int, int, int, int]):
|
47 |
+
center = point
|
48 |
+
radius = 16
|
49 |
+
return (
|
50 |
+
center[0] - radius,
|
51 |
+
center[1] - radius,
|
52 |
+
center[0] + radius,
|
53 |
+
center[1] + radius,
|
54 |
+
)
|
55 |
|
56 |
|
57 |
+
# Draw an ellipse at each coordinate in points
|
58 |
+
for point in st.session_state["points"]:
|
59 |
+
coords = get_ellipse_coords(point)
|
60 |
+
draw.rectangle(coords, outline="green",width=2)
|
61 |
|
62 |
+
value = streamlit_image_coordinates(img, key="pil")
|
63 |
|
64 |
+
if value is not None:
|
65 |
+
point = value["x"], value["y"]
|
66 |
|
67 |
+
if point not in st.session_state["points"]:
|
68 |
+
st.session_state["points"]=[point]
|
69 |
+
st.experimental_rerun()
|
70 |
|
71 |
|
72 |
+
st.button('Random frame', on_click=button_click)
|
73 |
+
|
74 |
+
st.write(str(r))
|
75 |
|
76 |
#else:
|
77 |
# st.write('Gohuhuhubye')
|