masapasa commited on
Commit
96f6d0f
1 Parent(s): 0281172

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -0
app.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline, set_seed
2
+ from transformers import BioGptTokenizer, BioGptForCausalLM
3
+ import gradio as gr
4
+ model = BioGptForCausalLM.from_pretrained("microsoft/biogpt")
5
+ tokenizer = BioGptTokenizer.from_pretrained("microsoft/biogpt")
6
+ generator = pipeline('text-generation', model=model, tokenizer=tokenizer)
7
+ set_seed(42)
8
+ def predict(text):
9
+ return generator(text, max_length=20, num_return_sequences=1, do_sample=True)
10
+ interface = gr.Interface(predict, "textbox", "textbox", title="Biogpt", description="Biogpt")
11
+ interface.launch()