joanrodai abhaypuri98 commited on
Commit
380ab95
·
verified ·
1 Parent(s): 5e6d1bb

Update model card readme.md (#1)

Browse files

- Update model card readme.md (44b4e9310df6faeac24dbc50079de7a9addd63e8)


Co-authored-by: Abhay Puri <[email protected]>

Files changed (1) hide show
  1. README.md +91 -139
README.md CHANGED
@@ -1,199 +1,151 @@
1
  ---
2
  library_name: transformers
3
- tags: []
 
 
4
  ---
5
 
6
- # Model Card for Model ID
7
-
8
- <!-- Provide a quick summary of what the model is/does. -->
9
 
 
10
 
 
11
 
12
  ## Model Details
13
 
14
  ### Model Description
15
 
16
- <!-- Provide a longer summary of what this model is. -->
17
 
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
 
 
 
 
19
 
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
 
28
- ### Model Sources [optional]
29
 
30
- <!-- Provide the basic links for the model. -->
 
 
 
31
 
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
35
 
36
- ## Uses
37
 
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
 
40
- ### Direct Use
 
41
 
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
 
44
- [More Information Needed]
45
 
46
- ### Downstream Use [optional]
47
 
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
 
50
- [More Information Needed]
51
 
52
  ### Out-of-Scope Use
53
 
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
-
56
- [More Information Needed]
57
 
58
  ## Bias, Risks, and Limitations
59
 
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
-
62
- [More Information Needed]
63
 
64
  ### Recommendations
65
 
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
-
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
 
70
  ## How to Get Started with the Model
71
 
72
  Use the code below to get started with the model.
73
 
74
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
  ## Training Details
77
-
78
  ### Training Data
79
-
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
-
82
- [More Information Needed]
83
 
84
  ### Training Procedure
85
-
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
-
88
- #### Preprocessing [optional]
89
-
90
- [More Information Needed]
91
-
92
-
93
- #### Training Hyperparameters
94
-
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
-
97
- #### Speeds, Sizes, Times [optional]
98
-
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
-
101
- [More Information Needed]
102
 
103
  ## Evaluation
104
-
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
-
107
- ### Testing Data, Factors & Metrics
108
-
109
  #### Testing Data
110
-
111
- <!-- This should link to a Dataset Card if possible. -->
112
-
113
- [More Information Needed]
114
 
115
  #### Factors
 
116
 
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
-
119
- [More Information Needed]
120
-
121
- #### Metrics
122
-
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
-
125
- [More Information Needed]
126
-
127
- ### Results
128
-
129
- [More Information Needed]
130
-
131
- #### Summary
132
-
133
-
134
-
135
- ## Model Examination [optional]
136
-
137
- <!-- Relevant interpretability work for the model goes here -->
138
-
139
- [More Information Needed]
140
-
141
- ## Environmental Impact
142
-
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
-
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
-
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
-
153
- ## Technical Specifications [optional]
154
-
155
- ### Model Architecture and Objective
156
-
157
- [More Information Needed]
158
-
159
- ### Compute Infrastructure
160
-
161
- [More Information Needed]
162
-
163
- #### Hardware
164
-
165
- [More Information Needed]
166
-
167
- #### Software
168
-
169
- [More Information Needed]
170
-
171
- ## Citation [optional]
172
-
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
-
175
- **BibTeX:**
176
-
177
- [More Information Needed]
178
 
179
- **APA:**
180
 
181
- [More Information Needed]
182
 
183
- ## Glossary [optional]
 
 
 
 
 
 
 
 
 
 
184
 
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
 
187
- [More Information Needed]
188
 
189
- ## More Information [optional]
 
190
 
191
- [More Information Needed]
192
 
193
- ## Model Card Authors [optional]
194
 
195
- [More Information Needed]
196
 
197
- ## Model Card Contact
198
 
199
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  library_name: transformers
3
+ license: apache-2.0
4
+ language:
5
+ - en
6
  ---
7
 
8
+ # Model Card for StarVector
 
 
9
 
10
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/65c27c201b5b51dd4814fcd2/ULL7FkrMHA38I8olD7nEh.png)
11
 
12
+ StarVector is a foundation model for generating Scalable Vector Graphics (SVG) code from images and text. It utilizes a Vision-Language Modeling architecture to understand both visual and textual inputs, enabling high-quality vectorization and text-guided SVG creation.
13
 
14
  ## Model Details
15
 
16
  ### Model Description
17
 
18
+ This is the model card for the StarVector model, a 🤗 transformers model. StarVector is a foundation model for generating Scalable Vector Graphics (SVG) code from images and text. It utilizes a Vision-Language Modeling architecture to understand both visual and textual inputs, enabling high-quality vectorization and text-guided SVG creation.
19
 
20
+ - **Developed by:** ServiceNow Research, Mila - Quebec AI Institute, ETS, Montreal.
21
+ - **Shared by :** Juan A Rodriguez, Abhay Puri, Shubham Agarwal, Issam H. Laradji, Sai Rajeswar, Pau Rodriguez, David Vazquez, Christopher Pal, Marco Pedersoli.
22
+ - **Model type:** Vision-Language Model for SVG Generation.
23
+ - **Language(s) (NLP):** English.
24
+ - **License:** Apache 2.0
25
 
26
+ ### Model Architecture
 
 
 
 
 
 
27
 
28
+ The StarVector architecture integrates an image encoder and a Large Language Model (LLM) Adapter to generate SVG code from both image and text inputs. Images are first converted into embeddings using a Vision Transformer (ViT), after which the LLM Adapter maps these embeddings into the LLM's embedding space to create visual tokens. Text prompts are handled through the LLM’s tokenizer and embedder. This unified multimodal approach ensures precise and contextually rich SVG output.
29
 
30
+ <figure>
31
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/65c27c201b5b51dd4814fcd2/IVGxASfNr8wfu-agH9Nqj.png" alt="Figure 2: StarVector Architecture">
32
+ <figcaption>Figure 2: a) StarVector Architecture: StarVector projects images into embeddings via an image encoder, then maps these embeddings to the LLM hidden space using an LLM Adapter, generating Visual Tokens. Text conditioning is achieved with the LLM's tokenizer and embedder. The model learns to map token sequences (visual or textual) to SVG code. The symbol ⊕ denotes mutually exclusive operations (image-to- SVG or text-to-SVG), while ‖ indicates sequence concatenation. Figure 2: b)Vision Model and Adapter: The image encoder employs a Vision Transformer (ViT) to process image patches sequentially. The LLM Adapter non-linearly projects embeddings into visual tokens for LLM integration.</figcaption>
33
+ </figure>
34
 
 
 
 
35
 
 
36
 
37
+ ### Model Sources
38
 
39
+ - **Repository:** [https://github.com/joanrod/star-vector](https://github.com/joanrod/star-vector)
40
+ - **Paper:** [https://arxiv.org/abs/2312.11556](https://arxiv.org/abs/2312.11556)
41
 
42
+ ## Uses
43
 
44
+ ### Direct Use
45
 
46
+ Image-to-SVG generation, Text-to-SVG generation.
47
 
48
+ ### Downstream Use
49
 
50
+ Creation of icons, logotypes, technical diagrams, and other vector graphics.
51
 
52
  ### Out-of-Scope Use
53
 
54
+ Generating realistic photographic images or complex 3D graphics.
 
 
55
 
56
  ## Bias, Risks, and Limitations
57
 
58
+ Potential biases may exist in the model due to the composition of the training data (SVG-Stack). The model's ability to perfectly vectorize all types of images and interpret all textual instructions may have limitations. Users should be aware of these potential issues, especially in critical applications.
 
 
59
 
60
  ### Recommendations
61
 
62
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. Further investigation into the model's behavior across different types of inputs is recommended.
 
 
63
 
64
  ## How to Get Started with the Model
65
 
66
  Use the code below to get started with the model.
67
 
68
+ ```Python
69
+ from PIL import Image
70
+ from transformers import AutoModelForCausalLM, AutoTokenizer, AutoProcessor
71
+ from starvector.data.util import process_and_rasterize_svg
72
+ import torch
73
+
74
+ model_name = "starvector/starvector-1b-im2svg"
75
+
76
+ starvector = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, trust_remote_code=True)
77
+ processor = starvector.model.processor
78
+ tokenizer = starvector.model.svg_transformer.tokenizer
79
+
80
+ starvector.cuda()
81
+ starvector.eval()
82
+
83
+ image_pil = Image.open('assets/examples/sample-18.png')
84
+
85
+ image = processor(image_pil, return_tensors="pt")['pixel_values'].cuda()
86
+ if not image.shape[0] == 1:
87
+ image = image.squeeze(0)
88
+ batch = {"image": image}
89
+
90
+ raw_svg = starvector.generate_im2svg(batch, max_length=4000)[0]
91
+ svg, raster_image = process_and_rasterize_svg(raw_svg)
92
+ ```
93
 
94
  ## Training Details
 
95
  ### Training Data
96
+ SVG-Stack: A dataset of over 2 million SVG samples.
 
 
 
97
 
98
  ### Training Procedure
99
+ The model utilizes a Vision-Language Modeling architecture. Images are projected into embeddings via an image encoder, then mapped to the LLM hidden space using an LLM Adapter, generating Visual Tokens. Text conditioning is achieved with the LLM's tokenizer and embedder. The model learns to map token sequences (visual or textual) to SVG code.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
  ## Evaluation
102
+ ### Testing Data & Factors
 
 
 
 
103
  #### Testing Data
104
+ SVG-Bench
 
 
 
105
 
106
  #### Factors
107
+ SVG-Stack, SVG-Fonts, SVG-Icons, SVG-Emoji, SVG-Diagrams.
108
 
109
+ ## Models
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
 
111
+ StarVector models achieve state-of-the-art performance on SVG generation tasks
112
 
113
+ We provide [Hugging Face 🤗 model checkpoints](https://huggingface.co/collections/starvector/starvector-models-6783b22c7bd4b43d13cb5289) for image2SVG vectorization, for 💫 StarVector-8B and 💫 StarVector-1B. These are the results on SVG-Bench, using the DinoScore metric.
114
 
115
+ | Method | SVG-Stack | SVG-Fonts | SVG-Icons | SVG-Emoji | SVG-Diagrams |
116
+ |--------------------|-----------|-----------|-----------|-----------|--------------|
117
+ | AutoTrace | 0.942 | 0.954 | 0.946 | 0.975 | 0.874 |
118
+ | Potrace | 0.898 | 0.967 | 0.972 | 0.882 | 0.875 |
119
+ | VTracer | 0.954 | 0.964 | 0.940 | 0.981 | 0.882 |
120
+ | Im2Vec | 0.692 | 0.733 | 0.754 | 0.732 | - |
121
+ | LIVE | 0.934 | 0.956 | 0.959 | 0.969 | 0.870 |
122
+ | DiffVG | 0.810 | 0.821 | 0.952 | 0.814 | 0.822 |
123
+ | GPT-4-V | 0.852 | 0.842 | 0.848 | 0.850 | - |
124
+ | 💫 **StarVector-1B** | 0.926 | 0.978 | 0.975 | 0.929 | 0.943 |
125
+ | 💫 **StarVector-8B** | 0.966 | 0.982 | 0.984 | 0.981 | 0.959 |
126
 
127
+ **Note:** StarVector models will not work for natural images or illustrations, as they have not been trained on those images. They excel in vectorizing icons, logotypes, technical diagrams, graphs, and charts.
128
 
129
+ As shown in the table above, StarVector-8B achieves the highest performance across all benchmark datasets, demonstrating its effectiveness in generating high-quality SVG code from images. The model's ability to understand and reproduce complex vector graphics makes it particularly valuable for applications requiring precise vectorization of icons, logos, and technical diagrams.
130
 
131
+ ## Summary
132
+ StarVector represents a significant advancement in the field of vector graphics generation. By combining the power of vision-language models with a comprehensive training dataset, we've created a system that can accurately translate images into high-quality SVG code. The model's performance on SVG-Bench demonstrates its effectiveness across a wide range of vector graphics tasks.
133
 
134
+ We believe that StarVector will enable new applications in design, illustration, and technical documentation, making vector graphics more accessible and easier to create. We invite the research community to build upon our work and explore new directions in this exciting field.
135
 
136
+ For more details, please refer to our [paper](https://arxiv.org/abs/2312.11556) and explore our [code](https://github.com/joanrod/star-vector) repository.
137
 
138
+ ## BibTeX entry and citation info
139
 
 
140
 
141
+ ```
142
+ @misc{rodriguez2024starvector,
143
+ title={StarVector: Generating Scalable Vector Graphics Code from Images and Text},
144
+ author={Juan A. Rodriguez and Abhay Puri and Shubham Agarwal and Issam H. Laradji and Pau Rodriguez and Sai Rajeswar and David Vazquez and Christopher Pal and Marco Pedersoli},
145
+ year={2024},
146
+ eprint={2312.11556},
147
+ archivePrefix={arXiv},
148
+ primaryClass={cs.CV},
149
+ url={https://arxiv.org/abs/2312.11556},
150
+ }
151
+ ```