A vision-language model fine-tuned to convert presentation slides (images) into structured SVG format.
This model takes an image of a presentation slide and generates corresponding SVG markup, preserving:
1from unsloth import FastVisionModel
2from PIL import Image
3
4# Load model
5model, tokenizer = FastVisionModel.from_pretrained(
6 "Bombek1/slide2svg-vl-2b",
7 load_in_4bit=True, # or False for 16-bit
8)
9FastVisionModel.for_inference(model)
10
11# Prepare input
12image = Image.open("your_slide.png")
13messages = [
14 {
15 "role": "user",
16 "content": [
17 {"type": "image", "image": image},
18 {"type": "text", "text": "Convert this presentation slide to SVG format."}
19 ]
20 }
21]
22
23# Generate
24inputs = tokenizer.apply_chat_template(
25 messages,
26 tokenize=True,
27 add_generation_prompt=True,
28 return_tensors="pt",
29 return_dict=True,
30).to(model.device)
31
32outputs = model.generate(**inputs, max_new_tokens=4096, do_sample=False)
33generated_ids = outputs[0][inputs["input_ids"].shape[1]:]
34svg_output = tokenizer.decode(generated_ids, skip_special_tokens=True)
35
36print(svg_output)
1<?xml version="1.0" encoding="utf-8"?>
2<html>
3<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="768" fill="white">
4 <image x="0.0%" y="0.0%" width="100.0%" href="background.png" />
5 <g id="images">
6 <image x="14.3%" y="28.5%" width="35.8%" href="image_0.png" />
7 </g>
8 <g id="text">
9 <foreignObject x="5.4%" y="8.1%" width="32.0%" height="12.0%" overflow="visible">
10 <div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Inter; font-size: 74px; font-weight: bold; color: #000000;">
11 <div>Your Text Here</div>
12 </div>
13 </foreignObject>
14 </g>
15</svg>
16</html>