Skip to content

setting up inference to use pre trained weights #1

@iamrishu11

Description

@iamrishu11

So i was going through the github and hugging face link and available items and then tried to create the inference script to test the model.

Steps:

  1. I firstly cloned the repo and its content !git clone https://github.com/pulp-bio/BioFoundation.git
  2. installed the required packages from requirements.txt
  3. downloaded the weights from the hugging face via the following command
from huggingface_hub import snapshot_download

snapshot_download(
    repo_id="thorir/FEMBA",
    repo_type="model",
    local_dir="checkpoints/FEMBA"
)
  1. installed mamba-ssm and its dependencies
  2. wrote the script to test the artifact detection model
import torch
from safetensors.torch import load_file
from models.FEMBA import FEMBA

# Model configuration
model = FEMBA(
    seq_length=1280,
    num_channels=22,
    num_classes=2,
    exp=4,
    embed_dim=79,
    num_blocks=4,
    classification_type='bc'
)

# Load safetensors checkpoint
state_dict = load_file("/content/checkpoints/FEMBA/TUAR/FEMBA_base.safetensors")
model.load_state_dict(state_dict)

model.eval()

# Dummy input
x = torch.randn(1, 22, 1280)
mask = torch.zeros_like(x, dtype=torch.bool)

# Inference
with torch.no_grad():
    preds, _ = model(x, mask)

print(preds)

but im getting this error module 'torch' has no attribute 'version' multiple times, tried restarting the colab session.
even though the torch is installed and working

import torch
print(torch.__version__)

result is 2.8.0+cu126

PS : this is the colab notebook Link.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions