cheesecz commited on
Commit
fc43adb
·
verified ·
1 Parent(s): 3596833

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -5
app.py CHANGED
@@ -5,10 +5,8 @@ import torch
5
 
6
  os.environ["TRANSFORMERS_CACHE"] = "/tmp"
7
 
8
- # Initialize
9
  app = Flask(__name__)
10
 
11
- # Load model and tokenizer once
12
  MODEL_NAME = "s-nlp/roberta-base-formality-ranker"
13
  tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
14
  model = AutoModelForSequenceClassification.from_pretrained(MODEL_NAME)
@@ -40,10 +38,8 @@ def predict_formality():
40
 
41
  return jsonify({
42
  "text": text,
43
- "formality_score": round(score, 3),
44
  "formal_percent": formal_percent,
45
- "informal_percent": informal_percent,
46
- "classification": classification
47
  })
48
 
49
  if __name__ == "__main__":
 
5
 
6
  os.environ["TRANSFORMERS_CACHE"] = "/tmp"
7
 
 
8
  app = Flask(__name__)
9
 
 
10
  MODEL_NAME = "s-nlp/roberta-base-formality-ranker"
11
  tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
12
  model = AutoModelForSequenceClassification.from_pretrained(MODEL_NAME)
 
38
 
39
  return jsonify({
40
  "text": text,
 
41
  "formal_percent": formal_percent,
42
+ "informal_percent": informal_percent
 
43
  })
44
 
45
  if __name__ == "__main__":