DeTikZify
Collection
Synthesizing Graphics Programs for Scientific Figures and Sketches with TikZ โข 13 items โข Updated โข 32
Run nllg/ultrasketch on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Use HF Jobs to fine-tune https://huggingface.co/nllg/ultrasketch. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Use HF Jobs to run batch inference with https://huggingface.co/nllg/ultrasketch on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
How to use nllg/ultrasketch with Diffusers:
pip install -U diffusers transformers accelerate
import torch
from diffusers import DiffusionPipeline
# switch to "mps" for apple devices
pipe = DiffusionPipeline.from_pretrained("nllg/ultrasketch", dtype=torch.bfloat16, device_map="cuda")
prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
image = pipe(prompt).images[0]UltraSketch is a diffusion model that has been trained primarily to convert scientific figures into sketches with a hand-drawn style. It is based on SD3_UltraEdit_w_mask and was fine-tuned on SketchFig. In addition, figures from DaTikZv2 rendered in a hand-drawn style using Rough.js, as well as the Sketchy Database and Photo Sketching datasets, have been used for data augmentation. Check out the DeTikZify project for more information.
from PIL import Image
from datasets import load_dataset
from diffusers import DiffusionPipeline
import torch
figure = load_dataset("nllg/datikz-v2", split="train")['image'][0]
pipe = DiffusionPipeline.from_pretrained(
pretrained_model_name_or_path="nllg/ultrasketch",
custom_pipeline="nllg/ultrasketch",
trust_remote_code=True,
torch_dtype=torch.float16,
device_map="balanced"
)
sketch = pipe(
prompt="Turn it into a hand-drawn sketch",
image=figure,
mask_img=Image.new("RGB", figure.size, "white"),
num_inference_steps=50,
image_guidance_scale=1.7,
guidance_scale=1.5,
strength=0.9
).images[0]
sketch.save("sketch.png")
Base model
BleachNick/SD3_UltraEdit_w_mask