Create new file
Browse files
app.py
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline, AutoTokenizer
|
3 |
+
|
4 |
+
scibert_tokenizer = AutoTokenizer.from_pretrained('allenai/scibert_scivocab_uncased')
|
5 |
+
|
6 |
+
classifier = pipeline("text-classification",
|
7 |
+
model="tugot17/S2ORC-topic-classificaton",
|
8 |
+
max_length=512,
|
9 |
+
tokenizer=scibert_tokenizer)
|
10 |
+
|
11 |
+
|
12 |
+
title_1 = "Type 2 Diabetes Mellitus, Oral Diabetic Medications, Insulin Therapy, and Overall Breast Cancer Risk"
|
13 |
+
abstract_1 = "Breast cancer is among the most common cancers worldwide. Diabetes is an important chronic health problem associated with insulin resistance, increased insulin level, changes in growth hormones and factors, and activation of mitogen-activating protein kinase (MAPK) pathways, leading to an increased breast cancer risk. This paper looked at the epidemiologic studies of the association between type 2 diabetes and risk of breast cancer and its effect on overall cancer-specific survival. The combined evidence overall supported a modest association between type 2 diabetes and the risk of breast cancer, which was found to be more prevalent among postmenopausal women. Effect of oral diabetics and insulin therapy on breast cancer risk was also evaluated. It was found that metformin and thiazolidinones tended to have a protective role. Metformin therapy trials for its use as an adjuvant for breast cancer treatment are still ongoing. Sulfonylurea and insulin therapy were found to be mildly associated with increased overall cancers. No evidence or studies evaluated the association of DPPIV inhibitors and GLP 1 agonists with breast cancer risk because of their recent introduction into the management of diabetes."
|
14 |
+
text_1 = """During the 2 nd International Go Game Science Conference, held within the LIX European Go Congress (Liberec, CZ) on the 29 th -30 th July 2015, we presented PhotoKifu, 1 a software for Windows operating systems indeed able to reconstruct the record of a Go game from a series of photographs taken during the game itself, each one after each move played. We described the program in detail, explaining the importance of taking each photograph immediately after a stone had been released on the goban; we described the algorithms employed to first identify the grid on the goban, also inferring the position and orientation of the camera, then to track the grid through the pictures (in order to compensate for small, accidental movements like some bumping on the table and so on), and eventually to detect every new stone placed on the goban. We also described how to avoid false negatives (stones not detected), false positives (stones wrongly detected), how to circumvent problems caused by "disturbance" (for example, hands of the players still visible in the pictures) as well as missing or duplicate pictures and how, in the worst cases, manual correction of the moves is allowed. The performance of the program was """
|
15 |
+
|
16 |
+
title_2 = "The NUCLEON space experiment"
|
17 |
+
abstract_2 = "The NUCLEON satellite experiment is designed to investigate directly, above the atmosphere, the energy spectra of cosmic-ray nuclei and the chemical composition (Z= 1 β 30) at energy range 100GeV- 1000 TeV. The effective geometric factor is more than 0.2m 2 sr for nuclei and 0.06 m 2 sr for electrons. The planned exposition time is more than 5 years. 1. The aims of the NUCLEON experiment The NUCLEON satellite experiment is designed to investigate directly, above the atmosphere, the energy spectra of cosmic-ray nuclei and the chemical composition from 100GeV to 1000TeV (before the \"knee\"). The additional aim is the cosmic-ray electron spectrum measurement (from 20GeV to 3TeV)."
|
18 |
+
text_2 = """ During the 2 nd International Go Game Science Conference, held within the LIX European Go Congress (Liberec, CZ) on the 29 th -30 th July 2015, we presented PhotoKifu, 1 a software for Windows operating systems indeed able to reconstruct the record of a Go game from a series of photographs taken during the game itself, each one after each move played. We described the program in detail, explaining the importance of taking each photograph immediately after a stone had been released on the goban; we described the algorithms employed to first identify the grid on the goban, also inferring the position and orientation of the camera, then to track the grid through the pictures (in order to compensate for small, accidental movements like some bumping on the table and so on), """
|
19 |
+
|
20 |
+
class_map = {"LABEL_0": 'Biology π¦ π§¬π¦',
|
21 |
+
"LABEL_1": 'Chemistry π¨βπ¬βοΈπ¬',
|
22 |
+
"LABEL_2": 'Computer Science π€π»π',
|
23 |
+
"LABEL_3": 'Medicine ππ¨ββοΈπ©ββοΈ',
|
24 |
+
"LABEL_4": 'Physics ππ π',
|
25 |
+
}
|
26 |
+
|
27 |
+
['Biology', 'Chemistry', 'Computer Science', 'Medicine', 'Physics']
|
28 |
+
|
29 |
+
def predict(title:str, abstract: str, aricle_text):
|
30 |
+
output = {}
|
31 |
+
|
32 |
+
text = f"{title}\n {abstract}\n {aricle_text}"
|
33 |
+
|
34 |
+
for result in classifier(text, top_k=None):
|
35 |
+
label = class_map[result["label"]]
|
36 |
+
output[label] = result["score"]
|
37 |
+
|
38 |
+
return output
|
39 |
+
|
40 |
+
iface = gr.Interface(
|
41 |
+
fn=predict,
|
42 |
+
inputs=[gr.Textbox(lines=1, label="Title"),
|
43 |
+
gr.Textbox(lines=5, label="Absract"),
|
44 |
+
gr.Textbox(lines=5, label="Article Text")],
|
45 |
+
outputs=gr.Label(num_top_classes=5),
|
46 |
+
examples=[[title_1, abstract_1, text_1], [title_2, abstract_2, text_2]]
|
47 |
+
)
|
48 |
+
|
49 |
+
iface.launch()
|
50 |
+
|
51 |
+
|