imperialwool commited on
Commit
2204e85
1 Parent(s): f942112

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -17
app.py CHANGED
@@ -92,7 +92,6 @@ def getBMFull(): return osuApi.getFull(request)
92
  ###############
93
  # LOAD MODELS
94
  sa_t, sa_m = AutoTokenizer.from_pretrained("cardiffnlp/twitter-xlm-roberta-base-sentiment"), AutoModelForSequenceClassification.from_pretrained("cardiffnlp/twitter-xlm-roberta-base-sentiment")
95
- ld_t, ld_m = AutoTokenizer.from_pretrained("papluca/xlm-roberta-base-language-detection"), AutoModelForSequenceClassification.from_pretrained("papluca/xlm-roberta-base-language-detection")
96
 
97
  ##############
98
  # ANALYZE DATA API
@@ -114,22 +113,6 @@ def sentimentAnalys():
114
  return {"status": "pass", "predicted_sentiment": predicted_sentiment}
115
  except Exception as e: return {"status": "error", "details": { "error_code": 123, "error_details": str(e).replace("\n", " | ") }}
116
 
117
- @app.route('/analyzeText/api/v1/detectLang', methods=['GET', 'POST'])
118
- def langDetect():
119
- try:
120
- text = request.form.get('text') or request.args.get('text') or request.values.get('text') or ""
121
- if text == "": return {"status": "error", "details": { "error_code": 101, "error_details": "No text provided" }}
122
-
123
- inputs = ld_t(text, return_tensors="pt")
124
-
125
- outputs = ld_m(**inputs)
126
- logits = outputs.logits
127
- predicted_language_index = logits.argmax(dim=1).item()
128
- predicted_language = ld_m.config.id2label[predicted_language_index]
129
-
130
- return {"status": "pass", "predicted_language": predicted_language}
131
- except Exception as e: return {"status": "error", "details": { "error_code": 123, "error_details": str(e).replace("\n", " | ") }}
132
-
133
  if __name__ == "__main__":
134
  config = configFile()
135
  with open(config['config-path'], "w") as outfile:
 
92
  ###############
93
  # LOAD MODELS
94
  sa_t, sa_m = AutoTokenizer.from_pretrained("cardiffnlp/twitter-xlm-roberta-base-sentiment"), AutoModelForSequenceClassification.from_pretrained("cardiffnlp/twitter-xlm-roberta-base-sentiment")
 
95
 
96
  ##############
97
  # ANALYZE DATA API
 
113
  return {"status": "pass", "predicted_sentiment": predicted_sentiment}
114
  except Exception as e: return {"status": "error", "details": { "error_code": 123, "error_details": str(e).replace("\n", " | ") }}
115
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  if __name__ == "__main__":
117
  config = configFile()
118
  with open(config['config-path'], "w") as outfile: