santhosh97 commited on
Commit
591e531
·
1 Parent(s): 7143af7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -18
app.py CHANGED
@@ -22,6 +22,9 @@ if "key" not in st.session_state:
22
  if "captcha" not in st.session_state:
23
  st.session_state["captcha"] = None
24
 
 
 
 
25
  if "model_inputs" not in st.session_state:
26
  st.session_state["model_inputs"] = None
27
 
@@ -183,22 +186,29 @@ with train.form("training"):
183
  if not email:
184
  st.markdown('Please input an email!')
185
  else:
186
- result = generate_captcha()
187
- st.session_state['captcha'] = result
188
- captcha_id = st.session_state['captcha']['uuid']
189
- captcha_image = st.session_state['captcha']['captcha']
190
-
191
- st.image(captcha_image, width=300)
192
- captcha_response = st.text_input("Enter the captcha response")
193
- if captcha_response:
194
- result = verify_captcha(captcha_id, captcha_response)
195
- if 'message' in result and result['message'] == 'CAPTCHA_SOLVED':
196
- with st.spinner("Model Fine Tuning..."):
197
- st.session_state["model_inputs"]["identifier"] = st.session_state["key"]
198
- st.session_state["model_inputs"]["email"] = email
199
- train_model(st.session_state["model_inputs"])
200
- st.session_state["train_view"] = True
201
- else:
202
- st.error(result['error'])
203
- st.success('Done!')
 
 
 
 
 
 
 
204
 
 
22
  if "captcha" not in st.session_state:
23
  st.session_state["captcha"] = None
24
 
25
+ if "captcha_bool" not in st.session_state:
26
+ st.session_state["captcha_bool"] = False
27
+
28
  if "model_inputs" not in st.session_state:
29
  st.session_state["model_inputs"] = None
30
 
 
186
  if not email:
187
  st.markdown('Please input an email!')
188
  else:
189
+ st.session_state["captcha_bool"] = True
190
+
191
+
192
+ if st.session_state["captcha_bool"] = True:
193
+ captcha_form = st.empty()
194
+ with captcha_form.form("captcha"):
195
+ result = generate_captcha()
196
+ st.session_state['captcha'] = result
197
+ captcha_id = st.session_state['captcha']['uuid']
198
+ captcha_image = st.session_state['captcha']['captcha']
199
+
200
+ st.image(captcha_image, width=300)
201
+ captcha_response = st.text_input("Enter the captcha response")
202
+ submitted = st.form_submit_button("Submit Captcha!")
203
+ if submitted:
204
+ result = verify_captcha(captcha_id, captcha_response)
205
+ if 'message' in result and result['message'] == 'CAPTCHA_SOLVED':
206
+ with st.spinner("Model Fine Tuning..."):
207
+ st.session_state["model_inputs"]["identifier"] = st.session_state["key"]
208
+ st.session_state["model_inputs"]["email"] = email
209
+ train_model(st.session_state["model_inputs"])
210
+ st.session_state["train_view"] = True
211
+ else:
212
+ st.error(result['error'])
213
+ st.success('Done!')
214