minhquang47 commited on
Commit
4345efc
·
verified ·
1 Parent(s): b16fe33

Upload 52 files

Browse files
Files changed (1) hide show
  1. submission_task1.py +3 -16
submission_task1.py CHANGED
@@ -69,20 +69,7 @@ except Exception as exc: # pragma: no cover - validator environment dependent
69
  build_structural_generative_vqa = None
70
 
71
 
72
- try:
73
- from src.postprocessing.answer_normalization import normalize_prediction
74
- except Exception: # pragma: no cover - fallback for lightweight smoke validation
75
- import re
76
-
77
- _SPACE_RE = re.compile(r"\s+")
78
- _LEADING_ANSWER_RE = re.compile(r"^\s*(?:answer\s*[:\-]\s*)+", re.IGNORECASE)
79
 
80
- def normalize_prediction(prediction: str, question: str = "") -> str:
81
- del question
82
- text = _SPACE_RE.sub(" ", str(prediction or "")).strip()
83
- text = _LEADING_ANSWER_RE.sub("", text)
84
- text = re.sub(r"\s+([,.;:!?])", r"\1", text)
85
- return _SPACE_RE.sub(" ", text).strip()
86
 
87
 
88
  CHECKPOINT_CANDIDATES = [
@@ -164,9 +151,9 @@ def _load_model_from_checkpoint(checkpoint_path: Path, device: torch.device):
164
  config.update(
165
  {
166
  "llm_name_or_path": train_args.get("llm_name_or_path", "Qwen/Qwen2.5-3B-Instruct"),
167
- "vision_pretrained": False,
168
  "vision_backend": train_args.get("vision_backend", "timm"),
169
- "freeze_vision_backbone": True,
170
  "freeze_llm": train_args.get("freeze_llm", True),
171
  }
172
  )
@@ -310,7 +297,7 @@ def predict_one(image: Image.Image, question: str, max_new_tokens: int = 48) ->
310
  question_text=[question],
311
  max_new_tokens=max_new_tokens,
312
  )[0]
313
- return normalize_prediction(prediction, question)
314
 
315
 
316
  def predict(batch: Iterable[Dict[str, Any]]) -> List[Dict[str, Any]]:
 
69
  build_structural_generative_vqa = None
70
 
71
 
 
 
 
 
 
 
 
72
 
 
 
 
 
 
 
73
 
74
 
75
  CHECKPOINT_CANDIDATES = [
 
151
  config.update(
152
  {
153
  "llm_name_or_path": train_args.get("llm_name_or_path", "Qwen/Qwen2.5-3B-Instruct"),
154
+ "vision_pretrained": train_args.get("vision_pretrained", True),
155
  "vision_backend": train_args.get("vision_backend", "timm"),
156
+ "freeze_vision_backbone": train_args.get("freeze_vision_backbone", True),
157
  "freeze_llm": train_args.get("freeze_llm", True),
158
  }
159
  )
 
297
  question_text=[question],
298
  max_new_tokens=max_new_tokens,
299
  )[0]
300
+ return prediction.strip()
301
 
302
 
303
  def predict(batch: Iterable[Dict[str, Any]]) -> List[Dict[str, Any]]: