Spaces:
Runtime error
Runtime error
created app
Browse files
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
# Load pre-trained model and tokenizer
|
5 |
+
model_name = "ferrazzipaulo/biobert-drug-interactions"
|
6 |
+
pipe = pipeline("text-classification", model=model_name)
|
7 |
+
|
8 |
+
def predict_drug_interaction(text):
|
9 |
+
result = pipe(text)
|
10 |
+
return result[0]['label'], result[0]['score']
|
11 |
+
|
12 |
+
demo = gr.Interface(
|
13 |
+
fn=predict_drug_interaction,
|
14 |
+
inputs=gr.Textbox(label="Enter a biomedical sentence"),
|
15 |
+
outputs=[
|
16 |
+
gr.Label(label="Prediction"),
|
17 |
+
gr.Number(label="Confidence Score")
|
18 |
+
],
|
19 |
+
title="Drug Interaction Predictor",
|
20 |
+
description="Detects whether two drugs are likely to interact based on biomedical text."
|
21 |
+
)
|
22 |
+
|
23 |
+
demo.launch()
|