Spaces:
Runtime error
Runtime error
Tristan Thrush
commited on
Commit
•
4047dab
1
Parent(s):
80bfae7
debug
Browse files
app.py
CHANGED
@@ -35,17 +35,17 @@ with demo:
|
|
35 |
pred["label"] = pred["label"].title()
|
36 |
ret = f"Target: **{tgt}**. Model prediction: **{pred['label']}**\n\n"
|
37 |
if pred["label"] != tgt:
|
38 |
-
state["fooled"] += 1
|
39 |
ret += " You fooled the model! Well done!"
|
40 |
else:
|
41 |
ret += " You did not fool the model! Too bad, try again!"
|
42 |
-
state["data"].append(ret)
|
43 |
-
state["cnt"] += 1
|
44 |
|
45 |
-
done = state["cnt"] == total_cnt
|
46 |
toggle_final_submit = gr.update(visible=done)
|
47 |
toggle_example_submit = gr.update(visible=not done)
|
48 |
-
new_state_md = f"State: {state['cnt']}/{total_cnt} ({state['fooled']} fooled)"
|
49 |
return pred_confidences, ret, state, toggle_example_submit, toggle_final_submit, new_state_md
|
50 |
|
51 |
# Input fields
|
@@ -65,10 +65,10 @@ with demo:
|
|
65 |
def _submit(state, dummy):
|
66 |
query = parse_qs(dummy[1:])
|
67 |
assert "assignmentId" in query, "No assignment ID provided, unable to submit"
|
68 |
-
state["assignmentId"] = query["assignmentId"]
|
69 |
url = "https://workersandbox.mturk.com/mturk/externalSubmit"
|
70 |
x = requests.post(url, data=state.value)
|
71 |
-
return str(x) + " With assignmentId " + state["assignmentId"][0] + "\n" + x.text, state, dummy
|
72 |
|
73 |
# Button event handlers
|
74 |
submit_ex_button.click(
|
@@ -84,6 +84,5 @@ with demo:
|
|
84 |
outputs=[response_output, state, dummy],
|
85 |
_js="function(state, dummy) { console.log(window); return [state, window.location.search]; }",
|
86 |
)
|
87 |
-
#gr.Markdown(state["response"].text if "response" in state and state["response"] is not None else "")
|
88 |
|
89 |
demo.launch()
|
|
|
35 |
pred["label"] = pred["label"].title()
|
36 |
ret = f"Target: **{tgt}**. Model prediction: **{pred['label']}**\n\n"
|
37 |
if pred["label"] != tgt:
|
38 |
+
state.value["fooled"] += 1
|
39 |
ret += " You fooled the model! Well done!"
|
40 |
else:
|
41 |
ret += " You did not fool the model! Too bad, try again!"
|
42 |
+
state.value["data"].append(ret)
|
43 |
+
state.value["cnt"] += 1
|
44 |
|
45 |
+
done = state.value["cnt"] == total_cnt
|
46 |
toggle_final_submit = gr.update(visible=done)
|
47 |
toggle_example_submit = gr.update(visible=not done)
|
48 |
+
new_state_md = f"State: {state.value['cnt']}/{total_cnt} ({state.value['fooled']} fooled)"
|
49 |
return pred_confidences, ret, state, toggle_example_submit, toggle_final_submit, new_state_md
|
50 |
|
51 |
# Input fields
|
|
|
65 |
def _submit(state, dummy):
|
66 |
query = parse_qs(dummy[1:])
|
67 |
assert "assignmentId" in query, "No assignment ID provided, unable to submit"
|
68 |
+
state.value["assignmentId"] = query["assignmentId"]
|
69 |
url = "https://workersandbox.mturk.com/mturk/externalSubmit"
|
70 |
x = requests.post(url, data=state.value)
|
71 |
+
return str(x) + " With assignmentId " + state.value["assignmentId"][0] + "\n" + x.text, state, dummy
|
72 |
|
73 |
# Button event handlers
|
74 |
submit_ex_button.click(
|
|
|
84 |
outputs=[response_output, state, dummy],
|
85 |
_js="function(state, dummy) { console.log(window); return [state, window.location.search]; }",
|
86 |
)
|
|
|
87 |
|
88 |
demo.launch()
|