1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] why there is no grad in the fine-tuning SAM

Discussão em 'Python' iniciado por Stack, Setembro 16, 2025.

  1. Stack

    Stack Membro Participativo

    I download the SAM model and parameter from the official website and then try to re-train the network. When I try to do the back-propagation, then there is an error called:


    RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn
    ​

    The training network is as:

    url = "https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth"
    checkpoint_path = "sam_vit_b_01ec64.pth"

    if not os.path.exists(checkpoint_path):
    with requests.get(url, stream=True) as r:
    r.raise_for_status()
    with open(checkpoint_path, 'wb') as f:
    for chunk in r.iter_content(chunk_size=8192):
    f.write(chunk)
    print("Checkpoint downloaded.")

    model_type = "vit_b"
    checkpoint = "sam_vit_b_01ec64.pth"

    model = sam_model_registry\[model_type\](checkpoint=checkpoint)


    Is there someone can help. Thanks a lot loll.

    Continue reading...

Compartilhe esta Página