Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#5 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
python
Lĩnh vực
machine-learning

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Python
Star
2
Fork
0
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/Lens

Tất cả issue của microsoft/Lens

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.