Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
from simpletransformers.classification import ClassificationModel
|
| 4 |
+
|
| 5 |
+
import os
|
| 6 |
+
import numpy as np
|
| 7 |
+
|
| 8 |
+
np.random.seed(123)
|
| 9 |
+
|
| 10 |
+
# Set the Streamlit app title
|
| 11 |
+
st.title("Molecule Toxicity Predictions")
|
| 12 |
+
|
| 13 |
+
# Set the model path
|
| 14 |
+
path = 'ToxicityPrediction/Models/transformers/checkpoint-149-epoch-1'
|
| 15 |
+
|
| 16 |
+
# Load the model from the stage
|
| 17 |
+
#loaded_model = ClassificationModel('roberta', path, use_cuda = False)
|
| 18 |
+
rob_chem_model = ClassificationModel('roberta', 'seyonec/SMILES_tokenized_PubChem_shard00_160k',use_cuda=False ,args={'evaluate_each_epoch':True , 'evaluate_during_training_verbose':True, })
|
| 19 |
+
# Predict based on the input
|
| 20 |
+
target_name= st.text_input('Enter a SMILES string:')
|
| 21 |
+
predict_toxicity = st.button('Predict Toxicity')
|
| 22 |
+
if predict_toxicity:
|
| 23 |
+
predictions, raw_outputs = rob_chem_model.predict([str(target_name)])
|
| 24 |
+
df_pred = pd.DataFrame({'predictions': predictions, 'raw_outputs_lowerbound': raw_outputs[0][0], 'raw_outputs_upperbound': raw_outputs[0][0]})
|
| 25 |
+
st.dataframe(df_pred)
|