Spaces:
Runtime error
Runtime error
Commit
·
591e531
1
Parent(s):
7143af7
Update app.py
Browse files
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 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|