Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,42 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
name_list = ['microsoft/biogpt', 'stanford-crfm/BioMedLM']
|
| 4 |
|
| 5 |
examples = [['COVID-19 is'],['A 65-year-old female patient with a past medical history of']]
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
def generate_biomedical(text):
|
| 8 |
interfaces = [gr.Interface.load(name) for name in name_list]
|
| 9 |
return [interface(text) for interface in interfaces]
|
|
@@ -28,4 +61,5 @@ with gr.Blocks() as demo:
|
|
| 28 |
gr.Markdown("Let’s compare!")
|
| 29 |
btn.click(generate_biomedical, inputs = input_text, outputs = [gr.Textbox(label=name_list[_], lines=4) for _ in range(len(name_list))])
|
| 30 |
|
| 31 |
-
demo.launch(enable_queue=True, debug=True)
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
import gradio as gr
|
| 3 |
+
import torch
|
| 4 |
+
import numpy as np
|
| 5 |
+
from transformers import pipeline
|
| 6 |
|
| 7 |
name_list = ['microsoft/biogpt', 'stanford-crfm/BioMedLM']
|
| 8 |
|
| 9 |
examples = [['COVID-19 is'],['A 65-year-old female patient with a past medical history of']]
|
| 10 |
|
| 11 |
+
#import torch
|
| 12 |
+
#print(f"Is CUDA available: {torch.cuda.is_available()}")
|
| 13 |
+
#print(f"CUDA device: {torch.cuda.get_device_name(torch.cuda.current_device())}")
|
| 14 |
+
|
| 15 |
+
pipe_biogpt = pipeline("text2text-generation", model="microsoft/biogpt")
|
| 16 |
+
pipe_biomedlm = pipeline("text2text-generation", model="stanford-crfm/BioMedLM")
|
| 17 |
+
|
| 18 |
+
title = "Compare generative biomedical LLMs!"
|
| 19 |
+
description = "This demo compares [BioGPT](https://huggingface.co/microsoft/biogpt) and [BioMedLM](https://huggingface.co/stanford-crfm/BioMedLM)."
|
| 20 |
+
|
| 21 |
+
def inference(text):
|
| 22 |
+
output_biogpt = pipe_biogpt(text, max_length=100)[0]["generated_text"]
|
| 23 |
+
output_biomedlm = pipe_biomedlm(text, max_length=100)[0]["generated_text"]
|
| 24 |
+
return [output_biogpt, output_biomedlm]
|
| 25 |
+
|
| 26 |
+
io = gr.Interface(
|
| 27 |
+
inference,
|
| 28 |
+
gr.Textbox(lines=3),
|
| 29 |
+
outputs=[
|
| 30 |
+
gr.Textbox(lines=3, label="BioGPT"),
|
| 31 |
+
gr.Textbox(lines=3, label="BioMedLM")
|
| 32 |
+
],
|
| 33 |
+
title=title,
|
| 34 |
+
description=description,
|
| 35 |
+
examples=examples
|
| 36 |
+
)
|
| 37 |
+
io.launch()
|
| 38 |
+
|
| 39 |
+
"""
|
| 40 |
def generate_biomedical(text):
|
| 41 |
interfaces = [gr.Interface.load(name) for name in name_list]
|
| 42 |
return [interface(text) for interface in interfaces]
|
|
|
|
| 61 |
gr.Markdown("Let’s compare!")
|
| 62 |
btn.click(generate_biomedical, inputs = input_text, outputs = [gr.Textbox(label=name_list[_], lines=4) for _ in range(len(name_list))])
|
| 63 |
|
| 64 |
+
demo.launch(enable_queue=True, debug=True)
|
| 65 |
+
"""
|