Commit
·
12ae958
1
Parent(s):
42f4e81
app.py updates
Browse files
app.py
CHANGED
@@ -31,13 +31,17 @@ if "img" not in st.session_state:
|
|
31 |
if "draw" not in st.session_state:
|
32 |
st.session_state["draw"] = False
|
33 |
|
|
|
|
|
34 |
|
35 |
def button_click():
|
36 |
st.session_state["img"]=np.random.randint(100)
|
37 |
st.session_state["draw"] = False
|
38 |
|
39 |
def find():
|
40 |
-
|
|
|
|
|
41 |
|
42 |
|
43 |
def get_ellipse_coords(point):# tuple[int, int]) -> tuple[int, int, int, int]):
|
@@ -51,35 +55,42 @@ def get_ellipse_coords(point):# tuple[int, int]) -> tuple[int, int, int, int]):
|
|
51 |
)
|
52 |
|
53 |
|
54 |
-
|
55 |
-
draw = ImageDraw.Draw(current_image)
|
56 |
|
57 |
-
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
point=st.session_state["points"]
|
62 |
-
coords = get_ellipse_coords(point)
|
63 |
-
draw.rectangle(coords, outline="green",width=2)
|
64 |
|
65 |
-
|
66 |
|
67 |
-
|
68 |
-
point
|
|
|
|
|
|
|
69 |
|
70 |
-
|
71 |
-
st.session_state["points"]=point
|
72 |
-
st.session_state["draw"]=True
|
73 |
-
st.experimental_rerun()
|
74 |
|
|
|
|
|
75 |
|
76 |
-
st.
|
77 |
-
st.
|
|
|
|
|
78 |
|
79 |
-
st.write(st.session_state["img"])
|
80 |
-
st.write(st.session_state["points"])
|
81 |
-
st.write(st.session_state["draw"])
|
82 |
-
#st.write(value["x"], value["y"])
|
83 |
|
84 |
-
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
if "draw" not in st.session_state:
|
32 |
st.session_state["draw"] = False
|
33 |
|
34 |
+
if "sideimg" not in st.session_state:
|
35 |
+
st.session_state["sideimg"] = [0,1,2,3]
|
36 |
|
37 |
def button_click():
|
38 |
st.session_state["img"]=np.random.randint(100)
|
39 |
st.session_state["draw"] = False
|
40 |
|
41 |
def find():
|
42 |
+
for i in range(4):
|
43 |
+
st.image(ds[0]['image'][i]+=1
|
44 |
+
# st.image(ds[0]['image'])
|
45 |
|
46 |
|
47 |
def get_ellipse_coords(point):# tuple[int, int]) -> tuple[int, int, int, int]):
|
|
|
55 |
)
|
56 |
|
57 |
|
58 |
+
col1, col2 = st.columns(2)
|
|
|
59 |
|
60 |
+
with col1:
|
61 |
|
62 |
+
current_image=ds[st.session_state["img"]]['image']
|
63 |
+
draw = ImageDraw.Draw(current_image)
|
|
|
|
|
|
|
64 |
|
65 |
+
if st.session_state["draw"]:
|
66 |
|
67 |
+
# Draw an ellipse at each coordinate in points
|
68 |
+
#for point in st.session_state["points"]:
|
69 |
+
point=st.session_state["points"]
|
70 |
+
coords = get_ellipse_coords(point)
|
71 |
+
draw.rectangle(coords, outline="green",width=2)
|
72 |
|
73 |
+
value = streamlit_image_coordinates(current_image, key="pil")
|
|
|
|
|
|
|
74 |
|
75 |
+
if value is not None:
|
76 |
+
point = value["x"], value["y"]
|
77 |
|
78 |
+
if point != st.session_state["points"]:
|
79 |
+
st.session_state["points"]=point
|
80 |
+
st.session_state["draw"]=True
|
81 |
+
st.experimental_rerun()
|
82 |
|
|
|
|
|
|
|
|
|
83 |
|
84 |
+
st.button('Random frame', on_click=button_click)
|
85 |
+
st.button('Find simalar parts', on_click=find)
|
86 |
+
|
87 |
+
st.write(st.session_state["img"])
|
88 |
+
st.write(st.session_state["points"])
|
89 |
+
st.write(st.session_state["draw"])
|
90 |
+
|
91 |
+
with col2:
|
92 |
+
|
93 |
+
for i in range(4):
|
94 |
+
st.image(np.array(st.session_state["sideimg"][i])[::4,::4,:])
|
95 |
+
|
96 |
+
|