katielink commited on
Commit
a0aaf13
β€’
1 Parent(s): 0b034a4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ from transformers import pipeline
4
+
5
+ name_list = ['microsoft/biogpt']
6
+
7
+ examples = [['COVID-19 is'],['A 65-year-old female patient with a past medical history of']]
8
+
9
+ pipe_biogpt = pipeline("text-generation", model="microsoft/biogpt")
10
+
11
+ title = "BioGPT Demo"
12
+ description = "Disclaimer: this demo was made for research purposes only and should not be used for medical purposes.\nModel: [BioGPT](https://huggingface.co/microsoft/biogpt)."
13
+
14
+ def inference(text):
15
+ output_biogpt = pipe_biogpt(text, max_length=100)[0]["generated_text"]
16
+ return [
17
+ output_biogpt,
18
+ ]
19
+
20
+ io = gr.Interface(
21
+ inference,
22
+ gr.Textbox(lines=3),
23
+ outputs=[
24
+ gr.Textbox(lines=3, label="BioGPT"),
25
+ ],
26
+ title=title,
27
+ description=description,
28
+ examples=examples
29
+ )
30
+ io.launch()