Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,56 +1,3 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
from transformers import pipeline
|
3 |
-
|
4 |
-
# Загрузка модели для генерации текста
|
5 |
-
generator = pipeline("text-generation", model="gpt2")
|
6 |
-
|
7 |
-
# CSS стили
|
8 |
-
css = """
|
9 |
-
#generate {
|
10 |
-
width: 100%;
|
11 |
-
background: #e253dd !important;
|
12 |
-
border: none;
|
13 |
-
border-radius: 50px;
|
14 |
-
outline: none !important;
|
15 |
-
color: white;
|
16 |
-
}
|
17 |
-
#generate:hover {
|
18 |
-
background: #de6bda !important;
|
19 |
-
outline: none !important;
|
20 |
-
color: #fff;
|
21 |
-
}
|
22 |
-
#image_output {
|
23 |
-
display: flex;
|
24 |
-
justify-content: center;
|
25 |
-
}
|
26 |
-
footer {visibility: hidden !important;}
|
27 |
-
#image_output {
|
28 |
-
height: 100% !important;
|
29 |
-
}
|
30 |
-
"""
|
31 |
-
|
32 |
-
# Функция для генерации текста по prompt
|
33 |
-
def generate_text(prompt):
|
34 |
-
output = generator(prompt, max_length=600)[0]['generated_text']
|
35 |
-
return output
|
36 |
-
|
37 |
-
# Создание интерфейса Gradio
|
38 |
-
demo = gr.Interface(
|
39 |
-
fn=generate_text,
|
40 |
-
inputs="text",
|
41 |
-
outputs="text",
|
42 |
-
title="Text Generation Demo",
|
43 |
-
css=css
|
44 |
-
).launch()
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
# imports
|
55 |
import gradio as gr
|
56 |
import requests
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# imports
|
2 |
import gradio as gr
|
3 |
import requests
|