Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,7 +7,6 @@ import re
|
|
| 7 |
import numpy as np
|
| 8 |
import os
|
| 9 |
import shutil
|
| 10 |
-
from IPython.display import FileLink
|
| 11 |
from huggingface_hub import hf_hub_download
|
| 12 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 13 |
from sklearn.utils.class_weight import compute_class_weight
|
|
@@ -18,7 +17,7 @@ print(f"Using device: {device}")
|
|
| 18 |
|
| 19 |
# Model and dataset paths
|
| 20 |
model_name = "Fredaaaaaa/hybrid_model"
|
| 21 |
-
output_dir = "/
|
| 22 |
|
| 23 |
# Create output directory
|
| 24 |
os.makedirs(output_dir, exist_ok=True)
|
|
@@ -49,12 +48,10 @@ with open(os.path.join(output_dir, 'label_encoder.pkl'), 'wb') as f:
|
|
| 49 |
df.to_csv(os.path.join(output_dir, 'labeled_severity.csv'), index=False)
|
| 50 |
|
| 51 |
# Create zip archive
|
| 52 |
-
zip_path = "/
|
| 53 |
-
shutil.make_archive("/
|
| 54 |
print(f"📦 Model saved and zipped at: {zip_path}")
|
| 55 |
-
|
| 56 |
-
# Provide download link
|
| 57 |
-
display(FileLink('drug_interaction_model.zip'))
|
| 58 |
|
| 59 |
# Compute class weights
|
| 60 |
unique_classes = df['severity'].unique()
|
|
@@ -139,6 +136,7 @@ def get_smiles_from_api(drug_name):
|
|
| 139 |
if 'PropertyTable' in smiles_data and 'Properties' in smiles_data['PropertyTable']:
|
| 140 |
properties = smiles_data['PropertyTable']['Properties']
|
| 141 |
if properties and 'CanonicalSMILES' in properties[0]:
|
|
|
|
| 142 |
return properties[0]['CanonicalSMILES']
|
| 143 |
print(f"No SMILES found for drug {drug_name}")
|
| 144 |
return None
|
|
|
|
| 7 |
import numpy as np
|
| 8 |
import os
|
| 9 |
import shutil
|
|
|
|
| 10 |
from huggingface_hub import hf_hub_download
|
| 11 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 12 |
from sklearn.utils.class_weight import compute_class_weight
|
|
|
|
| 17 |
|
| 18 |
# Model and dataset paths
|
| 19 |
model_name = "Fredaaaaaa/hybrid_model"
|
| 20 |
+
output_dir = "/home/user/app/drug_interaction_model"
|
| 21 |
|
| 22 |
# Create output directory
|
| 23 |
os.makedirs(output_dir, exist_ok=True)
|
|
|
|
| 48 |
df.to_csv(os.path.join(output_dir, 'labeled_severity.csv'), index=False)
|
| 49 |
|
| 50 |
# Create zip archive
|
| 51 |
+
zip_path = "/home/user/app/drug_interaction_model.zip"
|
| 52 |
+
shutil.make_archive("/home/user/app/drug_interaction_model", 'zip', output_dir)
|
| 53 |
print(f"📦 Model saved and zipped at: {zip_path}")
|
| 54 |
+
print(f"To download, access the file at: {zip_path} from your environment or server.")
|
|
|
|
|
|
|
| 55 |
|
| 56 |
# Compute class weights
|
| 57 |
unique_classes = df['severity'].unique()
|
|
|
|
| 136 |
if 'PropertyTable' in smiles_data and 'Properties' in smiles_data['PropertyTable']:
|
| 137 |
properties = smiles_data['PropertyTable']['Properties']
|
| 138 |
if properties and 'CanonicalSMILES' in properties[0]:
|
| 139 |
+
print(f"SMILES found for {drug_name}: {properties[0]['CanonicalSMILES']}")
|
| 140 |
return properties[0]['CanonicalSMILES']
|
| 141 |
print(f"No SMILES found for drug {drug_name}")
|
| 142 |
return None
|