rjiang12 commited on
Commit
a444ecf
·
1 Parent(s): 2960381

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -5
app.py CHANGED
@@ -64,12 +64,10 @@ def generate_answer_vilt(processor, model, image, question):
64
  with torch.no_grad():
65
  outputs = model(**encoding)
66
  print(outputs.logits)
67
- lsm = torch.nn.LogSoftmax(dim=1)
68
- print(lsm(outputs.logits))
69
  predicted_class_idx = outputs.logits.argmax(-1).item()
70
- logitsList = outputs.logits.flatten().tolist()
71
- print(logitsList)
72
- maybeProbsList = [math.exp(i) for i in logitsList]
73
  return model.config.id2label[predicted_class_idx]
74
 
75
 
 
64
  with torch.no_grad():
65
  outputs = model(**encoding)
66
  print(outputs.logits)
67
+ print(torch.softmax(outputs.logits, dim=1))
 
68
  predicted_class_idx = outputs.logits.argmax(-1).item()
69
+ print(f"top2: {model.config.id2label[predicted_class_idx]}, {model.config.id2label[outputs.logits.argmax(-2).item()]}")
70
+ print(f"top2_: {outputs.logits.argmax(-1)}, {outputs.logits.argmax(-2)}")
 
71
  return model.config.id2label[predicted_class_idx]
72
 
73