Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load a general text generation model
|
| 5 |
+
generator = pipeline("text-generation", model="bigscience/bloom-560m")
|
| 6 |
+
|
| 7 |
+
def answer_med_question(question):
|
| 8 |
+
# Generate answer
|
| 9 |
+
result = generator(question, max_length=200, do_sample=True)
|
| 10 |
+
return result[0]['generated_text']
|
| 11 |
+
|
| 12 |
+
demo = gr.Interface(
|
| 13 |
+
fn=answer_med_question,
|
| 14 |
+
inputs=gr.Textbox(label="Ask your medical question"),
|
| 15 |
+
outputs=gr.Textbox(label="AI Answer")
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
demo.launch()
|