| import gradio as gr | |
| from gliner import GLiNER | |
| model = GLiNER.from_pretrained("chris32/gliner_multi_pii_real_state-v2") | |
| model.eval() | |
| #text = """ | |
| #Casa en venta Valle de San Ángel, San Pedro Garza García**Para remodelar o demoler Casa de 1220 m2 de terreno y 1400 m2 de construcciónCasa de 3 niveles-Sala-Comedor-Cocina-Estancia-Preparación para alberca-Cochera para 3 autos techada -4 recamaras -Lavandería"Esta es una de las varias opciones que tenemos para ti. Somos una agencia de bienes raíces especializada en la venta y renta de vivienda residencial, te brindamos un servicio personalizado y de alta calidad. Si necesitas ayuda para comprar o rentar, contáctanos y uno de nuestros asesores te atenderá. | |
| #""" | |
| #for entity in entities: | |
| # print(entity["text"], "=>", entity["label"]) | |
| def generate_answer(text): | |
| labels = [ | |
| 'SUPERFICIE_JARDIN', | |
| 'NOMBRE_CLUB_GOLF', | |
| 'SUPERFICIE_TERRENO', | |
| 'SUPERFICIE_HABITABLE', | |
| 'SUPERFICIE_TERRAZA', | |
| 'NOMBRE_COMPLETO_ARQUITECTO', | |
| 'SUPERFICIE_BALCON', | |
| 'NOMBRE_DESARROLLO', | |
| 'NOMBRE_TORRE', | |
| 'NOMBRE_CONDOMINIO', | |
| 'AÑO_REMODELACIÓN' | |
| ] | |
| entities = model.predict_entities(text, labels, threshold=0.4) | |
| result_dict = entities | |
| return result_dict | |
| # Cambiar a entrada de texto | |
| #text_input = gr.inputs.Textbox(lines=15, label="Input Text") | |
| iface = gr.Interface( | |
| fn=generate_answer, | |
| inputs="text", | |
| outputs="text", | |
| title="Text Intelligence for Real State", | |
| description="Input text describing the property." | |
| ) | |
| iface.launch() | |