File size: 752 Bytes
bbdc525
0cedc3a
013fbe9
 
7caf466
013fbe9
7caf466
5fee423
bbdc525
a55ed28
0cedc3a
013fbe9
 
 
 
64e11c7
5fee423
64e11c7
 
5fee423
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#TODO: integrate into markdown
#TODO: clean up output formatting
import gradio as gr
from gradio import mix
from transformers import pipeline, set_seed

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

def inference(text, seed):
    set_seed(int(seed))
    outtext = generator(text, max_length=100, num_return_sequences=1) #get the string from the return dict with key 'generated text'
    return outtext   
    
gr.Interface(
    inference, 
    [gr.inputs.Radio(choices=["trustworthy artificial intelligence"], label="input"), gr.inputs.Slider(minimum=0., maximum=1000.,label="seed")], 
    gr.outputs.Textbox(label="gpt-2 proposal"),
    cache_examples=True,
    allow_flagging="manual").launch(enable_queue=True)

#TODO: add credits at bottom