Create 2
Browse files
2
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Создаем текстовую модель
|
5 |
+
generator = pipeline("text-generation", model="gpt2")
|
6 |
+
|
7 |
+
# Функция для генерации текста
|
8 |
+
def generate_text(prompt):
|
9 |
+
return generator(prompt, max_length=50, num_return_sequences=1)[0]['generated_text']
|
10 |
+
|
11 |
+
# Интерфейс
|
12 |
+
interface = gr.Interface(fn=generate_text, inputs="text", outputs="text")
|
13 |
+
interface.launch()
|