rjiang12 commited on
Commit
0432b3b
·
1 Parent(s): 28b536f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -54,7 +54,7 @@ def generate_answer_git(processor, model, image, question):
54
  # print(generated_ids)
55
  # generated_answer = processor.batch_decode(generated_ids.sequences, skip_special_tokens=True)
56
  # print(generated_answer)
57
- inputs = processor(images=image, text=question, add_special_tokens=False, return_tensors="pt")
58
  inputs["max_length"] = 20
59
  inputs["num_beams"] = 1
60
  inputs["do_sample"] = True
@@ -62,6 +62,8 @@ def generate_answer_git(processor, model, image, question):
62
  inputs["top_p"] = 0.95
63
 
64
  out = model.generate(**inputs)
 
 
65
  print(processor.batch_decode(out, skip_special_tokens=True))
66
 
67
  # encoding = processor(images=image, text=question, return_tensors="pt")
 
54
  # print(generated_ids)
55
  # generated_answer = processor.batch_decode(generated_ids.sequences, skip_special_tokens=True)
56
  # print(generated_answer)
57
+ inputs = processor(images=image, text=question, add_special_tokens=False, return_tensors="pt", return_dict_in_generate=True, output_scores=True)
58
  inputs["max_length"] = 20
59
  inputs["num_beams"] = 1
60
  inputs["do_sample"] = True
 
62
  inputs["top_p"] = 0.95
63
 
64
  out = model.generate(**inputs)
65
+ print(out.scores)
66
+ print(model.config.id2label)
67
  print(processor.batch_decode(out, skip_special_tokens=True))
68
 
69
  # encoding = processor(images=image, text=question, return_tensors="pt")