Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/caduceus_inf.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import argparse
import os
import sys
import time
import traceback
from typing import Any, Literal

import numpy as np
import torch
import torch.nn as nn
import xarray as xr
Expand Down Expand Up @@ -212,7 +215,8 @@ def generate_soft_labels(
"sample": batch_indices,
"sequence": range(input_ids.shape[1]),
"vocab": range(logits.shape[-1]),
"chr_name": (["sample"], list(chr_names)),
# NOTE: use U5 encoding because chr name can be either 3 or 4 characters long, e.g. `chr1` or `chr10`
"chr_name": (["sample"], np.asarray(list(chr_names)).astype("<U5")),
"start": (["sample"], [int(s) for s in starts]),
"end": (["sample"], [int(e) for e in ends]),
},
Expand Down Expand Up @@ -275,7 +279,7 @@ def generate_soft_labels(

except Exception as e:
was_interrupted = True
print(f"\nError occurred: {str(e)}")
print(f"\n{traceback.format_exc()}\nError occurred: {str(e)}", file=sys.stderr)

finally:
if nvml_available and pynvml is not None:
Expand Down