Run this model with HF Jobs
Run tugrulv89/image21-evaluation-cache 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:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/tugrulv89/image21-evaluation-cache. 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.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/tugrulv89/image21-evaluation-cache 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.
Instructions to use tugrulv89/image21-evaluation-cache with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use tugrulv89/image21-evaluation-cache with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("tugrulv89/image21-evaluation-cache", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
Use official CPU offload and verified pipeline signature for 48 GB evaluation
Browse filesFiles changed (5)
1234567{"source": "Qwen/Qwen-Image-2.1","source_revision": "d26bb61231c349cf6b7896fa83353113880e1ba3","handler_git": "1805a9dcb663b115221a5a55d72150d70f2968d7","handler_sha256": "d0dc0e84a39786a2de9f7808b8adae83ad0c66ba9661f7ca47ba2707e6eb892a","use": "Isolated research/evaluation only; no production promotion"}1234567{"source": "Qwen/Qwen-Image-2.1","source_revision": "d26bb61231c349cf6b7896fa83353113880e1ba3","handler_git": "cf13cfff6d29586858d45a7e0d7972d0b88fd98f","handler_sha256": "126ca057f75fbc25185a75fb00cb9041942d9744f0489dd64f6685b5faa50877","use": "Isolated research/evaluation only; no production promotion"}
1 unmodified line2345671 unmodified lineResearch only. Root 2511 handler, Dockerfile and production endpoint stay unchanged.The official base model is tested at 40 steps, CFG 1 and BF16, with prefix KV cache.This is a base-model quality comparison; it is not an 8-step Turbo benchmark.Build from the repository root using `qwen21/Dockerfile`. Set1 unmodified line2345678910111 unmodified lineResearch only. Root 2511 handler, Dockerfile and production endpoint stay unchanged.The official base model is tested at 40 steps, CFG 1 and BF16, with prefix KV cache.Reference conditioning uses the upstream `output_resolution=1024` default;the requested final image is 1024x1536. Full-resident BF16 failed with CUDA OOMon the actual 48 GB worker. The official `enable_model_cpu_offload()` methodkeeps BF16 and moves components in sequence without requiring a 96 GB GPU.This is a base-model quality comparison; it is not an 8-step Turbo benchmark.Build from the repository root using `qwen21/Dockerfile`. Set
2 unmodified lines34567823 unmodified lines3233343536373812 unmodified lines5152535455565750 unmodified lines1081091101111121131142 unmodified linesimport jsonimport osimport timeimport uuidfrom pathlib import Path23 unmodified linesraise ValueError('An explicit editing prompt is required')return {'prompt': job['prompt'], 'negative_prompt': job.get('negative_prompt'),'width': width, 'height': height, 'num_inference_steps': steps,'true_cfg_scale': cfg, 'use_kv_cache': True}def cached_model_path():12 unmodified linesfrom diffusers import QwenImage21Pipeline_pipe = QwenImage21Pipeline.from_pretrained(cached_model_path(), local_files_only=True,torch_dtype=torch.bfloat16).to('cuda')return _pipe50 unmodified lines'peak_reserved_gib': round(torch.cuda.max_memory_reserved() / 1024**3, 2),'model_revision': os.environ['QWEN21_MODEL_REVISION']})except Exception as exc:detail = str(exc)for key in ('HF_TOKEN', 'JSON_PATH_KEY'):if os.environ.get(key):detail = detail.replace(os.environ[key], '[REDACTED]')2 unmodified lines345678923 unmodified lines333435363738394012 unmodified lines535455565758596050 unmodified lines1111121131141151161172 unmodified linesimport jsonimport osimport timeimport tracebackimport uuidfrom pathlib import Path23 unmodified linesraise ValueError('An explicit editing prompt is required')return {'prompt': job['prompt'], 'negative_prompt': job.get('negative_prompt'),'width': width, 'height': height, 'num_inference_steps': steps,'true_cfg_scale': cfg, 'use_kv_cache': True,'output_resolution': 1024}def cached_model_path():12 unmodified linesfrom diffusers import QwenImage21Pipeline_pipe = QwenImage21Pipeline.from_pretrained(cached_model_path(), local_files_only=True,torch_dtype=torch.bfloat16)_pipe.enable_model_cpu_offload()return _pipe50 unmodified lines'peak_reserved_gib': round(torch.cuda.max_memory_reserved() / 1024**3, 2),'model_revision': os.environ['QWEN21_MODEL_REVISION']})except Exception as exc:detail = traceback.format_exc()for key in ('HF_TOKEN', 'JSON_PATH_KEY'):if os.environ.get(key):detail = detail.replace(os.environ[key], '[REDACTED]')
1234567891011121314151617181920212223242526272829{ "diffusers_commit": "85c9fa4caee33d1c5b473395784471d2d7957c1b", "source": "src/diffusers/pipelines/qwenimage21/pipeline_qwenimage21.py", "source_sha256": "e75e4ce38d38e194edaac818bba99b2115b4bb2bfdbd15ce03a2813b0fe8856c", "call_parameters": [ "prompt", "image", "negative_prompt", "true_cfg_scale", "height", "width", "num_inference_steps", "sigmas", "num_images_per_prompt", "generator", "latents", "prompt_embeds", "prompt_embeds_mask", "negative_prompt_embeds", "negative_prompt_embeds_mask", "output_type", "return_dict", "attention_kwargs", "callback_on_step_end", "callback_on_step_end_tensor_inputs", "output_resolution", "use_kv_cache" ]}12345622 unmodified lines293031323334353637import unittestimport osimport tempfilefrom pathlib import Pathfrom unittest.mock import patch22 unmodified linesself.assertEqual((args['width'], args['height'], args['num_inference_steps']), (1024, 1536, 40))self.assertEqual(args['true_cfg_scale'], 1.0)self.assertTrue(args['use_kv_cache'])self.assertNotIn('guidance_scale', args)self.assertNotIn('sigmas', args)def test_invalid_controls_fail_before_loading_a_model(self):with patch('qwen21.handler.pipeline') as load:result = handler({'input': {'task': 'edit', 'jobs': [123456722 unmodified lines3031323334353637383940414243444546import unittestimport osimport tempfileimport jsonfrom pathlib import Pathfrom unittest.mock import patch22 unmodified linesself.assertEqual((args['width'], args['height'], args['num_inference_steps']), (1024, 1536, 40))self.assertEqual(args['true_cfg_scale'], 1.0)self.assertTrue(args['use_kv_cache'])self.assertEqual(args['output_resolution'], 1024)self.assertNotIn('guidance_scale', args)self.assertNotIn('sigmas', args)def test_sampling_matches_the_pinned_official_pipeline_signature(self):root = Path(__file__).parents[1]contract = json.loads((root / 'tests/pipeline_contract.json').read_text())self.assertIn(contract['diffusers_commit'], (root / 'requirements.txt').read_text())self.assertLessEqual(set(sampling({'prompt': 'Keep the actual bag.'})),set(contract['call_parameters']))def test_invalid_controls_fail_before_loading_a_model(self):with patch('qwen21.handler.pipeline') as load:result = handler({'input': {'task': 'edit', 'jobs': [
EVALUATION_PROVENANCE.json+2-2
handler/qwen21/README.md+4
handler/qwen21/handler.py+6-3
handler/qwen21/tests/pipeline_contract.jsonAdded+29
handler/qwen21/tests/test_sampling.py+9