File size: 2,249 Bytes
46f5a0c
 
 
 
 
 
 
 
 
 
 
198e2c6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e1dcbef
198e2c6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6b339ef
46f5a0c
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
51
52
53
54
55
56
57
58
59
60
61
import gradio as gr
from transformers import pipeline

generator = pipeline('text-generation', model = 'gpt2')

def text_generator(sample, max_length):
  outputs = generator(sample, max_length = int(max_length), num_return_sequences=3)
  return outputs[0]["generated_text"], outputs[1]["generated_text"], outputs[2]["generated_text"]

examples = [["Hello, I'm a language model", "45"], ["Hello, I'm a designer", "30"]]

css = """
footer {display:none !important}
.output-markdown{display:none !important}
.gr-button-primary {
    z-index: 14;
    height: 43px;
    width: 130px;
    left: 0px;
    top: 0px;
    padding: 0px;
    cursor: pointer !important; 
    background: none rgb(17, 20, 45) !important;
    border: none !important;
    text-align: center !important;
    font-family: Poppins !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    color: rgb(255, 255, 255) !important;
    line-height: 1 !important;
    border-radius: 12px !important;
    transition: box-shadow 200ms ease 0s, background 200ms ease 0s !important;
    box-shadow: none !important;
}
.gr-button-primary:hover{
    z-index: 14;
    height: 43px;
    width: 130px;
    left: 0px;
    top: 0px;
    padding: 0px;
    cursor: pointer !important;
    background: none rgb(66, 133, 244) !important;
    border: none !important;
    text-align: center !important;
    font-family: Poppins !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    color: rgb(255, 255, 255) !important;
    line-height: 1 !important;
    border-radius: 12px !important;
    transition: box-shadow 200ms ease 0s, background 200ms ease 0s !important;
    box-shadow: rgb(0 0 0 / 23%) 0px 1px 7px 0px !important;
}
.hover\:bg-orange-50:hover {
    --tw-bg-opacity: 1 !important;
    background-color: rgb(229,225,255) !important;
}
"""
demo = gr.Interface(fn=text_generator, inputs=[gr.Textbox(lines=2, placeholder="Enter sample text here", label="Sample text"), gr.Textbox(lines=1, label="Length of generated text")], outputs=[gr.Textbox(label="Generated text 1"), gr.Textbox(label="Generated text 2"), gr.Textbox(label="Generated text 3")],title="Text Generator | Data Science Dojo", examples=examples, css=css)
demo.launch( debug = True )