-
-
Save kurianbenoy/59bc813b535adc3a739f87dd4d4f4fb7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
supported = ['a', 'b',..] | |
def load_model(source, target): | |
try: | |
if source == target: | |
raise AssertionError("source and target shouldn't be same") | |
if( source in supported) and (target in supported): | |
..... | |
if source == "ta": | |
raise ValueError("Not supported pair") | |
except AssertionError as e: | |
return {"inputerror": "Please enter required fields"} | |
except ValueError as e: | |
return {"error": e} | |
//Assume this as flask API endpoint | |
def predict_raw(X): | |
try: | |
tokenizer, model = load_model(X['s'], X['t']) | |
..... | |
return preds | |
except Exception as e: | |
return {"error": e} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment