Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,8 +2,8 @@ import os
|
|
| 2 |
import torch
|
| 3 |
import gradio as gr
|
| 4 |
import spaces
|
| 5 |
-
#
|
| 6 |
-
from transformers import AutoConfig,
|
| 7 |
from huggingface_hub import snapshot_download
|
| 8 |
|
| 9 |
# 1. Configuration Settings
|
|
@@ -24,12 +24,15 @@ else:
|
|
| 24 |
|
| 25 |
print("Loading architecture layers from local storage...")
|
| 26 |
|
| 27 |
-
# 3. Load using
|
| 28 |
config = AutoConfig.from_pretrained(LOCAL_PATH, trust_remote_code=True)
|
| 29 |
tokenizer = AutoTokenizer.from_pretrained(LOCAL_PATH, trust_remote_code=True)
|
| 30 |
|
| 31 |
-
#
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
| 33 |
LOCAL_PATH,
|
| 34 |
config=config,
|
| 35 |
dtype=torch.bfloat16,
|
|
@@ -49,8 +52,8 @@ def generate_vector_icon(prompt_text):
|
|
| 49 |
"Output raw SVG xml code ONLY."
|
| 50 |
)
|
| 51 |
|
| 52 |
-
#
|
| 53 |
-
full_prompt = f"<|im_start|>system\n{system_rules}<|im_end|>\n<|im_start|>user\nIcon Request: {prompt_text}<|im_end|>\n<|im_start|>assistant\
|
| 54 |
|
| 55 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 56 |
model.to(device)
|
|
@@ -97,5 +100,4 @@ demo = gr.Interface(
|
|
| 97 |
)
|
| 98 |
|
| 99 |
if __name__ == "__main__":
|
| 100 |
-
# Maximize thread capacity to smoothly pool matching requests from your Mac client machines
|
| 101 |
demo.queue(default_concurrency_limit=1).launch(max_threads=10)
|
|
|
|
| 2 |
import torch
|
| 3 |
import gradio as gr
|
| 4 |
import spaces
|
| 5 |
+
# Use AutoModel to let trust_remote_code resolve the custom vector architecture cleanly
|
| 6 |
+
from transformers import AutoConfig, AutoModel, AutoTokenizer
|
| 7 |
from huggingface_hub import snapshot_download
|
| 8 |
|
| 9 |
# 1. Configuration Settings
|
|
|
|
| 24 |
|
| 25 |
print("Loading architecture layers from local storage...")
|
| 26 |
|
| 27 |
+
# 3. Load using custom remote code loaders
|
| 28 |
config = AutoConfig.from_pretrained(LOCAL_PATH, trust_remote_code=True)
|
| 29 |
tokenizer = AutoTokenizer.from_pretrained(LOCAL_PATH, trust_remote_code=True)
|
| 30 |
|
| 31 |
+
# Setting this manually patch-fixes the missing attribute crash
|
| 32 |
+
if not hasattr(config, "pad_token_id"):
|
| 33 |
+
config.pad_token_id = tokenizer.eos_token_id if tokenizer.eos_token_id is not None else 151643
|
| 34 |
+
|
| 35 |
+
model = AutoModel.from_pretrained(
|
| 36 |
LOCAL_PATH,
|
| 37 |
config=config,
|
| 38 |
dtype=torch.bfloat16,
|
|
|
|
| 52 |
"Output raw SVG xml code ONLY."
|
| 53 |
)
|
| 54 |
|
| 55 |
+
# Precise prompt architecture required for OmniSVG text-to-vector generations
|
| 56 |
+
full_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"
|
| 57 |
|
| 58 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 59 |
model.to(device)
|
|
|
|
| 100 |
)
|
| 101 |
|
| 102 |
if __name__ == "__main__":
|
|
|
|
| 103 |
demo.queue(default_concurrency_limit=1).launch(max_threads=10)
|