Spaces:
Sleeping
Sleeping
File size: 1,540 Bytes
7553436 c869578 7553436 83b3c1b e79e84e 83b3c1b e79e84e c869578 7553436 e79e84e d4c8cfe e742e31 83b3c1b d4c8cfe 83b3c1b e79e84e 7553436 3048da6 7553436 3048da6 d4c8cfe a8f95cb d1d1da8 a8f95cb 7553436 d4c8cfe |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
import streamlit as st
import pandas as pd
from simpletransformers.classification import ClassificationModel
import torch
import random
import os
import numpy as np
import subprocess
import requests
random.seed(4)
np.random.seed(4)
torch.manual_seed(4)
np.random.seed(4)
#def start_fastapi():
# Start the FastAPI server
#start_fastapi()
# Set the Streamlit app title
st.title("Molecule Toxicity Predictions")
# Set the model path
path = 'ToxicityPrediction/Models/transformers/checkpoint-149-epoch-1'
# Load the model from the stage
#loaded_model = ClassificationModel('roberta', path, use_cuda = False)
#rob_chem_model = ClassificationModel('roberta', 'seyonec/SMILES_tokenized_PubChem_shard00_160k',use_cuda=False ,args={'evaluate_each_epoch':True , 'evaluate_during_training_verbose':True, 'seed':4})
# Predict based on the input
rob_chem_model = ClassificationModel('roberta', 'BasselAhmed/RobertaChemClinToxTuned',use_cuda=False ,args={'evaluate_each_epoch':True , 'evaluate_during_training_verbose':True, 'seed':4})
rob_chem_model.model.eval()
#target_name= st.text_input('Enter a SMILES string:')
target_name = st.text_area("Enter smiles (one per line):", "")
target_name_list = target_name.splitlines()
target_name_list = [x.strip() for x in target_name_list]
predict_toxicity = st.button('Predict Toxicity')
if predict_toxicity:
predictions, raw_outputs = rob_chem_model.predict(target_name_list)
df_pred = pd.DataFrame({'Smiles':target_name_list,'Predictions': predictions})
st.dataframe(df_pred)
|