jfarray commited on
Commit
ed380d4
1 Parent(s): d9c939f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -17
app.py CHANGED
@@ -4,24 +4,16 @@ from datasets import load_dataset
4
  from sentence_transformers import SentenceTransformer, InputExample, losses, util, evaluation
5
  import pandas as pd
6
 
7
- def Main(Operacion, Modelo, Texto1, Texto2, File):
8
 
9
  error = ""
10
  modelResult = ""
11
 
12
- if File == None and Operacion == "Procesar Fichero":
13
- error = "Debe seleccionar un fichero"
14
- else:
15
- try:
16
- if Operacion == "Comparar Textos":
17
- data_test = []
18
- data_test.append(InputExample(guid= "", texts=[Texto1, Texto2], label=0))
19
- else:
20
- data_test = ConvertJsonToList(File.name)
21
-
22
- modelResult = TestModel('jfarray/Model_'+ Modelo +'_50_Epochs',data_test)
23
- except Exception as e:
24
- error = e
25
 
26
  return [error, modelResult]
27
 
@@ -83,15 +75,13 @@ Modelos = gr.inputs.Dropdown(["dccuchile_bert-base-spanish-wwm-uncased"
83
  , "paraphrase-multilingual-MiniLM-L12-v2"
84
  , "distiluse-base-multilingual-cased-v1"])
85
  Opciones = gr.inputs.Radio(["Comparar Textos", "Procesar Fichero"])
86
- Text1Input = gr.inputs.Textbox(lines=10, placeholder="Escriba el texto aqui ...")
87
- Text2Input = gr.inputs.Textbox(lines=10, placeholder="Escriba el otro texto aqui ...")
88
  FileInput = gr.inputs.File(file_count="single", type="file", label="Fichero Json")
89
  LabelOutput = gr.outputs.Label(num_top_classes=None, type="auto", label="")
90
  DataFrameOutput = gr.outputs.Dataframe(headers=["Hashed_id", "Nota", "Similitud Semántica"]
91
  , max_rows=20, max_cols=None, overflow_row_behaviour="paginate", type="auto", label="Resultado")
92
 
93
  iface = gr.Interface(fn=Main
94
- , inputs=[ Opciones, Modelos, Text1Input ,Text2Input, FileInput]
95
  , outputs=[LabelOutput, DataFrameOutput]
96
  , title = "Similitud Semántica de textos en Español de tamaño medio (200-250 palabras)"
97
  )
 
4
  from sentence_transformers import SentenceTransformer, InputExample, losses, util, evaluation
5
  import pandas as pd
6
 
7
+ def Main(Modelo, File):
8
 
9
  error = ""
10
  modelResult = ""
11
 
12
+ try:
13
+ data_test = ConvertJsonToList(File.name)
14
+ modelResult = TestModel('jfarray/Model_'+ Modelo +'_50_Epochs',data_test)
15
+ except Exception as e:
16
+ error = e
 
 
 
 
 
 
 
 
17
 
18
  return [error, modelResult]
19
 
 
75
  , "paraphrase-multilingual-MiniLM-L12-v2"
76
  , "distiluse-base-multilingual-cased-v1"])
77
  Opciones = gr.inputs.Radio(["Comparar Textos", "Procesar Fichero"])
 
 
78
  FileInput = gr.inputs.File(file_count="single", type="file", label="Fichero Json")
79
  LabelOutput = gr.outputs.Label(num_top_classes=None, type="auto", label="")
80
  DataFrameOutput = gr.outputs.Dataframe(headers=["Hashed_id", "Nota", "Similitud Semántica"]
81
  , max_rows=20, max_cols=None, overflow_row_behaviour="paginate", type="auto", label="Resultado")
82
 
83
  iface = gr.Interface(fn=Main
84
+ , inputs=[Modelos, FileInput]
85
  , outputs=[LabelOutput, DataFrameOutput]
86
  , title = "Similitud Semántica de textos en Español de tamaño medio (200-250 palabras)"
87
  )