MaxReimann commited on
Commit
29e045c
1 Parent(s): 02d819d
Files changed (1) hide show
  1. Whitebox_style_transfer.py +7 -3
Whitebox_style_transfer.py CHANGED
@@ -41,6 +41,9 @@ if "click_counter" not in st.session_state:
41
 
42
  if "action" not in st.session_state:
43
  st.session_state["action"] = ""
 
 
 
44
 
45
  content_urls = [
46
  {
@@ -129,7 +132,7 @@ def img_choice_panel(imgtype, urls, default_choice, expanded):
129
  st.write("uploaded.")
130
 
131
  last_clicked = last_image_clicked(type=imgtype)
132
- print("last_clicked", last_clicked, "clicked", clicked, "action", st.session_state["action"] )
133
  if not upload_pressed and clicked != "": # trigger when no file uploaded
134
  if last_clicked != clicked: # only activate when content was actually clicked
135
  store_img_from_id(clicked, urls, imgtype)
@@ -146,6 +149,7 @@ def optimize(effect, preset, result_image_placeholder):
146
  style = st.session_state["Style_im"]
147
  st.session_state["optimize_next"] = False
148
  with st.spinner(text="Optimizing parameters.."):
 
149
  if HUGGING_FACE:
150
  optimize_on_server(content, style, result_image_placeholder)
151
  else:
@@ -245,11 +249,11 @@ if st.session_state["action"] == "uploaded":
245
  content_img, _vp = optimize_next(result_image_placeholder)
246
  elif st.session_state["action"] in ("switch_page_from_local_edits", "switch_page_from_presets", "slider_change") or \
247
  content_id == "uploaded" or style_id == "uploaded":
248
- print("restore param")
249
  _vp = st.session_state["result_vp"]
250
  content_img = st.session_state["effect_input"]
251
  else:
252
- print("load_params")
253
  content_img, _vp = load_params(content_id, style_id)#, effect)
254
 
255
  vp = torch.clone(_vp)
 
41
 
42
  if "action" not in st.session_state:
43
  st.session_state["action"] = ""
44
+
45
+ if "user" not in st.session_state:
46
+ st.session_state["user"] = hash(time.time())
47
 
48
  content_urls = [
49
  {
 
132
  st.write("uploaded.")
133
 
134
  last_clicked = last_image_clicked(type=imgtype)
135
+ print(st.session_state["user"], " last_clicked", last_clicked, "clicked", clicked, "action", st.session_state["action"] )
136
  if not upload_pressed and clicked != "": # trigger when no file uploaded
137
  if last_clicked != clicked: # only activate when content was actually clicked
138
  store_img_from_id(clicked, urls, imgtype)
 
149
  style = st.session_state["Style_im"]
150
  st.session_state["optimize_next"] = False
151
  with st.spinner(text="Optimizing parameters.."):
152
+ print("optimizing for user", st.session_state["user"])
153
  if HUGGING_FACE:
154
  optimize_on_server(content, style, result_image_placeholder)
155
  else:
 
249
  content_img, _vp = optimize_next(result_image_placeholder)
250
  elif st.session_state["action"] in ("switch_page_from_local_edits", "switch_page_from_presets", "slider_change") or \
251
  content_id == "uploaded" or style_id == "uploaded":
252
+ print(st.session_state["user"], "restore param")
253
  _vp = st.session_state["result_vp"]
254
  content_img = st.session_state["effect_input"]
255
  else:
256
+ print(st.session_state["user"], "load_params")
257
  content_img, _vp = load_params(content_id, style_id)#, effect)
258
 
259
  vp = torch.clone(_vp)