File size: 728 Bytes
0be1c7b
 
 
 
8be8be5
 
0be1c7b
8be8be5
 
0be1c7b
8be8be5
 
0be1c7b
8be8be5
 
 
0be1c7b
8be8be5
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import gradio as gr
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch

# ✅ Load from current directory where files are
model_path = "."

tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForSequenceClassification.from_pretrained(model_path)

def predict(text):
    inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
    with torch.no_grad():
        outputs = model(**inputs)
        pred = torch.argmax(outputs.logits, dim=1).item()
    return ["No interaction", "Mild", "Moderate", "Severe"][pred]

demo = gr.Interface(fn=predict, inputs="text", outputs="text", title="BioBERT Drug Interaction Predictor")
demo.launch()