Daeyongkwon98 commited on
Commit
7389783
1 Parent(s): 4811d2a

add others, none

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -68,15 +68,21 @@ def classify(sentence):
68
  probability_outputs = torch.sigmoid(outputs).cpu().detach().numpy()
69
 
70
  binary_outputs = (probability_outputs >= 0.5)
71
- binary_outputs[np.all(binary_outputs == False, axis=1), -1] = True
72
 
73
  intents = intents_dict[data_type]
74
  predicted_intents = [intent for i, intent in enumerate(intents) if binary_outputs[0][i] == 1]
75
 
76
  if data_type=="user":
77
- output += f"User Intents: {predicted_intents}\n"
 
 
 
78
  else:
79
- output += f"Musical Attributes: {predicted_intents}\n"
 
 
 
80
  return output
81
 
82
  title = "User Intents and Musical Attributes Classifier"
 
68
  probability_outputs = torch.sigmoid(outputs).cpu().detach().numpy()
69
 
70
  binary_outputs = (probability_outputs >= 0.5)
71
+ # binary_outputs[np.all(binary_outputs == False, axis=1), -1] = True
72
 
73
  intents = intents_dict[data_type]
74
  predicted_intents = [intent for i, intent in enumerate(intents) if binary_outputs[0][i] == 1]
75
 
76
  if data_type=="user":
77
+ if np.sum(binary_outputs)==0:
78
+ output += f"User Intents: ['others']\n"
79
+ else:
80
+ output += f"User Intents: {predicted_intents}\n"
81
  else:
82
+ if np.sum(binary_outputs)==0:
83
+ output += f"Musical Attributes: ['none']"
84
+ else:
85
+ output += f"Musical Attributes: {predicted_intents}\n"
86
  return output
87
 
88
  title = "User Intents and Musical Attributes Classifier"