Circularmachines commited on
Commit
d96d68b
·
1 Parent(s): d3c262e

app.py updates

Browse files
Files changed (1) hide show
  1. app.py +26 -26
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
- #r=0#np.random.randint(100)
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
- draw = ImageDraw.Draw(img)
46
 
47
- def get_ellipse_coords(point):# tuple[int, int]) -> tuple[int, int, int, int]):
48
- center = point
49
- radius = 16
50
- return (
51
- center[0] - radius,
52
- center[1] - radius,
53
- center[0] + radius,
54
- center[1] + radius,
55
- )
56
 
57
 
58
- # Draw an ellipse at each coordinate in points
59
- for point in st.session_state["points"]:
60
- coords = get_ellipse_coords(point)
61
- draw.rectangle(coords, outline="green",width=2)
62
 
63
- value = streamlit_image_coordinates(img, key="pil")
64
 
65
- if value is not None:
66
- point = value["x"], value["y"]
67
 
68
- if point not in st.session_state["points"]:
69
- st.session_state["points"]=[point]
70
- st.experimental_rerun()
71
 
72
 
73
- st.button('Random frame', on_click=button_click)
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')