Spaces:
Sleeping
Sleeping
File size: 1,091 Bytes
cbb029f 5fd6553 cbb029f 5fd6553 cbb029f 5fd6553 |
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 |
import gradio as gr
from transformers import pipeline
# Загрузка модели для генерации текста
generator = pipeline("text-generation", model="gpt2")
# CSS стили
css = """
#generate {
width: 100%;
background: #e253dd !important;
border: none;
border-radius: 50px;
outline: none !important;
color: white;
}
#generate:hover {
background: #de6bda !important;
outline: none !important;
color: #fff;
}
#image_output {
display: flex;
justify-content: center;
}
footer {visibility: hidden !important;}
#image_output {
height: 100% !important;
}
"""
# Функция для генерации текста по prompt
def generate_text(prompt):
output = generator(prompt, max_length=100)[0]['generated_text']
return output
# Создание интерфейса Gradio
demo = gr.Interface(
fn=generate_text,
inputs="text",
outputs="text",
layout="vertical",
title="Text Generation Demo",
css=css
)
# Запуск интерфейса
if __name__ == "__main__":
demo.launch()
|