|
from transformers import pipeline |
|
from gradio import Interface |
|
import gradio as gr |
|
|
|
|
|
MODELS = { |
|
"FB": "facebook/xglm-1.7B", |
|
"Stylz": "GraphicStylz/Stylz", |
|
"GPT2": "datificate/gpt2-small-spanish", |
|
"OpenAssistant":"OpenAssistant/oasst-sft-7-llama-30b-xor" |
|
} |
|
|
|
|
|
def generate_and_analyze(model_name, input_text): |
|
|
|
model = MODELS[model_name] |
|
text_generator = pipeline('text-generation', model=model) |
|
result = text_generator(input_text, max_length=10, do_sample=True)[0] |
|
return result['generated_text'] |
|
|
|
|
|
iface = gr.Interface( |
|
fn=generate_and_analyze, |
|
inputs=[ |
|
gr.inputs.Dropdown(choices=list(MODELS.keys()), label="Model"), |
|
gr.inputs.Textbox(lines=2, label="Input Text") |
|
], |
|
outputs="text" |
|
) |
|
iface.launch() |
|
|