Update synonymous_logit_processor.py
Browse files
synonymous_logit_processor.py
CHANGED
|
@@ -45,14 +45,18 @@ def generate_candidate_codons_with_generate(initial_codons, temperature=1.0, top
|
|
| 45 |
"""
|
| 46 |
# Use global variables if not provided as parameters
|
| 47 |
if model is None:
|
| 48 |
-
import
|
| 49 |
-
|
|
|
|
|
|
|
| 50 |
if model is None:
|
| 51 |
raise ValueError("Model not provided and no global 'model' variable found")
|
| 52 |
|
| 53 |
if tokenizer is None:
|
| 54 |
-
import
|
| 55 |
-
|
|
|
|
|
|
|
| 56 |
if tokenizer is None:
|
| 57 |
raise ValueError("Tokenizer not provided and no global 'tokenizer' variable found")
|
| 58 |
|
|
|
|
| 45 |
"""
|
| 46 |
# Use global variables if not provided as parameters
|
| 47 |
if model is None:
|
| 48 |
+
import inspect
|
| 49 |
+
# Check calling frame's globals and locals
|
| 50 |
+
frame = inspect.currentframe().f_back
|
| 51 |
+
model = frame.f_locals.get('model') or frame.f_globals.get('model')
|
| 52 |
if model is None:
|
| 53 |
raise ValueError("Model not provided and no global 'model' variable found")
|
| 54 |
|
| 55 |
if tokenizer is None:
|
| 56 |
+
import inspect
|
| 57 |
+
# Check calling frame's globals and locals
|
| 58 |
+
frame = inspect.currentframe().f_back
|
| 59 |
+
tokenizer = frame.f_locals.get('tokenizer') or frame.f_globals.get('tokenizer')
|
| 60 |
if tokenizer is None:
|
| 61 |
raise ValueError("Tokenizer not provided and no global 'tokenizer' variable found")
|
| 62 |
|