EgorShibaev/TikZ-short-code
Viewer • Updated • 11.4k • 45 • 10
How to use waleko/TikZ-llava-1.5-7b with Transformers:
# Use a pipeline as a high-level helper
# Warning: Pipeline type "image-to-text" is no longer supported in transformers v5.
# You must load the model directly (see below) or downgrade to v4.x with:
# 'pip install "transformers<5.0.0'
from transformers import pipeline
pipe = pipeline("image-to-text", model="waleko/TikZ-llava-1.5-7b") # Load model directly
from transformers import AutoProcessor, AutoModelForImageTextToText
processor = AutoProcessor.from_pretrained("waleko/TikZ-llava-1.5-7b")
model = AutoModelForImageTextToText.from_pretrained("waleko/TikZ-llava-1.5-7b")Fine-tuned multimodal LLaVA model for TikZ diagram generation using hand-drawn sketches.
from transformers import pipeline
from PIL import Image
import requests
pipe = pipeline("image-to-text", model="waleko/TikZ-llava-1.5-7b")
url = "https://waleko.github.io/data/image.jpg"
image = Image.open(requests.get(url, stream=True).raw)
prompt = "Assistant helps to write down the TikZ code for the user's image. USER: <image>\nWrite down the TikZ code to draw the diagram shown in the image. ASSISTANT: "
print(pipe(image, prompt=prompt)[0]['generated_text'])
Trained on synthetic TikZ-short-code dataset.