Spaces:
Running on Zero
Running on Zero
Upload app.py with huggingface_hub
Browse files
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 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
|