shivamjadhav commited on
Commit
3a3df03
·
1 Parent(s): 39fd91a

updated the model labels and api code

Browse files
app.py CHANGED
@@ -6,14 +6,13 @@ model = get_model()
6
 
7
  @app.post("/predict")
8
  async def predict(issue: str):
9
- predictions = model.predict(issue)
 
10
  print(f"Predictions: {predictions}")
11
  id = predictions
12
  print(f"Predictions: {predictions}")
13
  return {
14
  "priority 1": str(predictions[0]),
15
  "priority 2": str(predictions[1]),
16
- "priority 3": str(predictions[2]),
17
- "priority 4": str(predictions[3]),
18
- "priority 5": str(predictions[4])
19
  }
 
6
 
7
  @app.post("/predict")
8
  async def predict(issue: str):
9
+ labels = ["No", "Yes"]
10
+ predictions,label = model.predict(issue)
11
  print(f"Predictions: {predictions}")
12
  id = predictions
13
  print(f"Predictions: {predictions}")
14
  return {
15
  "priority 1": str(predictions[0]),
16
  "priority 2": str(predictions[1]),
17
+ "Label":label
 
 
18
  }
classifier/Albert_latest.py CHANGED
@@ -1,5 +1,6 @@
1
  from transformers import AlbertTokenizer, AlbertForSequenceClassification
2
  import torch
 
3
 
4
  class Model:
5
  def __init__(self, model_weights):
@@ -27,16 +28,15 @@ class Model:
27
  outputs = self.model(**inputs)
28
 
29
  logits = outputs.logits
30
- print(f"logits: {logits}")
31
  predictions = torch.nn.functional.softmax(logits, dim=-1)
32
- return predictions[0].tolist()
 
33
 
34
  model_instance = None
35
- model_weights = "assets/albert_sentiment_checkpoint_58.pt"
 
36
  def get_model():
37
  global model_instance
38
  if model_instance is None:
39
  model_instance = Model(model_weights)
40
  return model_instance
41
-
42
-
 
1
  from transformers import AlbertTokenizer, AlbertForSequenceClassification
2
  import torch
3
+ import numpy as np
4
 
5
  class Model:
6
  def __init__(self, model_weights):
 
28
  outputs = self.model(**inputs)
29
 
30
  logits = outputs.logits
 
31
  predictions = torch.nn.functional.softmax(logits, dim=-1)
32
+ Labels = ["No", "Yes"]
33
+ return predictions[0].tolist()[:2],Labels[np.argmax(predictions)]
34
 
35
  model_instance = None
36
+ model_weights = "../assets/albert_sentiment_checkpoint_58.pt"
37
+
38
  def get_model():
39
  global model_instance
40
  if model_instance is None:
41
  model_instance = Model(model_weights)
42
  return model_instance
 
 
classifier/__pycache__/Albert_latest.cpython-311.pyc CHANGED
Binary files a/classifier/__pycache__/Albert_latest.cpython-311.pyc and b/classifier/__pycache__/Albert_latest.cpython-311.pyc differ