Text Generation
Transformers
Safetensors
English
markupdm
graphic design
design completion
multimodal
markup document
custom_code
Instructions to use cyberagent/markupdm with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use cyberagent/markupdm with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="cyberagent/markupdm", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("cyberagent/markupdm", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use cyberagent/markupdm with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "cyberagent/markupdm" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cyberagent/markupdm", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/cyberagent/markupdm
- SGLang
How to use cyberagent/markupdm with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "cyberagent/markupdm" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cyberagent/markupdm", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "cyberagent/markupdm" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cyberagent/markupdm", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use cyberagent/markupdm with Docker Model Runner:
docker model run hf.co/cyberagent/markupdm
File size: 1,979 Bytes
0bdb3ea | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | import numpy as np
import torch
from PIL import Image
from transformers.image_processing_utils import BaseImageProcessor
from transformers.utils import logging
logger = logging.get_logger(__name__)
class VQModelImageProcessor(BaseImageProcessor): # type: ignore
def __init__(
self,
size: int = 256,
convert_rgb: bool = False,
resample: Image.Resampling = Image.Resampling.LANCZOS,
**kwargs: dict,
) -> None:
self.size = size
self.convert_rgb = convert_rgb
self.resample = resample
def __call__(self, image: Image.Image) -> dict:
return self.preprocess(image)
def preprocess(self, image: Image.Image) -> dict:
width, height = image.size
size = (self.size, self.size)
image = image.resize(size, resample=self.resample)
image = image.convert("RGBA")
if self.convert_rgb:
# Paste RGBA image on white background
image_new = Image.new("RGB", image.size, (255, 255, 255))
image_new.paste(image, mask=image.split()[3])
image = image_new
return {
"image": self.to_tensor(image),
"width": width,
"height": height,
}
def to_tensor(self, image: Image.Image) -> torch.Tensor:
x = np.array(image) / 127.5 - 1.0
x = x.transpose(2, 0, 1).astype(np.float32)
return torch.as_tensor(x)
def postprocess(
self,
x: torch.Tensor,
width: int | None = None,
height: int | None = None,
) -> Image.Image:
x_np = x.detach().cpu().numpy()
x_np = x_np.transpose(1, 2, 0)
x_np = (x_np + 1.0) * 127.5
x_np = np.clip(x_np, 0, 255).astype(np.uint8)
image = Image.fromarray(x_np)
# Resize image
width = width or self.size
height = height or self.size
image = image.resize((width, height), resample=self.resample)
return image
|