Spaces:
Runtime error
Runtime error
File size: 2,030 Bytes
489c564 dd90f68 49ec14a ef3e238 f124040 d582d22 f124040 dc0dc06 f124040 ef3e238 49ec14a 9adf938 8e48d3e fadfca7 8d0ce31 8e48d3e cfa5afa 9adf938 4e07626 8e5c897 4e07626 19dae2f 2b84e99 19dae2f 8e48d3e 4a6889b 4e07626 cd9db19 4e8b19e cd9db19 8e48d3e 79f02c0 4e8b19e 79f02c0 8e48d3e 79f02c0 823a19b 6b5a3ad c9de4a3 8e48d3e 4e07626 74e89b2 |
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 47 48 49 50 51 52 53 |
import gradio as gr
from transformers import pipeline
examples = [
'Alisher Navoiy – ulug‘ o‘zbek va boshqa turkiy xalqlarning <mask>, mutafakkiri va davlat arbobi bo‘lgan.',
'Oʻzbekistonning poytaxti <mask> shahri boʻlib, davlat tili oʻzbek tili hisoblanadi.',
'Registon maydoni - tarixda shaharning ilm-fan, siyosat va <mask> markazi boʻlgan.',
'Venera - Quyosh tizimidagi o‘z o‘qi atrofida soat sohasi farqli ravishda aylanadigan yagona <mask>.',
'Kuchli yomg‘irlar tufayli bir qator <mask> kuchli sel oqishi kuzatildi.',
'Oʻzbekiston iqtisodiyoti bozor <mask> bosqichma-bosqich oʻtadi, tashqi savdo siyosati import oʻrnini bosishga asoslangan.'
]
models = [
"sinonimayzer/UzRoBERTa-v1",
"sinonimayzer/UzRoBERTa-v2",
"sinonimayzer/UzRoBERTa-v2",
"rifkat/uztext-3Gb-BPE-Roberta",
"tahrirchi/tahrirchi-bert-base",
]
def df(arr):
d = {}
for val in arr:
d[val['token_str']] = val['score']
return d
def fn(text):
arr = []
for model in models:
arr.append(df(pipeline("fill-mask", model=model)(text)))
return arr[0], arr[1], arr[2], arr[3], arr[4]
with gr.Blocks() as demo:
with gr.Row():
with gr.Column():
output0 = gr.Label(label=models[0])
with gr.Column():
output1 = gr.Label(label=models[1])
with gr.Column():
output2 = gr.Label(label=models[2])
with gr.Row():
with gr.Column():
output3 = gr.Label(label=models[3])
with gr.Column():
output4 = gr.Label(label=models[4])
with gr.Column():
input = gr.Textbox(label="Input", value=examples[0], lines=8, max_lines=8)
btn = gr.Button("Check")
gr.Examples(examples, fn=fn, inputs=[input], outputs=[output0, output1, output2, output3, output4], cache_examples=True, batch=True)
btn.click(fn, inputs=[input], outputs=[output0, output1, output2, output3, output4])
if __name__ == "__main__":
demo.queue().launch()
|