Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -14,6 +14,7 @@ from transformers import pipeline, AutoTokenizer
|
|
14 |
from transformers.pipelines.pt_utils import KeyDataset
|
15 |
|
16 |
from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
|
17 |
|
18 |
##os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "max_split_size_mb:512"
|
19 |
#os.environ['PYTORCH_CUDA_ALLOC_CONF'] = 'expandable_segments:True'
|
@@ -2012,7 +2013,24 @@ def nerBio(text, ModelsSelection, CategoriesSelection, ScoreFilt, EntityLinking,
|
|
2012 |
parser.add_argument("--virtuosokey_filename", type=str, default="", help="file location where it is stored the virtuoso endpoint dba pwd")
|
2013 |
parser.add_argument("--bioportalkey_filename", type=str, default="", help="file location where it is stored the NCBO BioPortal api key")
|
2014 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015 |
parser.add_argument("--USE_CACHE", type=str, default="False", help="whether to use cache for the NER and NEL tasks or not")
|
|
|
2016 |
parser.add_argument("--num_cores_eLinking", type=int, default=1, help="parallel processing for the entity linking process")
|
2017 |
|
2018 |
parser.add_argument("--computeEntityContext", type=str, default="False",
|
@@ -2026,15 +2044,6 @@ def nerBio(text, ModelsSelection, CategoriesSelection, ScoreFilt, EntityLinking,
|
|
2026 |
|
2027 |
parser.add_argument("--temperature", type=int, default=0.01)
|
2028 |
|
2029 |
-
#consose 20250205:
|
2030 |
-
#KGchoices = None
|
2031 |
-
# KGchoices = ['SNOMED', 'LOINC', 'ICD10', 'NCIT']
|
2032 |
-
#KGchoices = ['SNOMED', 'LOINC', 'ICD10', 'MESH', 'NCIT'] # restricts the input to these values only
|
2033 |
-
if KGchoices:
|
2034 |
-
KGchoices.sort()
|
2035 |
-
parser.add_argument("--KG_restriction", nargs='+', choices=KGchoices, default=KGchoices,
|
2036 |
-
help="List of ontologies to which restrict the entity linking task.")
|
2037 |
-
|
2038 |
args = parser.parse_args()
|
2039 |
|
2040 |
|
@@ -2348,6 +2357,8 @@ demo = gr.Interface(
|
|
2348 |
gr.CheckboxGroup(categories_List, label="CategoriesSelection", value=categories_List),
|
2349 |
gr.Slider(minimum=0, maximum=1.0, step=0.1, label="Score", value=0.5),
|
2350 |
gr.Checkbox(label="Enable Named-Entity Linking (NEL)", value=False), #True False
|
|
|
|
|
2351 |
gr.State(value={})
|
2352 |
],
|
2353 |
outputs=[
|
|
|
14 |
from transformers.pipelines.pt_utils import KeyDataset
|
15 |
|
16 |
from concurrent.futures import ThreadPoolExecutor, as_completed
|
17 |
+
from collections import Counter
|
18 |
|
19 |
##os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "max_split_size_mb:512"
|
20 |
#os.environ['PYTORCH_CUDA_ALLOC_CONF'] = 'expandable_segments:True'
|
|
|
2013 |
parser.add_argument("--virtuosokey_filename", type=str, default="", help="file location where it is stored the virtuoso endpoint dba pwd")
|
2014 |
parser.add_argument("--bioportalkey_filename", type=str, default="", help="file location where it is stored the NCBO BioPortal api key")
|
2015 |
|
2016 |
+
# consose 20250205:
|
2017 |
+
# KGchoices = None
|
2018 |
+
# KGchoices = ['SNOMED', 'LOINC', 'ICD10', 'NCIT']
|
2019 |
+
# KGchoices = ['SNOMED', 'LOINC', 'ICD10', 'MESH', 'NCIT'] # restricts the input to these values only
|
2020 |
+
if KGchoices:
|
2021 |
+
KGchoices.sort()
|
2022 |
+
parser.add_argument("--KG_restriction", nargs='+', choices=KGchoices, default=KGchoices,
|
2023 |
+
help="List of ontologies to which restrict the entity linking task.")
|
2024 |
+
# # consose 20250502:
|
2025 |
+
# if Counter(KGchoices) == Counter(POSSIBLE_KGchoices_List):
|
2026 |
+
# parser.add_argument("--USE_CACHE", type=str, default="True",
|
2027 |
+
# help="whether to use cache for the NER and NEL tasks or not")
|
2028 |
+
# else:
|
2029 |
+
# # print("Lists do not have the same elements")
|
2030 |
+
# parser.add_argument("--USE_CACHE", type=str, default="False",
|
2031 |
+
# help="whether to use cache for the NER and NEL tasks or not")
|
2032 |
parser.add_argument("--USE_CACHE", type=str, default="False", help="whether to use cache for the NER and NEL tasks or not")
|
2033 |
+
|
2034 |
parser.add_argument("--num_cores_eLinking", type=int, default=1, help="parallel processing for the entity linking process")
|
2035 |
|
2036 |
parser.add_argument("--computeEntityContext", type=str, default="False",
|
|
|
2044 |
|
2045 |
parser.add_argument("--temperature", type=int, default=0.01)
|
2046 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2047 |
args = parser.parse_args()
|
2048 |
|
2049 |
|
|
|
2357 |
gr.CheckboxGroup(categories_List, label="CategoriesSelection", value=categories_List),
|
2358 |
gr.Slider(minimum=0, maximum=1.0, step=0.1, label="Score", value=0.5),
|
2359 |
gr.Checkbox(label="Enable Named-Entity Linking (NEL)", value=False), #True False
|
2360 |
+
#gr.CheckboxGroup(POSSIBLE_KGchoices_List, label="KGchoices Selection", value=POSSIBLE_KGchoices_List, visible=True),
|
2361 |
+
gr.Dropdown(POSSIBLE_KGchoices_List, multiselect=True, label="KGchoices Selection", value=POSSIBLE_KGchoices_List),
|
2362 |
gr.State(value={})
|
2363 |
],
|
2364 |
outputs=[
|