Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -22,7 +22,7 @@ class CFG():
|
|
22 |
num_return_sequences = 5
|
23 |
seed = 42
|
24 |
|
25 |
-
|
26 |
|
27 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
28 |
|
@@ -35,13 +35,15 @@ def seed_everything(seed=42):
|
|
35 |
torch.backends.cudnn.deterministic = True
|
36 |
seed_everything(seed=CFG.seed)
|
37 |
|
|
|
|
|
38 |
tokenizer = AutoTokenizer.from_pretrained(CFG.model_name_or_path, return_tensors='pt')
|
39 |
|
40 |
if CFG.model == 't5':
|
41 |
model = AutoModelForSeq2SeqLM.from_pretrained(CFG.model_name_or_path).to(device)
|
42 |
elif CFG.model == 'deberta':
|
43 |
model = EncoderDecoderModel.from_pretrained(CFG.model_name_or_path).to(device)
|
44 |
-
|
45 |
input_compound = CFG.input_data
|
46 |
min_length = min(input_compound.find('CATALYST') - input_compound.find(':') - 10, 0)
|
47 |
inp = tokenizer(input_compound, return_tensors='pt').to(device)
|
@@ -60,4 +62,5 @@ if type(mol) == None:
|
|
60 |
output += scores
|
61 |
output = [input_compound] + output
|
62 |
output_df = pd.DataFrame(np.array(output).reshape(1, -1), columns=['input'] + [f'{i}th' for i in range(CFG.num_beams)] + ['valid compound'] + [f'{i}th score' for i in range(CFG.num_beams)] + ['valid compound score'])
|
63 |
-
print(output)
|
|
|
|
22 |
num_return_sequences = 5
|
23 |
seed = 42
|
24 |
|
25 |
+
print('ok')
|
26 |
|
27 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
28 |
|
|
|
35 |
torch.backends.cudnn.deterministic = True
|
36 |
seed_everything(seed=CFG.seed)
|
37 |
|
38 |
+
print('ok')
|
39 |
+
print(CFG.input_data)
|
40 |
tokenizer = AutoTokenizer.from_pretrained(CFG.model_name_or_path, return_tensors='pt')
|
41 |
|
42 |
if CFG.model == 't5':
|
43 |
model = AutoModelForSeq2SeqLM.from_pretrained(CFG.model_name_or_path).to(device)
|
44 |
elif CFG.model == 'deberta':
|
45 |
model = EncoderDecoderModel.from_pretrained(CFG.model_name_or_path).to(device)
|
46 |
+
print('ok')
|
47 |
input_compound = CFG.input_data
|
48 |
min_length = min(input_compound.find('CATALYST') - input_compound.find(':') - 10, 0)
|
49 |
inp = tokenizer(input_compound, return_tensors='pt').to(device)
|
|
|
62 |
output += scores
|
63 |
output = [input_compound] + output
|
64 |
output_df = pd.DataFrame(np.array(output).reshape(1, -1), columns=['input'] + [f'{i}th' for i in range(CFG.num_beams)] + ['valid compound'] + [f'{i}th score' for i in range(CFG.num_beams)] + ['valid compound score'])
|
65 |
+
print(output)
|
66 |
+
print('ok')
|