multimodalart HF Staff commited on
Commit
dd09596
·
verified ·
1 Parent(s): 87a0421

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -24,10 +24,15 @@ def load_processor(mid):
24
  # which AutoImageProcessor needs. Materialize one from the nested dict.
25
  local = snapshot_download(mid, allow_patterns=["*.json", "*.jinja", "*.txt"])
26
  pre = os.path.join(local, "preprocessor_config.json")
27
- if not os.path.exists(pre):
28
- cfg = json.load(open(os.path.join(local, "processor_config.json")))
29
- with open(pre, "w") as f:
30
- json.dump(cfg.get("image_processor", {}), f)
 
 
 
 
 
31
  return AutoProcessor.from_pretrained(local, trust_remote_code=True)
32
 
33
 
 
24
  # which AutoImageProcessor needs. Materialize one from the nested dict.
25
  local = snapshot_download(mid, allow_patterns=["*.json", "*.jinja", "*.txt"])
26
  pre = os.path.join(local, "preprocessor_config.json")
27
+ cfg = json.load(open(os.path.join(local, "processor_config.json")))
28
+ img = dict(cfg.get("image_processor", {}))
29
+ # Drop image_processor_type: lfm2_vl ships only a *Fast* processor, so the
30
+ # exact "Lfm2VlImageProcessor" name won't resolve. Without it, AutoImageProcessor
31
+ # falls back to the lfm2_vl model_type mapping (which picks the Fast class)
32
+ # while still reading every param from this file. (Overwrite each boot.)
33
+ img.pop("image_processor_type", None)
34
+ with open(pre, "w") as f:
35
+ json.dump(img, f)
36
  return AutoProcessor.from_pretrained(local, trust_remote_code=True)
37
 
38