jonathanjordan21 commited on
Commit
28c31d6
1 Parent(s): 2cb17e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -34,7 +34,7 @@ def greet_json():
34
 
35
 
36
  @app.post("/language_detection")
37
- async def sentiment_score(inp: InputText):
38
  inputs = language_tokenizer(inp.text, return_tensors='pt')
39
  with torch.no_grad():
40
  logits = language_model(**inputs).logits
@@ -53,7 +53,7 @@ async def sentiment_score(inp: InputText):
53
  # Map the sorted indices back to the original tensor indices
54
  original_indices = torch.nonzero(mask, as_tuple=True)[1][sorted_indices]
55
 
56
- return [{"label":model.config.id2label[predicted_class_id.tolist()], "score":softmax[0, predicted_class_id].tolist()} for predicted_class_id in original_indices]
57
 
58
 
59
  @app.post("/sentiment_score")
 
34
 
35
 
36
  @app.post("/language_detection")
37
+ async def language_detection(inp: InputText):
38
  inputs = language_tokenizer(inp.text, return_tensors='pt')
39
  with torch.no_grad():
40
  logits = language_model(**inputs).logits
 
53
  # Map the sorted indices back to the original tensor indices
54
  original_indices = torch.nonzero(mask, as_tuple=True)[1][sorted_indices]
55
 
56
+ return [{"label":language_model.config.id2label[predicted_class_id.tolist()], "score":softmax[0, predicted_class_id].tolist()} for predicted_class_id in original_indices]
57
 
58
 
59
  @app.post("/sentiment_score")