chendl commited on
Commit
7f3585f
1 Parent(s): 0ddf7b1

update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -12
app.py CHANGED
@@ -64,18 +64,28 @@ def get_outputs(
64
  ):
65
  # and torch.cuda.amp.autocast(dtype=torch.float16)
66
  with torch.inference_mode():
67
- outputs = model.generate(
68
- batch_images,
69
- input_ids,
70
  attention_mask=attention_mask,
71
- max_new_tokens=max_generation_length,
72
- min_length=min_generation_length,
73
- num_beams=num_beams,
74
- length_penalty=length_penalty,
75
- image_start_index_list=image_start_index_list,
76
  image_nums=image_nums,
77
- bad_words_ids=bad_words_ids,
 
 
78
  )
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
  return outputs
81
 
@@ -145,13 +155,11 @@ def generate(
145
  scores = outputs["scores"]
146
  if len(scores) > 0:
147
  box = boxes[scores.argmax()]
148
- iou = get_iou(box, gt_box)
149
  else:
150
  iou = 0.0
151
  # tqdm.write(f"output: {tokenizer.batch_decode(outputs)}")
152
  tqdm.write(f"no output for: {uniq_id}, {image_id}, {text}")
153
- if iou >= 0.5:
154
- correct += 1
155
 
156
 
157
  gen_text = tokenizer.batch_decode(outputs)
 
64
  ):
65
  # and torch.cuda.amp.autocast(dtype=torch.float16)
66
  with torch.inference_mode():
67
+ outputs = model(
68
+ vision_x=batch_images,
69
+ lang_x=input_ids,
70
  attention_mask=attention_mask,
71
+ labels=None,
 
 
 
 
72
  image_nums=image_nums,
73
+ image_start_index_list=image_start_index_list,
74
+ added_bbox_list=None,
75
+ add_box=False,
76
  )
77
+ # outputs = model.generate(
78
+ # batch_images,
79
+ # input_ids,
80
+ # attention_mask=attention_mask,
81
+ # max_new_tokens=max_generation_length,
82
+ # min_length=min_generation_length,
83
+ # num_beams=num_beams,
84
+ # length_penalty=length_penalty,
85
+ # image_start_index_list=image_start_index_list,
86
+ # image_nums=image_nums,
87
+ # bad_words_ids=bad_words_ids,
88
+ # )
89
 
90
  return outputs
91
 
 
155
  scores = outputs["scores"]
156
  if len(scores) > 0:
157
  box = boxes[scores.argmax()]
 
158
  else:
159
  iou = 0.0
160
  # tqdm.write(f"output: {tokenizer.batch_decode(outputs)}")
161
  tqdm.write(f"no output for: {uniq_id}, {image_id}, {text}")
162
+ print(f"{box}")
 
163
 
164
 
165
  gen_text = tokenizer.batch_decode(outputs)