Skip to content

Tip: Alternative installation method using uv #61

@kawamou

Description

@kawamou

Summary

I successfully set up this project using uv instead of conda by modifying the existing pyproject.toml file. Sharing this for anyone who prefers uv over conda.

Environment

  • OS: Windows WSL (Ubuntu 24.04.1 LTS)
  • Python: 3.11+

What I did

I modified the existing pyproject.toml file to include all necessary dependencies. This allows users to install the project using uv commands as an alternative to the conda installation method described in the README.

Installation commands with uv

uv sync --no-dev
uv sync --dev --no-build-isolation

How to set it up

[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "starvector"
version = "1.0"
description = "Generating Scalable Vector Graphics Code from Images and Text"
readme = "README.md"
requires-python = ">=3.11"
classifiers = [
    "Programming Language :: Python :: 3",
    "License :: OSI Approved :: Apache Software License",
]
dependencies = [
    "torch==2.5.1",
    "torchvision==0.20.1",
    "transformers==4.49.0",
    "tokenizers==0.21.1",
    "sentencepiece==0.2.0",
    "accelerate",
    "pydantic==2.10",
    "markdown2[all]",
    "numpy<2.0.0",
    "scikit-learn==1.2.2",
    "gradio==3.36.1",
    "gradio_client==0.2.9",
    "requests",
    "httpx==0.24.0",
    "uvicorn",
    "fastapi",
    "svgpathtools==1.6.1",
    "seaborn==0.12.2",
    "taming-transformers",
    "lpips",
    "cairosvg",
    "beautifulsoup4",
    "webcolors",
    "tqdm",
    "omegaconf",
    "open-clip-torch",
    "noise",
    "datasets",
    "scikit-image",
    "fairscale",
    "lxml",
    "torch-fidelity",
    "clip-openai",
    "scipy==1.11.1",
    "sentence-transformers",
    "reportlab",
    "svglib",
    "Pillow",
    "protobuf",
    "openai",
    "hatchling>=1.27.0",
    "editables>=0.5",
    "wheel>=0.45.1",
    "deepspeed>=0.17.1",
]

[project.optional-dependencies]
train = ["deepspeed", "ninja", "wandb"]

[project.urls]
"Homepage" = "https://starvector.github.io"
"Bug Tracker" = "https://github.com/joanrod/starvector/issues"

[tool.setuptools.packages.find]
exclude = ["assets*", "benchmark*", "docs", "dist*", "playground*", "scripts*", "tests*"]

[tool.wheel]
exclude = ["assets*", "benchmark*", "docs", "dist*", "playground*", "scripts*", "tests*"]

[dependency-groups]
dev = [
    "flash-attn==2.7.3",
]

I tested this setup and it works well on my system. I was able to successfully run the example code from the README:

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions