Spaces:
Runtime error
Runtime error
SantiagoMoreno-UdeA
commited on
Commit
β’
7bc122c
1
Parent(s):
0d201e3
Sync complete
Browse files- data/{train β NER/train}/test.txt +0 -0
- data/{train β NER/train}/train.txt +0 -0
- models/{CCC β NER/CCC}/best-model.pt +0 -0
- models/RC/new/rel2id.json +0 -1
- src/graph/GUI.py +9 -10
- src/graph/__pycache__/GUI.cpython-310.pyc +0 -0
- src/graph/__pycache__/GUI.cpython-311.pyc +0 -0
- src/scripts/__pycache__/functionsner.cpython-311.pyc +0 -0
- src/scripts/functionsner.py +8 -8
data/{train β NER/train}/test.txt
RENAMED
File without changes
|
data/{train β NER/train}/train.txt
RENAMED
File without changes
|
models/{CCC β NER/CCC}/best-model.pt
RENAMED
File without changes
|
models/RC/new/rel2id.json
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
{"Product-Producer": 0, "Cause-Effect": 1, "Content-Container": 2, "Component-Whole": 3, "Other": 4, "Entity-Destination": 5, "Instrument-Agency": 6, "Entity-Origin": 7, "Message-Topic": 8, "Member-Collection": 9}
|
|
|
|
src/graph/GUI.py
CHANGED
@@ -20,8 +20,7 @@ sys.path.insert(0, default_path+'/../scripts')
|
|
20 |
from src.scripts.functionsner import use_model, tag_sentence, json_to_txt, training_model, characterize_data, upsampling_data, usage_cuda, copy_data
|
21 |
from src.scripts.functionsrc import use_model_rc, training_model_rc, usage_cuda_rc
|
22 |
|
23 |
-
|
24 |
-
models.remove('RC')
|
25 |
models_rc = os.listdir(default_path+'/../../models/RC')
|
26 |
|
27 |
#-------------------------------------------Functions-----------------------------------------------
|
@@ -124,7 +123,7 @@ def Tagger_document_RC(Model, Input_file, Output_file, Cuda):
|
|
124 |
|
125 |
#---------------------------------GUI-------------------------------------
|
126 |
def execute_GUI():
|
127 |
-
global
|
128 |
with gr.Blocks(title='NER', css="#title {font-size: 150% } #sub {font-size: 120% } ") as demo:
|
129 |
|
130 |
gr.Markdown("Named Entity Recognition(NER) and Relation Classification (RC) by GITA and Pratec Group S.A.S.",elem_id="title")
|
@@ -138,7 +137,7 @@ def execute_GUI():
|
|
138 |
with gr.Tab("Sentence"):
|
139 |
with gr.Row():
|
140 |
with gr.Column():
|
141 |
-
b = gr.Radio(list(
|
142 |
inputs =[
|
143 |
b,
|
144 |
gr.Textbox(placeholder="Enter sentence here...", label='Sentence'),
|
@@ -150,7 +149,7 @@ def execute_GUI():
|
|
150 |
|
151 |
|
152 |
tagger_sen.click(Tagger_sentence, inputs=inputs, outputs=output)
|
153 |
-
b.change(fn=lambda value: gr.update(choices=list(os.listdir('../../models'))
|
154 |
gr.Examples(
|
155 |
|
156 |
examples=[
|
@@ -164,7 +163,7 @@ def execute_GUI():
|
|
164 |
with gr.Tab("Document"):
|
165 |
with gr.Row():
|
166 |
with gr.Column():
|
167 |
-
c = gr.Radio(list(
|
168 |
inputs =[
|
169 |
c,
|
170 |
gr.File(label='Input data file'),
|
@@ -178,18 +177,18 @@ def execute_GUI():
|
|
178 |
gr.File(),
|
179 |
]
|
180 |
|
181 |
-
|
182 |
-
|
183 |
|
184 |
tagger_json.click(Tagger_json, inputs=inputs, outputs=output)
|
185 |
-
c.change(fn=lambda value: gr.update(choices=list(os.listdir('../../models'))
|
186 |
|
187 |
|
188 |
with gr.Tab("Trainer"):
|
189 |
with gr.Row():
|
190 |
with gr.Column():
|
191 |
train_input = inputs =[
|
192 |
-
gr.Radio([True,False], label='Fast training', value=
|
193 |
gr.Textbox(placeholder="Enter model name here...", label='New model name'),
|
194 |
gr.Radio([True,False], label='Standard input', value=False),
|
195 |
gr.Textbox(placeholder="Enter path here...", label='Input data directory path'),
|
|
|
20 |
from src.scripts.functionsner import use_model, tag_sentence, json_to_txt, training_model, characterize_data, upsampling_data, usage_cuda, copy_data
|
21 |
from src.scripts.functionsrc import use_model_rc, training_model_rc, usage_cuda_rc
|
22 |
|
23 |
+
models_NER = os.listdir(default_path+'/../../models/NER')
|
|
|
24 |
models_rc = os.listdir(default_path+'/../../models/RC')
|
25 |
|
26 |
#-------------------------------------------Functions-----------------------------------------------
|
|
|
123 |
|
124 |
#---------------------------------GUI-------------------------------------
|
125 |
def execute_GUI():
|
126 |
+
global models_NER
|
127 |
with gr.Blocks(title='NER', css="#title {font-size: 150% } #sub {font-size: 120% } ") as demo:
|
128 |
|
129 |
gr.Markdown("Named Entity Recognition(NER) and Relation Classification (RC) by GITA and Pratec Group S.A.S.",elem_id="title")
|
|
|
137 |
with gr.Tab("Sentence"):
|
138 |
with gr.Row():
|
139 |
with gr.Column():
|
140 |
+
b = gr.Radio(list(models_NER), label='Model')
|
141 |
inputs =[
|
142 |
b,
|
143 |
gr.Textbox(placeholder="Enter sentence here...", label='Sentence'),
|
|
|
149 |
|
150 |
|
151 |
tagger_sen.click(Tagger_sentence, inputs=inputs, outputs=output)
|
152 |
+
b.change(fn=lambda value: gr.update(choices=list(os.listdir('../../models/NER'))), inputs=b, outputs=b)
|
153 |
gr.Examples(
|
154 |
|
155 |
examples=[
|
|
|
163 |
with gr.Tab("Document"):
|
164 |
with gr.Row():
|
165 |
with gr.Column():
|
166 |
+
c = gr.Radio(list(models_NER), label='Model')
|
167 |
inputs =[
|
168 |
c,
|
169 |
gr.File(label='Input data file'),
|
|
|
177 |
gr.File(),
|
178 |
]
|
179 |
|
180 |
+
models_NER = os.listdir(default_path+'/../../models/NER')
|
181 |
+
|
182 |
|
183 |
tagger_json.click(Tagger_json, inputs=inputs, outputs=output)
|
184 |
+
c.change(fn=lambda value: gr.update(choices=list(os.listdir('../../models/NER'))), inputs=c, outputs=c)
|
185 |
|
186 |
|
187 |
with gr.Tab("Trainer"):
|
188 |
with gr.Row():
|
189 |
with gr.Column():
|
190 |
train_input = inputs =[
|
191 |
+
gr.Radio([True,False], label='Fast training', value=False),
|
192 |
gr.Textbox(placeholder="Enter model name here...", label='New model name'),
|
193 |
gr.Radio([True,False], label='Standard input', value=False),
|
194 |
gr.Textbox(placeholder="Enter path here...", label='Input data directory path'),
|
src/graph/__pycache__/GUI.cpython-310.pyc
ADDED
Binary file (7.54 kB). View file
|
|
src/graph/__pycache__/GUI.cpython-311.pyc
CHANGED
Binary files a/src/graph/__pycache__/GUI.cpython-311.pyc and b/src/graph/__pycache__/GUI.cpython-311.pyc differ
|
|
src/scripts/__pycache__/functionsner.cpython-311.pyc
CHANGED
Binary files a/src/scripts/__pycache__/functionsner.cpython-311.pyc and b/src/scripts/__pycache__/functionsner.cpython-311.pyc differ
|
|
src/scripts/functionsner.py
CHANGED
@@ -44,11 +44,11 @@ def str2bool(v):
|
|
44 |
|
45 |
|
46 |
def copy_data(original_path):
|
47 |
-
data_folder = default_path + '/../../data/train'
|
48 |
copy_tree(original_path, data_folder)
|
49 |
|
50 |
def characterize_data():
|
51 |
-
data_folder = default_path + '/../../data/train'
|
52 |
columns = {0: 'text', 1:'ner'}
|
53 |
|
54 |
# init a corpus using column format, data folder and the names of the train, dev and test files
|
@@ -73,7 +73,7 @@ def characterize_data():
|
|
73 |
|
74 |
def upsampling_data(entities_to_upsample, probability, entities):
|
75 |
print('-'*20,'upsampling','-'*20)
|
76 |
-
data_folder = default_path + '/../../data/train'
|
77 |
columns = {'text':0, 'ner':1}
|
78 |
for m in ["SiS","LwTR","MR","SR", "MBT"]:
|
79 |
upsampler = upsampling_ner(data_folder+'/train.txt', entities+['O'], columns)
|
@@ -107,8 +107,8 @@ def usage_cuda(cuda):
|
|
107 |
def training_model(name, epochs=20):
|
108 |
#FUNCION
|
109 |
|
110 |
-
data_folder = default_path + '/../../data/train'
|
111 |
-
path_model = default_path + '/../../models/{}'.format(name)
|
112 |
if (os.path.isdir(path_model)): print('WARNING, model already exists will be overwritten')
|
113 |
columns = {0: 'text', 1:'ner'}
|
114 |
# init a corpus using column format, data folder and the names of the train, dev and test files
|
@@ -192,7 +192,7 @@ def tag_sentence(sentence, name):
|
|
192 |
|
193 |
|
194 |
#--------------Load the trained model-------------------------
|
195 |
-
path_model = default_path + '/../../models/{}'.format(name)
|
196 |
global tagger_sentence
|
197 |
|
198 |
if (not tagger_sentence):
|
@@ -239,7 +239,7 @@ def tag_sentence(sentence, name):
|
|
239 |
def use_model(name, path_data, output_dir):
|
240 |
|
241 |
#--------------Load the trained model-------------------------
|
242 |
-
path_model = default_path + '/../../models/{}'.format(name)
|
243 |
|
244 |
if not (os.path.isdir(path_model)):
|
245 |
print('Model does not exists')
|
@@ -427,7 +427,7 @@ def json_to_txt(path_data_documents):
|
|
427 |
id_in=groups_temp[0]
|
428 |
|
429 |
|
430 |
-
data_folder = default_path + '/../../data/train'
|
431 |
check_create(data_folder)
|
432 |
count = 0
|
433 |
with open(data_folder + '/{}.txt'.format(arch), mode='w', encoding='utf-8') as f:
|
|
|
44 |
|
45 |
|
46 |
def copy_data(original_path):
|
47 |
+
data_folder = default_path + '/../../data/NER/train'
|
48 |
copy_tree(original_path, data_folder)
|
49 |
|
50 |
def characterize_data():
|
51 |
+
data_folder = default_path + '/../../data/NER/train'
|
52 |
columns = {0: 'text', 1:'ner'}
|
53 |
|
54 |
# init a corpus using column format, data folder and the names of the train, dev and test files
|
|
|
73 |
|
74 |
def upsampling_data(entities_to_upsample, probability, entities):
|
75 |
print('-'*20,'upsampling','-'*20)
|
76 |
+
data_folder = default_path + '/../../data/NER/train'
|
77 |
columns = {'text':0, 'ner':1}
|
78 |
for m in ["SiS","LwTR","MR","SR", "MBT"]:
|
79 |
upsampler = upsampling_ner(data_folder+'/train.txt', entities+['O'], columns)
|
|
|
107 |
def training_model(name, epochs=20):
|
108 |
#FUNCION
|
109 |
|
110 |
+
data_folder = default_path + '/../../data/NER/train'
|
111 |
+
path_model = default_path + '/../../models/NER/{}'.format(name)
|
112 |
if (os.path.isdir(path_model)): print('WARNING, model already exists will be overwritten')
|
113 |
columns = {0: 'text', 1:'ner'}
|
114 |
# init a corpus using column format, data folder and the names of the train, dev and test files
|
|
|
192 |
|
193 |
|
194 |
#--------------Load the trained model-------------------------
|
195 |
+
path_model = default_path + '/../../models/NER/{}'.format(name)
|
196 |
global tagger_sentence
|
197 |
|
198 |
if (not tagger_sentence):
|
|
|
239 |
def use_model(name, path_data, output_dir):
|
240 |
|
241 |
#--------------Load the trained model-------------------------
|
242 |
+
path_model = default_path + '/../../models/NER/{}'.format(name)
|
243 |
|
244 |
if not (os.path.isdir(path_model)):
|
245 |
print('Model does not exists')
|
|
|
427 |
id_in=groups_temp[0]
|
428 |
|
429 |
|
430 |
+
data_folder = default_path + '/../../data/NER/train'
|
431 |
check_create(data_folder)
|
432 |
count = 0
|
433 |
with open(data_folder + '/{}.txt'.format(arch), mode='w', encoding='utf-8') as f:
|