Spaces:
Sleeping
Sleeping
Update app.py
Browse files1 unmodified line2345678912 unmodified lines2223242526272829303132333435363738394041421 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 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...")# 3. Load using custom remote code loadersconfig = 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 151643model = AutoModel.from_pretrained(LOCAL_PATH,config=config,dtype=torch.bfloat16,trust_remote_code=True)@spaces.GPU(duration=60)1 unmodified line234567812 unmodified lines212223242526272829303132333435363738391 unmodified lineimport torchimport gradio as grimport spacesfrom 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 using custom remote scripts...")# 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)# 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,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