File size: 1,444 Bytes
a06a4d2 e4b1b54 a06a4d2 e4b1b54 a06a4d2 a36827f 2c76ec9 a36827f a5a49b1 a06a4d2 9a889c4 a06a4d2 7cdcd70 a36827f a06a4d2 9ccafb6 a06a4d2 a5a49b1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
import gradio as gr
import requests
import os
# from dotenv import load_dotenv
# load_dotenv()
API_URL = os.getenv("API_URL")
AUTH_TOKEN = os.getenv("AUTH_TOKEN")
headers = {"Authorization": f"Bearer {AUTH_TOKEN}"}
def postproccess(responce):
try:
return ' '.join(x['entity_group'] for x in responce)
except Exception as ex:
print(list(responce.items()))
print(f"Exception: {ex}")
# return f"Exception: {ex}"
return query(inp.value)
def query(request):
response = requests.post(API_URL, headers=headers, json=request)
return postproccess(response.json())
with gr.Blocks() as demo:
gr.Markdown(
"""
# Модель для определения скелетной структуры текста
Это веб-приожение демонстрирует работу модели.
- [Модель](https://huggingface.co/disk0dancer/ruBert-base-finetuned-pos)
- [Проект](https://huggingface.co/spaces/disk0dancer/demo-rubert-base-finetuned-pos)
- [Код и Документация](https://github.com/disk0Dancer/rubert-finetuned-pos)
""")
inp = gr.Textbox(placeholder="Введите текст на русском языке...", label="input")
out = gr.Textbox(label="output")
inp.change(query, inp, out)
with open('tags.txt', 'r') as f:
gr.Markdown(f.read())
if __name__ == "__main__":
demo.launch() |