Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Can you enable a two pipe solution for those with Unified Memory Architecture ?

未关闭
#5 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
冷清
技术栈
python

调研方向

Start by reading LensPipeline.__init__ and the prompt-handling paths used by encode_prompt and pipeline invocation. Trace how configuration and optional models are loaded, then identify where None prompt inputs are converted to lists. The work is complete when text encoding can run separately, the text encoder can be removed, and prompt embeddings, masks, and negative prompts are accepted without errors.

由索引模型根据 Issue 内容生成。

描述

With Diffusers style Pipelines its a common pattern to split the Pipeline into 2, one to do the text encoding and one to do run the transformer integration. This is done so we can throw the Text encoder out of memory once its been finished with.

e.g.

with torch.no_grad():
    te_pipe = LensPipeline.from_pretrained(
        "microsoft/Lens", torch_dtype=torch.bfloat16,
        transformer=None, vae=None
    ).to("mps")

    prompt_embeds, prompt_mask, negative_prompt_embeds, negative_prompt_mask = te_pipe.encode_prompt(
        prompt=prompt,
        negative_prompt=""
    )

del te_pipe
import gc
gc.collect()
torch.mps.empty_cache()
gc.collect()
torch.mps.empty_cache()


pipe = LensPipeline.from_pretrained(
    "microsoft/Lens", torch_dtype=torch.bfloat16,
    text_encoder=None,
).to("mps")


image = pipe(
    prompt_embeds=prompt_embeds, 
    prompt_mask=prompt_mask, 
    negative_prompt_embeds=negative_prompt_embeds, 
    negative_prompt_mask=negative_prompt_mask,
    base_resolution=1440, aspect_ratio="1:1",
    num_inference_steps=20, guidance_scale=5.0,
    generator=torch.Generator("mps").manual_seed(0),
).images[0]

Unfortunately Lens has a few coding barriers, the init for the pipeline assumes all the models are there, using config values.
Using the prompt embeds is broken, the code that copies the prompts into list form does not have a guard for the prompt being None, and the same for the negative prompt

主要语言
Python
星标
2
派生
0
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/Lens 的其他 Issue

查看 microsoft/Lens 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。