|
import gradio as gr |
|
from transformers import pipeline |
|
|
|
generator = pipeline('text-generation', model='mohsenfayyaz/mt5-small-query_realestate_cars-finetuned') |
|
|
|
def generate(text): |
|
result = generator(text, max_length=100, num_return_sequences=1) |
|
return result[0]["generated_text"] |
|
|
|
examples = [ |
|
["آپارتمان 100 متری توی پیروزی سه خواب"], |
|
["شمع 206"], |
|
] |
|
|
|
demo = gr.Interface( |
|
fn=generate, |
|
inputs=gr.inputs.Textbox(lines=1, label="Input Text"), |
|
outputs=gr.outputs.Textbox(label="Generated Text"), |
|
examples=examples, |
|
cache_examples=True, |
|
title="Query Information Extraction Demo", |
|
) |
|
|
|
demo.launch() |