Instructions to use physicsrob/torchwright-doom-e1m1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use physicsrob/torchwright-doom-e1m1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="physicsrob/torchwright-doom-e1m1")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("physicsrob/torchwright-doom-e1m1") model = AutoModelForCausalLM.from_pretrained("physicsrob/torchwright-doom-e1m1", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use physicsrob/torchwright-doom-e1m1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "physicsrob/torchwright-doom-e1m1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "physicsrob/torchwright-doom-e1m1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/physicsrob/torchwright-doom-e1m1
- SGLang
How to use physicsrob/torchwright-doom-e1m1 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 "physicsrob/torchwright-doom-e1m1" \ --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": "physicsrob/torchwright-doom-e1m1", "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 "physicsrob/torchwright-doom-e1m1" \ --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": "physicsrob/torchwright-doom-e1m1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use physicsrob/torchwright-doom-e1m1 with Docker Model Runner:
docker model run hf.co/physicsrob/torchwright-doom-e1m1
File size: 2,450 Bytes
3a38e1b | 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 67 68 69 | """Minimal runnable example for this checkpoint.
This is complete executable code, not pseudocode. It loads an ordinary
Hugging Face text-generation checkpoint, runs the bundled E1M1 prompt, executes
the cursor and pixel commands emitted by the model, and writes ``frame.png``.
It imports no TorchWright or DOOM implementation.
The loop below is all of the post-processing. The transformer emits every
cursor direction, cursor coordinate, palette index, and run width. This program
only remembers the cursor, looks up RGB in DOOM's static 256-color palette, and
asks Pillow to paint those pixels. It contains no map data, geometry, visibility
tests, texture sampling, lighting calculations, or logic for choosing what gets
drawn or in what order.
This short path is intended to make the mechanism easy to inspect. For
canonical reproduction, download the checkpoint repository and use:
python infer.py --model . --prompt examples/e1m1_prompt.txt --output out
python tools/txt_to_png.py --input out/output.txt --output out/frame.png
That path validates the bundle, preserves the exact generated token IDs,
records termination and memory information, and validates the decoder inputs.
See ``README.md`` for details.
"""
import json
from pathlib import Path
from huggingface_hub import hf_hub_download
from PIL import Image
from transformers import pipeline
MODEL = "physicsrob/torchwright-doom-e1m1"
SCREEN = (320, 200)
prompt = Path(hf_hub_download(MODEL, "examples/e1m1_prompt.txt")).read_text()
colors = json.loads(Path(hf_hub_download(MODEL, "doom_palette.json")).read_text())[
"colors"
]
generate = pipeline(
"text-generation", model=MODEL, device_map="auto", trust_remote_code=False
)
output = generate(prompt, return_full_text=False)[0]["generated_text"]
image = Image.new("RGB", SCREEN)
x = y = 0
advance_x = False
for token in output.split():
command, _, arguments = token.rstrip(")").partition("(")
if command == "setCursorDirectionX":
advance_x = True
elif command == "setCursorDirectionY":
advance_x = False
elif command == "setCursorX":
x = int(arguments)
elif command == "setCursorY":
y = int(arguments)
elif command == "pixel":
color, width = map(int, arguments.split(","))
image.paste(tuple(colors[color]), (x, y, x + width, y + 1))
if advance_x:
x += width
else:
y += 1
image.save("frame.png")
|