Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -131,9 +131,11 @@ def d4_to_3d(image):
|
|
131 |
|
132 |
st.set_page_config(layout="wide")
|
133 |
|
134 |
-
st.write(str(os.getcwd()))
|
135 |
-
|
|
|
136 |
img_selection=None
|
|
|
137 |
# Specify canvas parameters in application
|
138 |
drawing_mode = st.sidebar.selectbox(
|
139 |
"Drawing tool:", ("freedraw","point", "line", "rect", "circle", "transform")
|
@@ -151,6 +153,8 @@ if "user" not in dictionary:
|
|
151 |
dictionary['user']=None
|
152 |
if "current_session" not in dictionary:
|
153 |
dictionary['current_session']=None
|
|
|
|
|
154 |
|
155 |
stroke_width = st.sidebar.slider("Stroke width: ", 1, 25, 20)
|
156 |
if drawing_mode == 'point':
|
@@ -234,7 +238,9 @@ with column2:
|
|
234 |
if img_selection in dictionary['current_image']:
|
235 |
dictionary['current_image'].remove(img_selection)
|
236 |
dictionary['current_image'].insert(0,img_selection)
|
237 |
-
|
|
|
|
|
238 |
|
239 |
img_selection.save("image.png")
|
240 |
with open("image.png", "rb") as file:
|
@@ -387,7 +393,7 @@ else:
|
|
387 |
|
388 |
with column1:
|
389 |
# Create a canvas component
|
390 |
-
changes,implementation,current=st.columns([0.
|
391 |
|
392 |
with implementation:
|
393 |
st.write("<br>"*5,unsafe_allow_html=True)
|
@@ -398,8 +404,8 @@ with column1:
|
|
398 |
background_color=bg_color,
|
399 |
background_image=gen_image if gen_image else Image.open("/home/user/app/ALL_image_formation/image_gen.png"),
|
400 |
update_streamlit=True,
|
401 |
-
height=
|
402 |
-
width=
|
403 |
drawing_mode=drawing_mode,
|
404 |
point_display_radius=point_display_radius if drawing_mode == 'point' else 0,
|
405 |
key="canvas",
|
|
|
131 |
|
132 |
st.set_page_config(layout="wide")
|
133 |
|
134 |
+
# st.write(str(os.getcwd()))
|
135 |
+
screen_width = streamlit_js_eval(label="screen.width",js_expressions='screen.width')
|
136 |
+
screen_height = streamlit_js_eval(label="screen.height",js_expressions='screen.height')
|
137 |
img_selection=None
|
138 |
+
|
139 |
# Specify canvas parameters in application
|
140 |
drawing_mode = st.sidebar.selectbox(
|
141 |
"Drawing tool:", ("freedraw","point", "line", "rect", "circle", "transform")
|
|
|
153 |
dictionary['user']=None
|
154 |
if "current_session" not in dictionary:
|
155 |
dictionary['current_session']=None
|
156 |
+
if "image_movement" not in dictionary:
|
157 |
+
dictionary['image_movement']=None
|
158 |
|
159 |
stroke_width = st.sidebar.slider("Stroke width: ", 1, 25, 20)
|
160 |
if drawing_mode == 'point':
|
|
|
238 |
if img_selection in dictionary['current_image']:
|
239 |
dictionary['current_image'].remove(img_selection)
|
240 |
dictionary['current_image'].insert(0,img_selection)
|
241 |
+
if dictionary['image_movement']!=img_selection:
|
242 |
+
dictionary['image_movement']=img_selection
|
243 |
+
st.rerun() # st.rerun()
|
244 |
|
245 |
img_selection.save("image.png")
|
246 |
with open("image.png", "rb") as file:
|
|
|
393 |
|
394 |
with column1:
|
395 |
# Create a canvas component
|
396 |
+
changes,implementation,current=st.columns([0.01,0.9,0.01])
|
397 |
|
398 |
with implementation:
|
399 |
st.write("<br>"*5,unsafe_allow_html=True)
|
|
|
404 |
background_color=bg_color,
|
405 |
background_image=gen_image if gen_image else Image.open("/home/user/app/ALL_image_formation/image_gen.png"),
|
406 |
update_streamlit=True,
|
407 |
+
height=screen_height//2.16 if screen_height!=1180 else screen_height/2,
|
408 |
+
width=screen_width//2.3 if screen_width!=820 else screen_width/2,
|
409 |
drawing_mode=drawing_mode,
|
410 |
point_display_radius=point_display_radius if drawing_mode == 'point' else 0,
|
411 |
key="canvas",
|