Delete invalid empty config.json file
When I do this:
from transformers import pipeline
pipe = pipeline("image-text-to-text", model="microsoft/OmniParser-v2.0")
I get this error OSError: It looks like the config file at '/home/user/.cache/huggingface/hub/models--microsoft--OmniParser-v2.0/snapshots/09fae83e39987d4c19e676253380033a0603dbc3/config.json' is not a valid JSON file.
When I look at the file, it is indeed blank.
Presumably before it was added, it was working.
For reference, the HuggingFace demo uses a way of loading that avoids the typical loading path by using Ultralytics YOLO and the AutoModelForCausalLM (from the HF library), but with a specific path:
From utils.py:
def get_yolo_model(model_path):
from ultralytics import YOLO
# Load the model.
model = YOLO(model_path)
return model
from transformers import AutoProcessor, AutoModelForCausalLM
processor = AutoProcessor.from_pretrained("microsoft/Florence-2-base", trust_remote_code=True)
if device == 'cpu':
model = AutoModelForCausalLM.from_pretrained(model_name_or_path, torch_dtype=torch.float32, trust_remote_code=True)
else:
model = AutoModelForCausalLM.from_pretrained(model_name_or_path, torch_dtype=torch.float16, trust_remote_code=True).to(device)
get_caption_model_processor in https://huggingface.co/spaces/microsoft/OmniParser-v2/blob/0ef105dfdc899661d9c48c900dc599f8b296308a/util/utils.py#L62-L67
As used by app.py:
from huggingface_hub import snapshot_download
# Define repository and local directory
repo_id = "microsoft/OmniParser-v2.0" # HF repo
local_dir = "weights" # Target local directory
# Download the entire repository
snapshot_download(repo_id=repo_id, local_dir=local_dir)
...
yolo_model = get_yolo_model(model_path='weights/icon_detect/model.pt')
caption_model_processor = get_caption_model_processor(model_name="florence2", model_name_or_path="weights/icon_caption")
See:
https://huggingface.co/spaces/microsoft/OmniParser-v2/blob/0ef105dfdc899661d9c48c900dc599f8b296308a/util/utils.py
https://huggingface.co/spaces/microsoft/OmniParser-v2/blob/0ef105dfdc899661d9c48c900dc599f8b296308a/app.py