Spaces:
Sleeping
Sleeping
Update app.py
Browse files1 unmodified line23456567812 unmodified lines212223252425272627282931323334353031323334383935363738391 unmodified lineimport torchimport gradio as grimport spaces# Use AutoModel to let trust_remote_code resolve the custom vector architecture cleanlyfrom transformers import AutoConfig, AutoModel, AutoTokenizerfrom transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizerfrom huggingface_hub import snapshot_download
# 1. Configuration Settings12 unmodified lineselse: print(f"Found existing local weights at {LOCAL_PATH}. Loading directly...")
print("Loading architecture layers from local storage...")print("Loading architecture layers from local storage using custom remote scripts...")
# 3. Load using custom remote code loaders# 3. Load configuration and enforce remote script executionconfig = AutoConfig.from_pretrained(LOCAL_PATH, trust_remote_code=True)tokenizer = AutoTokenizer.from_pretrained(LOCAL_PATH, trust_remote_code=True)
# Setting this manually patch-fixes the missing attribute crashif not hasattr(config, "pad_token_id"): config.pad_token_id = tokenizer.eos_token_id if tokenizer.eos_token_id is not None else 151643
model = AutoModel.from_pretrained(# Enforcing trust_remote_code=True on AutoModelForCausalLM forces Hugging Face # to use the custom modeling_qwen2_5_vl.py script inside the weight directory.model = AutoModelForCausalLM.from_pretrained( LOCAL_PATH, config=config, dtype=torch.bfloat16, trust_remote_code=True torch_dtype=torch.bfloat16, trust_remote_code=True # <-- CRITICAL: Tells the factory to load custom keys mapping)
@spaces.GPU(duration=60)app.py+8-11