Spaces:
Runtime error
Runtime error
Commit
·
04c9273
1
Parent(s):
19cf45b
Update app.py
Browse files
app.py
CHANGED
@@ -50,6 +50,37 @@ def zip_and_upload_images(identifier, uploaded_files, image_type):
|
|
50 |
)
|
51 |
return f"s3://gretel-image-synthetics/data/{identifier}/{image_type}_images.zip"
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
def train_model(model_inputs):
|
55 |
api_key = "03cdd72e-5c04-4207-bd6a-fd5712c1740e"
|
@@ -147,10 +178,18 @@ with train.form("training"):
|
|
147 |
if not email:
|
148 |
st.markdown('Please input an email!')
|
149 |
else:
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
st.success('Done!')
|
156 |
|
|
|
50 |
)
|
51 |
return f"s3://gretel-image-synthetics/data/{identifier}/{image_type}_images.zip"
|
52 |
|
53 |
+
CAPTCHA_ENDPOINT = "https://captcha-api.akshit.me/v2/generate"
|
54 |
+
VERIFY_ENDPOINT = "https://captcha-api.akshit.me/v2/verify"
|
55 |
+
|
56 |
+
# Create a function to generate a captcha
|
57 |
+
def generate_captcha():
|
58 |
+
# Make a GET request to the API endpoint to generate a captcha
|
59 |
+
response = requests.get(CAPTCHA_ENDPOINT)
|
60 |
+
|
61 |
+
# If the request was successful, return the API response
|
62 |
+
if response.status_code == 200:
|
63 |
+
return response.json()
|
64 |
+
|
65 |
+
# Otherwise, return an error message
|
66 |
+
return {"error": "Failed to generate captcha"}
|
67 |
+
|
68 |
+
# Create a function to verify the captcha
|
69 |
+
def verify_captcha(captcha_id, captcha_response):
|
70 |
+
# Make a POST request to the API endpoint with the captcha ID and response
|
71 |
+
|
72 |
+
response = requests.post(
|
73 |
+
VERIFY_ENDPOINT, json={"uuid": captcha_id, "captcha": captcha_response}
|
74 |
+
)
|
75 |
+
print(response)
|
76 |
+
|
77 |
+
# If the request was successful, return the API response
|
78 |
+
if response.status_code == 200:
|
79 |
+
return response.json()
|
80 |
+
|
81 |
+
# Otherwise, return an error message
|
82 |
+
return {"error": "Failed to verify captcha"}
|
83 |
+
|
84 |
|
85 |
def train_model(model_inputs):
|
86 |
api_key = "03cdd72e-5c04-4207-bd6a-fd5712c1740e"
|
|
|
178 |
if not email:
|
179 |
st.markdown('Please input an email!')
|
180 |
else:
|
181 |
+
result = generate_captcha()
|
182 |
+
st.image(captcha_image, width=300)
|
183 |
+
captcha_response = st.text_input("Enter the captcha response")
|
184 |
+
if captcha_response:
|
185 |
+
result = verify_captcha(captcha_id, captcha_response)
|
186 |
+
if 'message' in result and result['message'] == 'CAPTCHA_SOLVED':
|
187 |
+
with st.spinner("Model Fine Tuning..."):
|
188 |
+
st.session_state["model_inputs"]["identifier"] = st.session_state["key"]
|
189 |
+
st.session_state["model_inputs"]["email"] = email
|
190 |
+
train_model(st.session_state["model_inputs"])
|
191 |
+
st.session_state["train_view"] = True
|
192 |
+
else:
|
193 |
+
st.error(result['error'])
|
194 |
st.success('Done!')
|
195 |
|