Instructions to use starvector/starvector-8b-im2svg with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use starvector/starvector-8b-im2svg with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="starvector/starvector-8b-im2svg", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("starvector/starvector-8b-im2svg", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use starvector/starvector-8b-im2svg with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "starvector/starvector-8b-im2svg" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "starvector/starvector-8b-im2svg", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/starvector/starvector-8b-im2svg
- SGLang
How to use starvector/starvector-8b-im2svg with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "starvector/starvector-8b-im2svg" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "starvector/starvector-8b-im2svg", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "starvector/starvector-8b-im2svg" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "starvector/starvector-8b-im2svg", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use starvector/starvector-8b-im2svg with Docker Model Runner:
docker model run hf.co/starvector/starvector-8b-im2svg
Model availability
Hey everybody! Great work the model looks really promising!
However, your example of how to run the code sadly does not work. Always running into this problem while loading the model.
Encountered exception while importing starvector: No module named 'starvector'
Traceback (most recent call last):
File "/home/steven/Uni/semester2/Graph_Analytics/Data/test.py", line 8, in
starvector = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, trust_remote_code=True)
File "/home/steven/Uni/semester2/Graph_Analytics/sgc_venv/lib/python3.10/site-packages/transformers/models/auto/auto_factory.py", line 526, in from_pretrained
config, kwargs = AutoConfig.from_pretrained(
File "/home/steven/Uni/semester2/Graph_Analytics/sgc_venv/lib/python3.10/site-packages/transformers/models/auto/configuration_auto.py", line 1030, in from_pretrained
config_class = get_class_from_dynamic_module(
File "/home/steven/Uni/semester2/Graph_Analytics/sgc_venv/lib/python3.10/site-packages/transformers/dynamic_module_utils.py", line 541, in get_class_from_dynamic_module
final_module = get_cached_module_file(
File "/home/steven/Uni/semester2/Graph_Analytics/sgc_venv/lib/python3.10/site-packages/transformers/dynamic_module_utils.py", line 366, in get_cached_module_file
modules_needed = check_imports(resolved_module_file)
File "/home/steven/Uni/semester2/Graph_Analytics/sgc_venv/lib/python3.10/site-packages/transformers/dynamic_module_utils.py", line 198, in check_imports
raise ImportError(
ImportError: This modeling file requires the following packages that were not found in your environment: starvector. Run pip install starvector
I strictly used the model card code:
from PIL import Image
from transformers import AutoModelForCausalLM, AutoTokenizer, AutoProcessor
from starvector.data.util import process_and_rasterize_svg
import torch
model_name = "starvector/starvector-8b-im2svg"
starvector = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, trust_remote_code=True)
processor = starvector.model.processor
tokenizer = starvector.model.svg_transformer.tokenizer
starvector.cuda()
starvector.eval()
image_pil = Image.open('assets/examples/sample-18.png')
image = processor(image_pil, return_tensors="pt")['pixel_values'].cuda()
if not image.shape[0] == 1:
image = image.squeeze(0)
batch = {"image": image}
raw_svg = starvector.generate_im2svg(batch, max_length=4000)[0]
svg, raster_image = process_and_rasterize_svg(raw_svg)
Because star vector is not available on pip this effectively forces the user to clone the github repo to run the hugging face models, doesn't it? Could you include the whole setup in the example?