Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,11 +15,11 @@ torch.manual_seed(4)
|
|
| 15 |
np.random.seed(4)
|
| 16 |
|
| 17 |
|
| 18 |
-
def start_fastapi():
|
| 19 |
subprocess.Popen(["uvicorn", "fastapi_app:app", "--host", "0.0.0.0", "--port", "9999"])
|
| 20 |
|
| 21 |
# Start the FastAPI server
|
| 22 |
-
start_fastapi()
|
| 23 |
|
| 24 |
|
| 25 |
|
|
@@ -34,9 +34,9 @@ path = 'ToxicityPrediction/Models/transformers/checkpoint-149-epoch-1'
|
|
| 34 |
|
| 35 |
# Load the model from the stage
|
| 36 |
#loaded_model = ClassificationModel('roberta', path, use_cuda = False)
|
| 37 |
-
|
| 38 |
# Predict based on the input
|
| 39 |
-
|
| 40 |
#target_name= st.text_input('Enter a SMILES string:')
|
| 41 |
target_name = st.text_area("Enter smiles (one per line):", "")
|
| 42 |
|
|
@@ -44,7 +44,6 @@ target_name_list = target_name.splitlines()
|
|
| 44 |
target_name_list = [x.strip() for x in target_name_list]
|
| 45 |
predict_toxicity = st.button('Predict Toxicity')
|
| 46 |
if predict_toxicity:
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
pass
|
|
|
|
| 15 |
np.random.seed(4)
|
| 16 |
|
| 17 |
|
| 18 |
+
#def start_fastapi():
|
| 19 |
subprocess.Popen(["uvicorn", "fastapi_app:app", "--host", "0.0.0.0", "--port", "9999"])
|
| 20 |
|
| 21 |
# Start the FastAPI server
|
| 22 |
+
#start_fastapi()
|
| 23 |
|
| 24 |
|
| 25 |
|
|
|
|
| 34 |
|
| 35 |
# Load the model from the stage
|
| 36 |
#loaded_model = ClassificationModel('roberta', path, use_cuda = False)
|
| 37 |
+
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})
|
| 38 |
# Predict based on the input
|
| 39 |
+
rob_chem_model.model.eval()
|
| 40 |
#target_name= st.text_input('Enter a SMILES string:')
|
| 41 |
target_name = st.text_area("Enter smiles (one per line):", "")
|
| 42 |
|
|
|
|
| 44 |
target_name_list = [x.strip() for x in target_name_list]
|
| 45 |
predict_toxicity = st.button('Predict Toxicity')
|
| 46 |
if predict_toxicity:
|
| 47 |
+
predictions, raw_outputs = rob_chem_model.predict(target_name_list)
|
| 48 |
+
df_pred = pd.DataFrame({'Smiles':target_name_list,'Predictions': predictions})
|
| 49 |
+
st.dataframe(df_pred)
|
|
|