4eJIoBek commited on
Commit
20bbb99
1 Parent(s): b6d7129

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +21 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ generator = pipeline('text-generation', model='sberbank-ai/rugpt3large_based_on_gpt2')
5
+
6
+ def generate(text):
7
+ result = generator(text, max_length=200, temperature=0.7, num_return_sequences=1, do_sample=True)
8
+ return result[0]["generated_text"]
9
+
10
+ examples = [
11
+ ["Александр Сергеевич Пушкин известен нам не только евгением онегиным, но и своими сказками, среди которых:"],
12
+ ]
13
+
14
+ demo = gr.Interface(
15
+ fn=generate,
16
+ inputs = gr.inputs.Textbox(lines=3, label="Input Text"),
17
+ outputs=gr.outputs.Textbox(label="Generated Text"),
18
+ examples=examples
19
+ )
20
+
21
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ transformers
2
+ gradio
3
+ torch