Spaces:
Running
on
Zero
Running
on
Zero
app.py
CHANGED
@@ -21,7 +21,9 @@ MAX_PAGES = 20
|
|
21 |
MIN_LENGTH=200
|
22 |
settings.EXTRACT_IMAGES = False
|
23 |
settings.DEBUG = False
|
24 |
-
settings.PDFTEXT_CPU_WORKERS=1
|
|
|
|
|
25 |
surya_settings.IN_STREAMLIT = True
|
26 |
|
27 |
model_refs = load_all_models()
|
@@ -177,10 +179,6 @@ def process_file(file):
|
|
177 |
|
178 |
@spaces.GPU(duration=90)
|
179 |
def generate(paper_text, review_template):
|
180 |
-
# messages = [
|
181 |
-
# {"role": "system", "content": "You are a pirate."},
|
182 |
-
# {"role": "user", "content": paper_text}
|
183 |
-
# ]
|
184 |
messages = create_messages(review_template, paper_text)
|
185 |
input_ids = tokenizer.apply_chat_template(
|
186 |
messages,
|
@@ -195,20 +193,6 @@ def generate(paper_text, review_template):
|
|
195 |
for new_text in streamer:
|
196 |
generated_text += new_text
|
197 |
yield generated_text.replace("<|eot_id|>", "")
|
198 |
-
# generated_ids = model.generate(
|
199 |
-
# input_ids=input_ids,
|
200 |
-
# max_new_tokens=4096,
|
201 |
-
# do_sample=True,
|
202 |
-
# temperature=0.6,
|
203 |
-
# top_p=0.9
|
204 |
-
# )
|
205 |
-
# generated_ids = [
|
206 |
-
# output_ids[len(input_ids):] for input_ids, output_ids in zip(input_ids, generated_ids)
|
207 |
-
# ]
|
208 |
-
|
209 |
-
# response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
210 |
-
# return response
|
211 |
-
# return "Success"
|
212 |
|
213 |
|
214 |
|
@@ -246,8 +230,6 @@ theme = gr.themes.Default(primary_hue="gray", secondary_hue="blue", neutral_hue=
|
|
246 |
with gr.Blocks(theme=theme) as demo:
|
247 |
title = gr.HTML(title)
|
248 |
description = gr.Markdown(description)
|
249 |
-
# login_button = gr.LoginButton()
|
250 |
-
# instr = gr.Markdown("Upload your paper in pdf format")
|
251 |
file_input = gr.File(file_types=[".pdf"], file_count="single")
|
252 |
paper_text_field= gr.Textbox("Upload a pdf or paste the full text of your paper in markdown format here.", label="Paper Text", lines=20, max_lines=20, autoscroll=False)
|
253 |
with gr.Accordion("Review Template", open=False):
|
@@ -259,14 +241,6 @@ with gr.Blocks(theme=theme) as demo:
|
|
259 |
|
260 |
review_field = gr.Markdown("\n\n\n\n\n", label="Review")
|
261 |
generate_button.click(fn=lambda: gr.update(interactive=False), inputs=None, outputs=generate_button).then(generate, [paper_text_field, review_template_field], review_field).then(fn=lambda: gr.update(interactive=True), inputs=None, outputs=generate_button)
|
262 |
-
|
263 |
-
# gr.Examples([
|
264 |
-
# ["examples/2105.04505v1.pdf", REVIEW_FIELDS]
|
265 |
-
# ],
|
266 |
-
# inputs=[paper_text_field, review_template_field],
|
267 |
-
# outputs=[review_field],
|
268 |
-
# fn=generate,
|
269 |
-
# cache_examples=True)
|
270 |
|
271 |
demo.title = "OpenReviewer"
|
272 |
|
|
|
21 |
MIN_LENGTH=200
|
22 |
settings.EXTRACT_IMAGES = False
|
23 |
settings.DEBUG = False
|
24 |
+
settings.PDFTEXT_CPU_WORKERS = 1
|
25 |
+
settings.DETECTOR_POSTPROCESSING_CPU_WORKERS = 1
|
26 |
+
settings.OCR_PARALLEL_WORKERS = 1
|
27 |
surya_settings.IN_STREAMLIT = True
|
28 |
|
29 |
model_refs = load_all_models()
|
|
|
179 |
|
180 |
@spaces.GPU(duration=90)
|
181 |
def generate(paper_text, review_template):
|
|
|
|
|
|
|
|
|
182 |
messages = create_messages(review_template, paper_text)
|
183 |
input_ids = tokenizer.apply_chat_template(
|
184 |
messages,
|
|
|
193 |
for new_text in streamer:
|
194 |
generated_text += new_text
|
195 |
yield generated_text.replace("<|eot_id|>", "")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
|
197 |
|
198 |
|
|
|
230 |
with gr.Blocks(theme=theme) as demo:
|
231 |
title = gr.HTML(title)
|
232 |
description = gr.Markdown(description)
|
|
|
|
|
233 |
file_input = gr.File(file_types=[".pdf"], file_count="single")
|
234 |
paper_text_field= gr.Textbox("Upload a pdf or paste the full text of your paper in markdown format here.", label="Paper Text", lines=20, max_lines=20, autoscroll=False)
|
235 |
with gr.Accordion("Review Template", open=False):
|
|
|
241 |
|
242 |
review_field = gr.Markdown("\n\n\n\n\n", label="Review")
|
243 |
generate_button.click(fn=lambda: gr.update(interactive=False), inputs=None, outputs=generate_button).then(generate, [paper_text_field, review_template_field], review_field).then(fn=lambda: gr.update(interactive=True), inputs=None, outputs=generate_button)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
|
245 |
demo.title = "OpenReviewer"
|
246 |
|