Skip to content

Instantly share code, notes, and snippets.

@kurianbenoy
Created April 6, 2022 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurianbenoy/59bc813b535adc3a739f87dd4d4f4fb7 to your computer and use it in GitHub Desktop.
Save kurianbenoy/59bc813b535adc3a739f87dd4d4f4fb7 to your computer and use it in GitHub Desktop.
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