Spaces:
Sleeping
Sleeping
Update app.py
Browse files1 unmodified line2345678914 unmodified lines24252627282930313233343513 unmodified lines495051525354555640 unmodified lines9798991001011 unmodified lineimport torchimport gradio as grimport spaces# Explicitly use Qwen2ForCausalLM to bypass strict configuration class validation loopsfrom transformers import AutoConfig, Qwen2ForCausalLM, AutoTokenizerfrom huggingface_hub import snapshot_download# 1. Configuration Settings14 unmodified linesprint("Loading architecture layers from local storage...")# 3. Load using explicit text-causal structuresconfig = AutoConfig.from_pretrained(LOCAL_PATH, trust_remote_code=True)tokenizer = AutoTokenizer.from_pretrained(LOCAL_PATH, trust_remote_code=True)# Calling the structural class directly avoids the AutoFactory ValueError validation mapping checkmodel = Qwen2ForCausalLM.from_pretrained(LOCAL_PATH,config=config,dtype=torch.bfloat16,13 unmodified lines"Output raw SVG xml code ONLY.")# Prompt injection syntax for text-space vector graphics backendsfull_prompt = f"<|im_start|>system\n{system_rules}<|im_end|>\n<|im_start|>user\nIcon Request: {prompt_text}<|im_end|>\n<|im_start|>assistant\nSVG Output:"device = "cuda" if torch.cuda.is_available() else "cpu"model.to(device)40 unmodified lines)if __name__ == "__main__":# Maximize thread capacity to smoothly pool matching requests from your Mac client machinesdemo.queue(default_concurrency_limit=1).launch(max_threads=10)1 unmodified line2345678914 unmodified lines24252627282930313233343536373813 unmodified lines525354555657585940 unmodified lines1001011021031 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 Settings14 unmodified linesprint("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,13 unmodified lines"Output raw SVG xml code ONLY.")# Precise prompt architecture required for OmniSVG text-to-vector generationsfull_prompt = f"<|im_start|>system\n{system_rules}<|im_end|>\n<|im_start|>user\nIcon Request: {prompt_text}<|im_end|>\n<|im_start|>assistant\n"device = "cuda" if torch.cuda.is_available() else "cpu"model.to(device)40 unmodified lines)if __name__ == "__main__":demo.queue(default_concurrency_limit=1).launch(max_threads=10)
app.py+10-8