Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -57,7 +57,8 @@ def update_fields(url_or_id):
|
|
57 |
return '', '', ''
|
58 |
print (arxiv_id)
|
59 |
title, authors, abstract = fetch_arxiv_data(arxiv_id)
|
60 |
-
|
|
|
61 |
|
62 |
def normalize_spaces(text):
|
63 |
return re.sub(r'\s+', ' ', text).strip()
|
@@ -84,7 +85,7 @@ def model_inference(title, authors, abstract):
|
|
84 |
score = probs[1].item()
|
85 |
return score
|
86 |
|
87 |
-
def predict(title, authors, abstract
|
88 |
# Your model prediction logic here
|
89 |
score = model_inference(title, authors, abstract)
|
90 |
|
@@ -96,7 +97,7 @@ def predict(title, authors, abstract, _):
|
|
96 |
|
97 |
result = f"Your score: {score:.2f}.\nFor papers with score>={threshold:.2f}, {precision * 100:.2f}% are selected by AK.\nFor papers selected by AK, {recall * 100:.2f}% have score>={threshold:.2f}"
|
98 |
|
99 |
-
return
|
100 |
|
101 |
example_title = "WildChat: 1M ChatGPT Interaction Logs in the Wild"
|
102 |
example_authors = "Wenting Zhao, Xiang Ren, Jack Hessel, Claire Cardie, Yejin Choi, Yuntian Deng"
|
@@ -107,18 +108,21 @@ with gr.Blocks() as demo:
|
|
107 |
author_box = gr.Textbox(label="Authors (separated by comma)", placeholder="Enter authors (separated by comma)", value=example_authors)
|
108 |
abstract_box = gr.TextArea(label="Abstract", placeholder="Enter abstract", value=example_abstract)
|
109 |
arxiv_box = gr.Textbox(label="[Optional] Autofill using arXiv URL/ID", placeholder="[Optional] Autofill using arXiv URL/ID")
|
|
|
|
|
|
|
110 |
#arxiv_box.input(update_fields, inputs=[arxiv_box], outputs=[title_box, author_box, abstract_box])
|
111 |
|
112 |
iface = gr.Interface(
|
113 |
fn=predict,
|
114 |
-
inputs=[title_box, author_box, abstract_box
|
115 |
-
outputs=[
|
|
|
116 |
title="Paper Selection Prediction",
|
117 |
description="Predict if @_akhaliq will select your paper into Hugging Face papers. Enter the title, authors, and abstract of your paper, or enter an arXiv URL/ID.",
|
118 |
live=False,
|
119 |
concurrency_limit=1
|
120 |
)
|
121 |
-
|
122 |
-
autofill_btn.click(update_fields, inputs=[arxiv_box], outputs=[title_box, author_box, abstract_box], concurrency_limit=1)
|
123 |
|
124 |
demo.queue(max_size=20).launch()
|
|
|
57 |
return '', '', ''
|
58 |
print (arxiv_id)
|
59 |
title, authors, abstract = fetch_arxiv_data(arxiv_id)
|
60 |
+
output = predict(title, authors, abstract)
|
61 |
+
return title, authors, abstract, output
|
62 |
|
63 |
def normalize_spaces(text):
|
64 |
return re.sub(r'\s+', ' ', text).strip()
|
|
|
85 |
score = probs[1].item()
|
86 |
return score
|
87 |
|
88 |
+
def predict(title, authors, abstract):
|
89 |
# Your model prediction logic here
|
90 |
score = model_inference(title, authors, abstract)
|
91 |
|
|
|
97 |
|
98 |
result = f"Your score: {score:.2f}.\nFor papers with score>={threshold:.2f}, {precision * 100:.2f}% are selected by AK.\nFor papers selected by AK, {recall * 100:.2f}% have score>={threshold:.2f}"
|
99 |
|
100 |
+
return result
|
101 |
|
102 |
example_title = "WildChat: 1M ChatGPT Interaction Logs in the Wild"
|
103 |
example_authors = "Wenting Zhao, Xiang Ren, Jack Hessel, Claire Cardie, Yejin Choi, Yuntian Deng"
|
|
|
108 |
author_box = gr.Textbox(label="Authors (separated by comma)", placeholder="Enter authors (separated by comma)", value=example_authors)
|
109 |
abstract_box = gr.TextArea(label="Abstract", placeholder="Enter abstract", value=example_abstract)
|
110 |
arxiv_box = gr.Textbox(label="[Optional] Autofill using arXiv URL/ID", placeholder="[Optional] Autofill using arXiv URL/ID")
|
111 |
+
output_box = gr.Textbox(label="Predicted Selection Probability")
|
112 |
+
autofill_btn = gr.Button("Autofill using arXiv")
|
113 |
+
autofill_btn.click(update_fields, inputs=[arxiv_box], outputs=[title_box, author_box, abstract_box, output_box], concurrency_limit=1)
|
114 |
#arxiv_box.input(update_fields, inputs=[arxiv_box], outputs=[title_box, author_box, abstract_box])
|
115 |
|
116 |
iface = gr.Interface(
|
117 |
fn=predict,
|
118 |
+
inputs=[title_box, author_box, abstract_box],
|
119 |
+
outputs=[output_box],
|
120 |
+
submit_btn=gr.Button("Predict", variant="primary")
|
121 |
title="Paper Selection Prediction",
|
122 |
description="Predict if @_akhaliq will select your paper into Hugging Face papers. Enter the title, authors, and abstract of your paper, or enter an arXiv URL/ID.",
|
123 |
live=False,
|
124 |
concurrency_limit=1
|
125 |
)
|
126 |
+
|
|
|
127 |
|
128 |
demo.queue(max_size=20).launch()
|