Update model card with metadata, paper links and usage
Browse filesHi! I'm Niels from the Hugging Face community team. I've opened this PR to improve the documentation of your model.
Specifically, I have:
- Added `pipeline_tag: text-to-image` to the metadata to help users find your model.
- Added `library_name: diffusers` to enable automated code snippets on the Hub.
- Included links to the research paper, project page, and GitHub repository.
- Preserved the usage example from your README to ensure users can easily run the model.
These changes will make the model much more discoverable and easier to use within the Hugging Face ecosystem.
12345672891011121378141516173 unmodified lines21222324252627281 unmodified line3031323334353637383940414243448 unmodified lines5354555657585910 unmodified lines707172737475761 unmodified line78798068818283848573868788893 unmodified lines939495839697989910088101102103104929394105---library_name: diffuserspipeline_tag: text-to-image---
# TDM-R1: Reinforcing Few-Step Diffusion Models with Non-Differentiable Reward
<div align="center"><div align="center Lark"> <a href="https://luo-yihong.github.io/TDM-R1-Page/"><img src="https://img.shields.io/static/v1?label=Project%20Page&message=Github&color=blue&logo=github-pages"></a>   <a href="https://arxiv.org/abs/2603.07700"><img src="https://img.shields.io/static/v1?label=Paper&message=Arxiv:TDM-R1&color=red&logo=arxiv"></a>   <a href="https://github.com/Luo-Yihong/TDM-R1"><img src="https://img.shields.io/static/v1?label=Code&message=Github&color=green&logo=github"></a></div>
This is the Official Repository of "[TDM-R1: Reinforcing Few-Step Diffusion Models with Non-Differentiable Reward](https://arxiv.org/abs/2603.07700)", by *Yihong Luo, Tianyang Hu, Weijian Luo, Jing Tang*.This is the Official Repository of "[TDM-R1: Reinforcing Few-Step Diffusion Models with Non-Differentiable Reward](https://arxiv.org/abs/2603.07700)", by *Yihong Luo, Tianyang Hu, Weijian Luo, Jing Tang*.
<div align="center"> <img src="teaser_git.png" width="100%">3 unmodified lines Samples generated by <b>TDM-R1</b> using only <b>4 NFEs</b>, obtained by reinforcing the recent powerful Z-Image model.</p>
## DescriptionTDM-R1 is a reinforcement learning (RL) paradigm for few-step generative models. It decouples the learning process into surrogate reward learning and generator learning, allowing for the use of non-differentiable rewards (e.g., human preference, object counts). This repository contains the reinforced version of the [Z-Image-Turbo](https://huggingface.co/Tongyi-MAI/Z-Image-Turbo) model.
## Pre-trained Model
1 unmodified line
## Usage
You can use this model with `diffusers` and `peft`. Below is an example of how to load the weights as a LoRA adapter.
```pythonimport osos.environ["HF_ENDPOINT"] = "https://hf-mirror.com"import torchfrom diffusers import ZImagePipelinefrom peft import LoraConfig, get_peft_model
def load_ema(pipeline, lora_path, adapter_name='default'): """Load EMA weights into the pipeline's transformer adapter""" pipeline.transformer.set_adapter(adapter_name)8 unmodified lines for param, ema_param in zip(trainable_params, ema_params): param.data.copy_(ema_param.to(param.device)) print(f"Loaded EMA weights for adapter '{adapter_name}' from {lora_path}")
pipeline = ZImagePipeline.from_pretrained( "Tongyi-MAI/Z-Image-Turbo", torch_dtype=torch.bfloat16,10 unmodified lines transformer_lora_config, adapter_name="tdmr1",)# Ensure the checkpoint file is downloaded locallyload_ema( pipeline, lora_path="./tdmr1_zimage_ema.ckpt",1 unmodified line)pipeline = pipeline.to("cuda")image = pipeline( prompt=prompt, prompt="A high quality photo of a cat", height=1024, width=1024, num_inference_steps=5, # This actually results in 4 DiT forwards guidance_scale=0.0, generator=torch.Generator("cuda").manual_seed(xxx), generator=torch.Generator("cuda").manual_seed(42), ).images[0]image```3 unmodified linesPlease contact Yihong Luo (yluocg@connect.ust.hk) if you have any questions about this work.
## Bibtex``````bibtex@misc{luo2025tdmr1, title={TDM-R1: Reinforcing Few-Step Diffusion Models with Non-Differentiable Reward}, author={Yihong Luo and Tianyang Hu and Weijian Luo and Jing Tang}, year={2025}, eprint={TODO}, eprint={2603.07700}, archivePrefix={arXiv}, primaryClass={cs.CV}}```
```README.md+21-10