Default backend: Qwen-Image-2.1-Turbo (hugging-apps/qwen-qwen-image-2-1-turbo); full Qwen-Image-2.1 and Fibo stay selectable
Browse filesFiles changed (10)
8 unmodified lines9101112131412 unmodified lines27282930313233343566 unmodified lines1021031041051061071088 unmodified lineslicense: mitshort_description: Agent-first API to texture 3D meshes with Qwen-Image / Fibomodels:- Qwen/Qwen-Image-2.1- briaai/Fibo-2.0-edit-turbotags:12 unmodified lines3. projects the images onto the mesh and blends them in texture space;4. bakes the result into the mesh's UVs.Two image models are available, both through their official Hugging Face Spaces:- **Qwen-Image-2.1** via [Qwen/Qwen-Image-2.1](https://huggingface.co/spaces/Qwen/Qwen-Image-2.1) (default);- **Bria Fibo 2.0 Edit Turbo** via [briaai/Fibo-2.0-editing](https://huggingface.co/spaces/briaai/Fibo-2.0-editing).Designed for agents:* **Asynchronous jobs.** `POST /api/jobs` returns at once. Poll `GET /api/jobs/{id}`; every status includes66 unmodified lines## Licences* Code: MIT.* Qwen-Image-2.1 outputs: Qwen research licence.* Fibo 2.0 Edit Turbo outputs: CC BY-NC 4.0 (non-commercial).* Samples: Avocado and Lantern are CC0 (Khronos glTF-Sample-Assets). The head is the Lee Perry-Smith scan,CC-BY 3.0, by Infinite-Realities.8 unmodified lines910111213141512 unmodified lines2829303132333435363766 unmodified lines1041051061071081091108 unmodified lineslicense: mitshort_description: Agent-first API to texture 3D meshes with Qwen-Image / Fibomodels:- Qwen/Qwen-Image-2.1-Turbo- Qwen/Qwen-Image-2.1- briaai/Fibo-2.0-edit-turbotags:12 unmodified lines3. projects the images onto the mesh and blends them in texture space;4. bakes the result into the mesh's UVs.Three image models are available, through Hugging Face Spaces:- **Qwen-Image-2.1-Turbo** (8 steps) via [hugging-apps/qwen-qwen-image-2-1-turbo](https://huggingface.co/spaces/hugging-apps/qwen-qwen-image-2-1-turbo) (default: fastest, least GPU quota);- **Qwen-Image-2.1** (full model, 40 steps) via the official [Qwen/Qwen-Image-2.1](https://huggingface.co/spaces/Qwen/Qwen-Image-2.1) (`"backend": "qwen-space"`);- **Bria Fibo 2.0 Edit Turbo** via [briaai/Fibo-2.0-editing](https://huggingface.co/spaces/briaai/Fibo-2.0-editing) (`"backend": "fibo-space"`).Designed for agents:* **Asynchronous jobs.** `POST /api/jobs` returns at once. Poll `GET /api/jobs/{id}`; every status includes66 unmodified lines## Licences* Code: MIT.* Qwen-Image-2.1 and Qwen-Image-2.1-Turbo outputs: Qwen research licence.* Fibo 2.0 Edit Turbo outputs: CC BY-NC 4.0 (non-commercial).* Samples: Avocado and Lantern are CC0 (Khronos glTF-Sample-Assets). The head is the Lee Perry-Smith scan,CC-BY 3.0, by Infinite-Realities.
53 unmodified lines54555657585960205 unmodified lines266267268269270271133 unmodified lines40540640740840941041141241353 unmodified lines}BACKENDS = {"qwen-space": {"about": "Qwen-Image-2.1 (40 steps) via the official Space Qwen/Qwen-Image-2.1. Default.","seconds_per_view": 30, "uses_quota": True, "license_note": "Qwen research license"},"fibo-space": {"about": "Bria Fibo 2.0 Edit Turbo via its official Space briaai/Fibo-2.0-editing; native masks; ""best cross-view consistency.", "seconds_per_view": 20, "uses_quota": True,205 unmodified linesdef _backend(self, job: Job, name: str | None = None):"""A backend instance for this job carrying the caller's identity (never stored in project.json)."""name = name or job.params["backend"]if name == "qwen-space":from projtex.backends.qwen_space import QwenSpaceBackend133 unmodified linesraise JobError(f"unknown upload_id {p['upload_id']!r} (uploads expire after "f"{JOB_TTL_S // 3600} h or when the Space restarts)", 404, "upload again: POST /api/uploads")upload = (up["path"].name, up["path"].read_bytes())if p.get("backend", "qwen-space") not in BACKENDS:raise JobError(f"unknown backend {p.get('backend')!r}", 400, f"use one of {sorted(BACKENDS)}")p.setdefault("backend", "qwen-space")if not (p.get("sample") or p.get("mesh_url") or upload):raise JobError("give a mesh: upload_id (POST /api/uploads), mesh_url, mesh_base64 or sample", 400,f"samples: {sorted(SAMPLE_INFO)}")53 unmodified lines54555657585960616263205 unmodified lines269270271272273274275276277278133 unmodified lines41241341441541641741841942053 unmodified lines}BACKENDS = {"qwen-turbo": {"about": "Qwen-Image-2.1-Turbo (8 steps) via the Space hugging-apps/qwen-qwen-image-2-1-turbo. ""Default: fastest, about a quarter of qwen-space's GPU quota per view.","seconds_per_view": 15, "uses_quota": True, "license_note": "Qwen research license"},"qwen-space": {"about": "Qwen-Image-2.1, full model (40 steps), via the official Space Qwen/Qwen-Image-2.1.","seconds_per_view": 30, "uses_quota": True, "license_note": "Qwen research license"},"fibo-space": {"about": "Bria Fibo 2.0 Edit Turbo via its official Space briaai/Fibo-2.0-editing; native masks; ""best cross-view consistency.", "seconds_per_view": 20, "uses_quota": True,205 unmodified linesdef _backend(self, job: Job, name: str | None = None):"""A backend instance for this job carrying the caller's identity (never stored in project.json)."""name = name or job.params["backend"]if name == "qwen-turbo":from projtex.backends.qwen_space import QwenTurboSpaceBackendreturn _yielding(QwenTurboSpaceBackend(**self._ident_kw(job)), self.cpu)if name == "qwen-space":from projtex.backends.qwen_space import QwenSpaceBackend133 unmodified linesraise JobError(f"unknown upload_id {p['upload_id']!r} (uploads expire after "f"{JOB_TTL_S // 3600} h or when the Space restarts)", 404, "upload again: POST /api/uploads")upload = (up["path"].name, up["path"].read_bytes())if p.get("backend", "qwen-turbo") not in BACKENDS:raise JobError(f"unknown backend {p.get('backend')!r}", 400, f"use one of {sorted(BACKENDS)}")p.setdefault("backend", "qwen-turbo")if not (p.get("sample") or p.get("mesh_url") or upload):raise JobError("give a mesh: upload_id (POST /api/uploads), mesh_url, mesh_base64 or sample", 400,f"samples: {sorted(SAMPLE_INFO)}")
123456783 unmodified lines1213141516171880 unmodified lines99100101102103104105106# projtex: projection texturing API (agent guide)> Give a 3D mesh and a prompt; get back the same model with a baked colour texture (GLB).> Images are generated from virtual cameras by Qwen-Image-2.1 (official Qwen Space, default) or Bria Fibo 2.0> Edit Turbo, projected onto the geometry, blended in texture space and baked into the mesh's UVs.> Long operations are asynchronous jobs: create, then poll. Every status tells you what to do next.Interfaces (same functionality):3 unmodified linesdisable_views, fill_gaps, retouch, undo_retouch, bake, pick_point, submit_view_image, service_info, guide.## Quota and identity (read this first)Generation runs on ZeroGPU Spaces and spends the caller's daily GPU quota (about 30 s of GPU per view).- Send your Hugging Face token so your own quota is used: header `X-HF-Token: $HF_TOKEN` (REST and MCP), or the`hf_token` field. It is kept in memory for the job only, never stored, logged or returned.- Without a token the job runs as your forwarded visitor identity if the Hub provides one, otherwise anonymously80 unmodified linesfocus_prompt to describe only the head) | environment (360° probes from inside, for rooms and interiors youwalk through; slow on this CPU machine).- preset: minimal (4 views, fastest) | balanced (7, default) | dense (12) | greedy. Gap views (up to 3) are added.- backend: qwen-space (default) | fibo-space (most consistent views, best masked edits; CC BY-NC outputs) | mock |external.- texture_size 1024 | 2048 | 4096; view_size 512-1024; uv auto | keep | regen; up (non-glTF files only);inside plain (default) | paint (the inside of mugs, vases and pots: see "Reading results").metal keep (default) | flat: the image model paints chrome with reflections, which read as chrome in any renderer.123456783 unmodified lines121314151617181980 unmodified lines100101102103104105106107108# projtex: projection texturing API (agent guide)> Give a 3D mesh and a prompt; get back the same model with a baked colour texture (GLB).> Images are generated from virtual cameras by Qwen-Image-2.1-Turbo (default), the full Qwen-Image-2.1 or Bria> Fibo 2.0 Edit Turbo, projected onto the geometry, blended in texture space and baked into the mesh's UVs.> Long operations are asynchronous jobs: create, then poll. Every status tells you what to do next.Interfaces (same functionality):3 unmodified linesdisable_views, fill_gaps, retouch, undo_retouch, bake, pick_point, submit_view_image, service_info, guide.## Quota and identity (read this first)Generation runs on ZeroGPU Spaces and spends the caller's daily GPU quota (about 7 s of GPU per view with thedefault backend qwen-turbo, about 30 s with qwen-space).- Send your Hugging Face token so your own quota is used: header `X-HF-Token: $HF_TOKEN` (REST and MCP), or the`hf_token` field. It is kept in memory for the job only, never stored, logged or returned.- Without a token the job runs as your forwarded visitor identity if the Hub provides one, otherwise anonymously80 unmodified linesfocus_prompt to describe only the head) | environment (360° probes from inside, for rooms and interiors youwalk through; slow on this CPU machine).- preset: minimal (4 views, fastest) | balanced (7, default) | dense (12) | greedy. Gap views (up to 3) are added.- backend: qwen-turbo (default: Qwen-Image-2.1-Turbo, 8 steps) | qwen-space (the full Qwen-Image-2.1, 40 steps:slower, about 4x the GPU quota) | fibo-space (most consistent views, best masked edits; CC BY-NC outputs) | mock| external.- texture_size 1024 | 2048 | 4096; view_size 512-1024; uv auto | keep | regen; up (non-glTF files only);inside plain (default) | paint (the inside of mugs, vases and pots: see "Reading results").metal keep (default) | flat: the image model paints chrome with reflections, which read as chrome in any renderer.
310 unmodified lines31131231331431531631731831948 unmodified lines36836937037137237337425 unmodified lines40040140240340440540643 unmodified lines450451452453454455456457458459460461462463464149 unmodified lines614615616617618619620621310 unmodified linesmode: Literal["object", "character", "environment"] | None = Field(None, description="object: orbit views; character: + face close-ups, auto up-axis and facing; environment: ""360° probes from inside (slow on this CPU machine). Default: object (or the sample's).")backend: Literal["qwen-space", "fibo-space", "mock", "external"] = Field("qwen-space", description="qwen-space: official Qwen-Image-2.1 Space (default). fibo-space: Bria Fibo 2.0 ""Edit Turbo (non-commercial). mock: free dry run. external: you supply images.")part_prompts: dict[str, str] | None = Field(None, description="Description per material or object name of your file, e.g. {\"Walls\": \"white ""clapboard siding\", \"Roof\": \"grey asphalt shingles\", \"Door\": \"dark green panel "48 unmodified linesviews: list[str] = Field(..., description="View names (see 'views' in the job status).")seeds: dict[str, int] | None = Field(None, description="Optional seed per view (random new seeds otherwise).")prompt_extra: str | None = Field(None, description="Extra instruction appended to these views' prompts.")backend: Literal["qwen-space", "fibo-space", "mock", "external"] | None = Nonehf_token: str | None = None25 unmodified linesoutput_size: int | None = Nonesoftness: float = 0.75grow_px: int = 0backend: Literal["qwen-space", "fibo-space", "mock"] | None = Nonehf_token: str | None = None43 unmodified lines@mcp.tool()def texture_mesh(prompt: str = "", upload_id: str = "", mesh_url: str = "", mesh_base64: str = "", sample: str = "",mode: str = "", backend: str = "qwen-space", subject: str = "", preset: str = "",focus_prompt: str = "", texture_size: int = 0, uv: str = "", up: str = "",part_prompts: dict[str, str] | None = None, single_mesh: bool = False, inside: str = "",metal: str = "", hf_token: str = "", ctx: Context | None = None) -> dict:"""Start texturing a mesh; returns a job id immediately (the job takes ~30 s per view with qwen-space).Mesh: upload_id (from REST POST /api/uploads with the file as raw body), mesh_url (public .glb/.obj/.ply/.stl/.zip), mesh_base64 (the file itself, up to 20 MB) or sample ('avocado' | 'lantern' | 'head'). prompt: materialsand colours of what the mesh models. mode: object | character | environment. backend: qwen-space (default),fibo-space (non-commercial), mock (free dry run), external (you supply images). preset: minimal | balanced |dense | greedy. uv: auto | keep | regen. part_prompts: {material or object name: description}; each view thennames only the parts it shows (recommended for multi-part models). The result GLB keeps your objects andmaterials (single_mesh: one object, one material instead). inside: plain (default: the inside of a mug or vase149 unmodified lines"service": "projtex: projection texturing for 3D meshes (generate views -> project -> blend -> bake to UVs)","samples": SAMPLE_INFO,"backends": BACKENDS,"quota": "qwen-space and fibo-space run on ZeroGPU Spaces and spend the caller's daily GPU quota ""(unauthenticated ~2 min, free account ~5 min, PRO ~40 min per day; ~30 s per view). Send your HF ""token (header X-HF-Token or hf_token field) so your own quota is used; otherwise the request runs ""as your forwarded visitor identity or anonymously.","limits": {"mesh_mb": MAX_MESH_BYTES >> 20, "triangles": MAX_FACES, "texture_size": [1024, 2048, 4096],310 unmodified lines31131231331431531631731831932048 unmodified lines36937037137237337437525 unmodified lines40140240340440540640743 unmodified lines451452453454455456457458459460461462463464465466149 unmodified lines616617618619620621622623624310 unmodified linesmode: Literal["object", "character", "environment"] | None = Field(None, description="object: orbit views; character: + face close-ups, auto up-axis and facing; environment: ""360° probes from inside (slow on this CPU machine). Default: object (or the sample's).")backend: Literal["qwen-turbo", "qwen-space", "fibo-space", "mock", "external"] = Field("qwen-turbo", description="qwen-turbo: Qwen-Image-2.1-Turbo, 8 steps (default, fastest, least GPU quota). ""qwen-space: full Qwen-Image-2.1 (40 steps, official Space). fibo-space: Bria Fibo ""2.0 Edit Turbo (non-commercial). mock: free dry run. external: you supply images.")part_prompts: dict[str, str] | None = Field(None, description="Description per material or object name of your file, e.g. {\"Walls\": \"white ""clapboard siding\", \"Roof\": \"grey asphalt shingles\", \"Door\": \"dark green panel "48 unmodified linesviews: list[str] = Field(..., description="View names (see 'views' in the job status).")seeds: dict[str, int] | None = Field(None, description="Optional seed per view (random new seeds otherwise).")prompt_extra: str | None = Field(None, description="Extra instruction appended to these views' prompts.")backend: Literal["qwen-turbo", "qwen-space", "fibo-space", "mock", "external"] | None = Nonehf_token: str | None = None25 unmodified linesoutput_size: int | None = Nonesoftness: float = 0.75grow_px: int = 0backend: Literal["qwen-turbo", "qwen-space", "fibo-space", "mock"] | None = Nonehf_token: str | None = None43 unmodified lines@mcp.tool()def texture_mesh(prompt: str = "", upload_id: str = "", mesh_url: str = "", mesh_base64: str = "", sample: str = "",mode: str = "", backend: str = "qwen-turbo", subject: str = "", preset: str = "",focus_prompt: str = "", texture_size: int = 0, uv: str = "", up: str = "",part_prompts: dict[str, str] | None = None, single_mesh: bool = False, inside: str = "",metal: str = "", hf_token: str = "", ctx: Context | None = None) -> dict:"""Start texturing a mesh; returns a job id immediately (the job takes ~15 s per view with qwen-turbo).Mesh: upload_id (from REST POST /api/uploads with the file as raw body), mesh_url (public .glb/.obj/.ply/.stl/.zip), mesh_base64 (the file itself, up to 20 MB) or sample ('avocado' | 'lantern' | 'head'). prompt: materialsand colours of what the mesh models. mode: object | character | environment. backend: qwen-turbo (default,Qwen-Image-2.1-Turbo), qwen-space (full Qwen-Image-2.1), fibo-space (non-commercial), mock (free dry run),external (you supply images). preset: minimal | balanced |dense | greedy. uv: auto | keep | regen. part_prompts: {material or object name: description}; each view thennames only the parts it shows (recommended for multi-part models). The result GLB keeps your objects andmaterials (single_mesh: one object, one material instead). inside: plain (default: the inside of a mug or vase149 unmodified lines"service": "projtex: projection texturing for 3D meshes (generate views -> project -> blend -> bake to UVs)","samples": SAMPLE_INFO,"backends": BACKENDS,"quota": "qwen-turbo, qwen-space and fibo-space run on ZeroGPU Spaces and spend the caller's daily GPU ""quota (unauthenticated ~2 min, free account ~5 min, PRO ~40 min per day; ~7 s of GPU per view ""with qwen-turbo, ~30 s with qwen-space). Send your HF ""token (header X-HF-Token or hf_token field) so your own quota is used; otherwise the request runs ""as your forwarded visitor identity or anonymously.","limits": {"mesh_mb": MAX_MESH_BYTES >> 20, "triangles": MAX_FACES, "texture_size": [1024, 2048, 4096],
30 unmodified lines3132333435363714 unmodified lines5253545556575830 unmodified lines<body><h1>projtex: projection texturing API</h1><p class="lead">Send a 3D mesh and a prompt, get back a textured GLB. Images are generated from virtual cameras byQwen-Image-2.1 (the official Qwen Space) or Bria Fibo 2.0 Edit Turbo. They are projected onto the geometry, blendedin texture space and baked to the mesh's UVs. Agents: the API is asynchronous and every response says what to do next.</p><div class="cards">14 unmodified lines<form id="f"><div class="row"><div><label>Sample mesh</label><select id="sample"><option>lantern</option><option>avocado</option><option>head</option></select></div><div><label>Backend</label><select id="backend"><option value="mock">mock (free dry run)</option><option value="qwen-space">qwen-space</option><option value="fibo-space">fibo-space (non-commercial)</option></select></div><div><label>Views</label><select id="preset"><option>minimal</option><option selected>balanced</option><option>dense</option></select></div></div><div><label>Prompt (materials and colours)</label><input id="prompt" value="black wrought iron with rust, weathered oak post with grain, warm frosted glass"></div>30 unmodified lines3132333435363714 unmodified lines5253545556575830 unmodified lines<body><h1>projtex: projection texturing API</h1><p class="lead">Send a 3D mesh and a prompt, get back a textured GLB. Images are generated from virtual cameras byQwen-Image-2.1-Turbo (default), the full Qwen-Image-2.1 or Bria Fibo 2.0 Edit Turbo. They are projected onto the geometry, blendedin texture space and baked to the mesh's UVs. Agents: the API is asynchronous and every response says what to do next.</p><div class="cards">14 unmodified lines<form id="f"><div class="row"><div><label>Sample mesh</label><select id="sample"><option>lantern</option><option>avocado</option><option>head</option></select></div><div><label>Backend</label><select id="backend"><option value="mock">mock (free dry run)</option><option value="qwen-turbo" selected>qwen-turbo (default)</option><option value="qwen-space">qwen-space (full Qwen-Image-2.1)</option><option value="fibo-space">fibo-space (non-commercial)</option></select></div><div><label>Views</label><select id="preset"><option>minimal</option><option selected>balanced</option><option>dense</option></select></div></div><div><label>Prompt (materials and colours)</label><input id="prompt" value="black wrought iron with rust, weathered oak post with grain, warm frosted glass"></div>
4 unmodified lines56789107 unmodified lines18192021222324254 unmodified linesfrom .base import Backend, GenRequest, PendingGenerationBACKENDS = {"qwen-space": ("projtex.backends.qwen_space", "QwenSpaceBackend"),"qwen-local": ("projtex.backends.qwen_local", "QwenLocalBackend"),"hf": ("projtex.backends.hf_inference", "HFInferenceBackend"),7 unmodified lines# longer generate; projects that still name them must be switched to another backend.REMOVED = {"openrouter": "the OpenRouter backend (Google Gemini image models) was removed; its earlier results are kept ""for comparison. Use qwen-space (official Qwen Space), fibo-space, qwen-local or files, e.g. ""`projtex config P --backend qwen-space`",}_cache: dict[tuple, Backend] = {}4 unmodified lines5678910117 unmodified lines19202122232425264 unmodified linesfrom .base import Backend, GenRequest, PendingGenerationBACKENDS = {"qwen-turbo": ("projtex.backends.qwen_space", "QwenTurboSpaceBackend"),"qwen-space": ("projtex.backends.qwen_space", "QwenSpaceBackend"),"qwen-local": ("projtex.backends.qwen_local", "QwenLocalBackend"),"hf": ("projtex.backends.hf_inference", "HFInferenceBackend"),7 unmodified lines# longer generate; projects that still name them must be switched to another backend.REMOVED = {"openrouter": "the OpenRouter backend (Google Gemini image models) was removed; its earlier results are kept ""for comparison. Use qwen-turbo (default), qwen-space (full Qwen-Image-2.1), fibo-space, ""qwen-local or files, e.g. `projtex config P --backend qwen-turbo`",}_cache: dict[tuple, Backend] = {}
123435 unmodified lines40414243444514 unmodified lines606162636465666760 unmodified lines128129130"""Qwen-Image-2.1 through the official Qwen Space ``Qwen/Qwen-Image-2.1`` (the "Demo" linked from the model card).The Space runs the full ``Qwen/Qwen-Image-2.1`` checkpoint (40 steps, CFG 1) on ZeroGPU, so calls count againstthe GPU quota of the logged-in Hugging Face account (token from the local login / ``HF_TOKEN``; never stored).35 unmodified linesclass QwenSpaceBackend(Backend):name = "qwen-space"max_references = 9def __init__(self, space: str = OFFICIAL_SPACE, prompt_extend: bool = False, retries: int = 3,require_official: bool = True, timeout: float = 600.0, token: str | None = None,14 unmodified linesfrom huggingface_hub import HfApiinfo = HfApi().space_info(self.space)if self.require_official and info.author != OFFICIAL_AUTHOR:raise RuntimeError(f"{self.space} is owned by {info.author!r}, not the official {OFFICIAL_AUTHOR!r} ""organisation (pass require_official=false to use it anyway)")stage = getattr(info.runtime, "stage", None) if info.runtime else Noneif stage and stage != "RUNNING":60 unmodified linesdef describe(self) -> dict:return {**super().describe(), "space": self.space, "model": "Qwen/Qwen-Image-2.1 (40 steps, official Space)","prompt_extend": self.prompt_extend}123456789101135 unmodified lines4748495051525314 unmodified lines686970717273747560 unmodified lines136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196"""Qwen-Image-2.1 through Hugging Face Spaces: the 8-step Turbo checkpoint (default) and the full model.* ``qwen-turbo`` (default): ``Qwen/Qwen-Image-2.1-Turbo``, 8 steps, through ``hugging-apps/qwen-qwen-image-2-1-turbo``.One stateless ``/generate`` call (input images, prompt, seed, resolution tier, aspect ratio "Auto": the outputfollows the conditioning render); about 7 s of GPU per 1024 px view. The Space keeps a prefix KV cache only upto 4 input images at 1024 px (beyond, a call takes several times longer), so it gets at most 3 references.* ``qwen-space``: the full model through the official Qwen Space ``Qwen/Qwen-Image-2.1`` (the "Demo" linked fromthe model card), described below.The Space runs the full ``Qwen/Qwen-Image-2.1`` checkpoint (40 steps, CFG 1) on ZeroGPU, so calls count againstthe GPU quota of the logged-in Hugging Face account (token from the local login / ``HF_TOKEN``; never stored).35 unmodified linesclass QwenSpaceBackend(Backend):name = "qwen-space"max_references = 9official_author = OFFICIAL_AUTHORdef __init__(self, space: str = OFFICIAL_SPACE, prompt_extend: bool = False, retries: int = 3,require_official: bool = True, timeout: float = 600.0, token: str | None = None,14 unmodified linesfrom huggingface_hub import HfApiinfo = HfApi().space_info(self.space)if self.require_official and info.author != self.official_author:raise RuntimeError(f"{self.space} is owned by {info.author!r}, not the official {self.official_author!r} ""organisation (pass require_official=false to use it anyway)")stage = getattr(info.runtime, "stage", None) if info.runtime else Noneif stage and stage != "RUNNING":60 unmodified linesdef describe(self) -> dict:return {**super().describe(), "space": self.space, "model": "Qwen/Qwen-Image-2.1 (40 steps, official Space)","prompt_extend": self.prompt_extend}TURBO_SPACE = "hugging-apps/qwen-qwen-image-2-1-turbo"TURBO_AUTHOR = "hugging-apps"class QwenTurboSpaceBackend(QwenSpaceBackend):"""Qwen-Image-2.1-Turbo (8 steps) through ``hugging-apps/qwen-qwen-image-2-1-turbo`` (see the module docstring)."""name = "qwen-turbo"max_references = 3 # 4 input images at 1024 px keep the Space's prefix KV cache (fast)official_author = TURBO_AUTHORdef __init__(self, space: str = TURBO_SPACE, **kw):super().__init__(space=space, **kw)def generate(self, req: GenRequest) -> Image.Image:from gradio_client import handle_fileside = max(req.width, req.height)resolution = 1024 if side <= 1024 else 1536 if side <= 1536 else 2048 # the Space's tiers (ints)seed = int(req.seed) % 2147483647with tempfile.TemporaryDirectory(prefix="projtex_qwenturbo_") as td:paths = []for i, im in enumerate([req.image] + [r for r, _ in req.references[: self.max_references]]):p = Path(td) / f"in{i}.png"im.convert("RGB").save(p)paths.append(p)gallery = [{"image": handle_file(str(p)), "caption": None} for p in paths]err = Nonefor attempt in range(self.retries):try:t = time.time()out = self._c().predict(prompt=req.prompt, input_images=gallery, seed=seed, resolution=resolution,aspect_ratio="Auto", api_name="/generate")img = Image.open(out)if img.mode in ("RGBA", "LA"): # the model can return transparency: flatten on the backdropbg = Image.new("RGB", img.size, req.image.convert("RGB").getpixel((0, 0)))bg.paste(img, mask=img.getchannel("A"))img = bgself.last_meta = {"space": self.space, "seed": seed, "resolution": resolution,"seconds": round(time.time() - t, 1)}log.info("qwen-turbo %s -> %s in %.1fs", req.name, img.size, time.time() - t)return fit_output(img, req.width, req.height)except Exception as exc:msg = str(exc)if "quota" in msg.lower():raise QuotaExceeded(f"ZeroGPU quota exhausted on {self.space}: {msg[:300]}") from excif "prompt invalid" in msg.lower(): # the Space's prompt guard: deterministicraise RuntimeError(f"{self.space} rejected the prompt: {msg[:200]}") from excerr = exclog.warning("qwen-turbo attempt %d failed: %s: %s", attempt + 1, type(exc).__name__, msg[:300])self._client = Nonetime.sleep(5 + 15 * attempt)raise RuntimeError(f"qwen-turbo generation failed: {err}")def describe(self) -> dict:return {**Backend.describe(self), "space": self.space, "model": "Qwen/Qwen-Image-2.1-Turbo (8 steps)"}
86 unmodified lines87888990919293187 unmodified lines28128228328428528628786 unmodified linesreturn pdef backend_args(p):p.add_argument("--backend", help="qwen-space (default) | fibo-space | qwen-local | hf | files | oracle | mock")p.add_argument("--backend-opt", action="append", metavar="K=V",help="backend option, e.g. prompt_extend=true or model=Qwen/Qwen-Image-2.1 (repeatable)")187 unmodified linesfrom .backends import BACKENDSreturn {"backends": sorted(BACKENDS), "notes": {"qwen-space": "default. Qwen-Image-2.1 (40 steps) through the official Space Qwen/Qwen-Image-2.1 (ZeroGPU quota of your HF login; needs `pip install projtex[spaces]`)","qwen-local": "fallback: local diffusers QwenImage21Pipeline (default Qwen/Qwen-Image-2.1-Turbo); needs a GPU + `pip install projtex[local]`","hf": "Hugging Face Inference Providers image-to-image (default Qwen/Qwen-Image-Edit-2511); needs HF login/HF_TOKEN","fibo-space": "Bria Fibo 2.0 Edit Turbo via its official HF Space (ZeroGPU quota of your HF login); native masks; CC BY-NC 4.0",86 unmodified lines87888990919293187 unmodified lines28128228328428528628728886 unmodified linesreturn pdef backend_args(p):p.add_argument("--backend", help="qwen-turbo (default) | qwen-space | fibo-space | qwen-local | hf | files | oracle | mock")p.add_argument("--backend-opt", action="append", metavar="K=V",help="backend option, e.g. prompt_extend=true or model=Qwen/Qwen-Image-2.1 (repeatable)")187 unmodified linesfrom .backends import BACKENDSreturn {"backends": sorted(BACKENDS), "notes": {"qwen-turbo": "default. Qwen-Image-2.1-Turbo (8 steps, ~7 s of GPU per view) through the Space hugging-apps/qwen-qwen-image-2-1-turbo (ZeroGPU quota of your HF login; needs `pip install projtex[spaces]`)","qwen-space": "full Qwen-Image-2.1 (40 steps) through the official Space Qwen/Qwen-Image-2.1 (ZeroGPU quota of your HF login; needs `pip install projtex[spaces]`)","qwen-local": "fallback: local diffusers QwenImage21Pipeline (default Qwen/Qwen-Image-2.1-Turbo); needs a GPU + `pip install projtex[local]`","hf": "Hugging Face Inference Providers image-to-image (default Qwen/Qwen-Image-Edit-2511); needs HF login/HF_TOKEN","fibo-space": "Bria Fibo 2.0 Edit Turbo via its official HF Space (ZeroGPU quota of your HF login); native masks; CC BY-NC 4.0",
51 unmodified lines525354555657585951 unmodified linesdef configure(project: str, prompt: str = "", subject: str = "", backend: str = "", backend_options: dict | None = None,lighting: str = "", style_reference: str = "", texture_size: int = 0, fusion: dict | None = None,extra: dict | None = None) -> dict:"""Set the texturing prompt and options. backend: qwen-space (default, official Qwen Space) | fibo-space |qwen-local | hf | files | oracle | mock.lighting: flat (albedo-like, default) | soft | natural. fusion: e.g. {"sharpness": 6}."""kw: dict = {"prompt": prompt or None, "subject": subject or None, "lighting": lighting or None,"style_reference": style_reference or None, "texture_size": texture_size or None, "fusion": fusion}51 unmodified lines525354555657585951 unmodified linesdef configure(project: str, prompt: str = "", subject: str = "", backend: str = "", backend_options: dict | None = None,lighting: str = "", style_reference: str = "", texture_size: int = 0, fusion: dict | None = None,extra: dict | None = None) -> dict:"""Set the texturing prompt and options. backend: qwen-turbo (default, Qwen-Image-2.1-Turbo Space) | qwen-space(full Qwen-Image-2.1, official Space) | fibo-space | qwen-local | hf | files | oracle | mock.lighting: flat (albedo-like, default) | soft | natural. fusion: e.g. {"sharpness": 6}."""kw: dict = {"prompt": prompt or None, "subject": subject or None, "lighting": lighting or None,"style_reference": style_reference or None, "texture_size": texture_size or None, "fusion": fusion}
49 unmodified lines5051525354555649 unmodified lines# auto: when at least two materials have clearly different colours"color_guide": "auto", # GLB with one object and one material (game-ready) instead of the source scene"style_reference": None,"backend": {"name": "qwen-space"},"view_size": 1024,"texture_size": 2048,"preview_texture_size": 1024,49 unmodified lines5051525354555649 unmodified lines# auto: when at least two materials have clearly different colours"color_guide": "auto", # GLB with one object and one material (game-ready) instead of the source scene"style_reference": None,"backend": {"name": "qwen-turbo"},"view_size": 1024,"texture_size": 2048,"preview_texture_size": 1024,
README.md+6-4
app/jobs.py+10-3
app/llms.txt+7-5
app/server.py+14-11
app/static/index.html+2-2
projtex/backends/__init__.py+3-2
projtex/backends/qwen_space.py+69-3
projtex/cli.py+3-2
projtex/mcp_server.py+2-2
projtex/project.py+1-1