Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: only integer tensors of a single element can be converted to an index #18

Open
shenweima opened this issue May 26, 2023 · 3 comments

Comments

@shenweima
Copy link

Traceback (most recent call last):
  File "/share/home/yzbsl_masw/scripts/cue/engine/call.py", line 104, in <module>
    _ = Parallel(n_jobs=n_procs)(
  File "/share/home/yzbsl_masw/.conda/envs/cue/lib/python3.8/site-packages/joblib/parallel.py", line 1029, in __call__
    if self.dispatch_one_batch(iterator):
  File "/share/home/yzbsl_masw/.conda/envs/cue/lib/python3.8/site-packages/joblib/parallel.py", line 847, in dispatch_one_batch
    self._dispatch(tasks)
  File "/share/home/yzbsl_masw/.conda/envs/cue/lib/python3.8/site-packages/joblib/parallel.py", line 765, in _dispatch
    job = self._backend.apply_async(batch, callback=cb)
  File "/share/home/yzbsl_masw/.conda/envs/cue/lib/python3.8/site-packages/joblib/_parallel_backends.py", line 208, in apply_async
    result = ImmediateResult(func)
  File "/share/home/yzbsl_masw/.conda/envs/cue/lib/python3.8/site-packages/joblib/_parallel_backends.py", line 572, in __init__
    self.results = batch()
  File "/share/home/yzbsl_masw/.conda/envs/cue/lib/python3.8/site-packages/joblib/parallel.py", line 252, in __call__
    return [func(*args, **kwargs)
  File "/share/home/yzbsl_masw/.conda/envs/cue/lib/python3.8/site-packages/joblib/parallel.py", line 252, in <listcomp>
    return [func(*args, **kwargs)
  File "/share/home/yzbsl_masw/scripts/cue/engine/call.py", line 88, in call
    predictions = core.evaluate(model, data_loader, config, device, output_dir=predictions_dir,
  File "/share/home/yzbsl_masw/scripts/cue/engine/core.py", line 96, in evaluate
    plotting.plot_images(images, predictions, range(len(images)), config.classes,
  File "/share/home/yzbsl_masw/scripts/cue/img/plotting.py", line 202, in plot_images
    image = annotate(image, targets[indices[i]], classes, display_boxes=True, color=(0, 76 / 255, 153 / 255))
  File "/share/home/yzbsl_masw/scripts/cue/img/plotting.py", line 163, in annotate
    cv2.circle(image, (p[0], p[1]), int(image_dim/100), color=(128/255, 128/255, 128/255),
TypeError: only integer tensors of a single element can be converted to an index
@shenweima
Copy link
Author

this is config info

Job 5810276 has been submitted to the queue [cpu]. Command: /share/home/yzbsl_masw/scripts/cue.sh
Job 5810276 is waiting to be started...
Job 5810276 has started on host hw50.
*********************************
*  cue (v0.2.2): discovery mode *
*********************************
[INFO]  ========== Model config ==========
        model_path: /share/home/yzbsl_masw/scripts/cue/data/models/cue.v2.pt
        gpu_ids: []
        n_jobs_per_gpu: 1
        n_cpus: 1
        report_interval: 100
        batch_size: 16
        logging_level: INFO
        signal_set: SV_SIGNAL_SET.SHORT
        class_set: SV_CLASS_SET.BASIC5ZYG
        num_keypoints: 1
        model_architecture: HG
        image_dim: 256
        sigma: 10
        stride: 4
        heatmap_peak_threshold: 0.4
        pretrained_refinenn_path: None
        config_file: call_model.yaml
        experiment_dir: /share/home/yzbsl_masw/data/projects/results/CS2.1/AABBDD/SV_cue
        devices: [device(type='cpu')]
        device: cpu
        log_dir: /share/home/yzbsl_masw/data/projects/results/CS2.1/AABBDD/SV_cue/logs/
        report_dir: /share/home/yzbsl_masw/data/projects/results/CS2.1/AABBDD/SV_cue/reports/
        log_file: /share/home/yzbsl_masw/data/projects/results/CS2.1/AABBDD/SV_cue/logs/main.log
        classes: ['NEG', 'DEL-HOM', 'INV-HOM', 'DUP-HOM', 'DEL-HET', 'INV-HET', 'DUP-HET', 'IDUP-HOM', 'IDUP-HET']
        num_classes: 9
        n_signals: 6
[INFO] ========== Data config =========
        bam: /share/home/yzbsl_masw/data/projects/results/CS2.1/AABBDD/1496A.mrkdup.sorted.cram
        fai: /share/home/yzbsl_masw/data/genomes/ref/Chinese_spring2.1_KN9204_1RS.fasta.fai
        chr_names: ['chr1A']
        logging_level: INFO
        n_cpus: 1
        min_refine_buffer: 2000
        refine_buffer_frac_size: 5
        refine_pair_dist_frac_size: 2
        refine_bp_kernels: [0, 50, 500]
        refine_min_support: 2
        refine_disable: False
        min_pair_support: 2
        min_pair_distance: 4000
        max_pair_distance: 1000000
        scan_target_intervals: True
        stream: True
        view_mode: False
        store_img: False
        empty_annotation: False
        bins_per_block: 8000
        min_sv_len: 4000
        min_qual_score: 50
        bam_type: BAM_TYPE.SHORT
        signal_set: SV_SIGNAL_SET.SHORT
        signal_set_origin: SHORT
        bed: None
        blacklist_bed: None
        signal_vmax: {'RD': 600, 'RD_LOW': 800, 'RD_CLIPPED': 600, 'SM': 200, 'SR_RP': 600, 'LR': 600, 'LLRR': 100, 'RL': 100, 'LLRR_VS_LR': 1}
        signal_mapq: {'RD': 20, 'RD_LOW': 0, 'RD_CLIPPED': 20, 'SM': 20, 'SR_RP': 0, 'LR': 0, 'LLRR': 1, 'RL': 1, 'LLRR_VS_LR': 1}
        bin_size: 750
        interval_size: 150000
        step_size: 50000
        shift_size: None
        heatmap_dim: 1000
        image_dim: 256
        class_set: SV_CLASS_SET.BASIC5ZYG
        num_keypoints: 1
        bbox_padding: 0
        config_file: call_data.yaml
        dataset_dir: /share/home/yzbsl_masw/data/projects/results/CS2.1/AABBDD/SV_cue
        info_dir: /share/home/yzbsl_masw/data/projects/results/CS2.1/AABBDD/SV_cue/info/
        image_dir: /share/home/yzbsl_masw/data/projects/results/CS2.1/AABBDD/SV_cue/images/
        annotation_dir: /share/home/yzbsl_masw/data/projects/results/CS2.1/AABBDD/SV_cue/annotations/
        annotated_images_dir: /share/home/yzbsl_masw/data/projects/results/CS2.1/AABBDD/SV_cue/annotated_images/
        classes: ['NEG', 'DEL-HOM', 'INV-HOM', 'DUP-HOM', 'DEL-HET', 'INV-HET', 'DUP-HET', 'IDUP-HOM', 'IDUP-HET']
        num_classes: 9
        num_signals: 6
        uid: 0000000000
        log_file: /share/home/yzbsl_masw/data/projects/results/CS2.1/AABBDD/SV_cue/info/main.log
[INFO] Running on 1 CPUs/GPUs
[INFO] Chromosome lists processed by each process: [array(['chr1A'], dtype='<U5')]
[INFO] Loaded model: /share/home/yzbsl_masw/scripts/cue/data/models/cue.v2.pt on cpu
[INFO] Loading AUX index: /share/home/yzbsl_masw/data/projects/results/CS2.1/AABBDD/1496A.mrkdup.sorted.cram.chr1A.750.SHORT.auxindex
[INFO] Generating SV predictions for chr1A
[INFO] Number of target interval pairs: 5776
[INFO] Interval pair: chr1A x=0 y=0
[INFO] Interval pair: chr1A x=0 y=50000
[INFO] Interval pair: chr1A x=0 y=100000
[INFO] Interval pair: chr1A x=0 y=150000
[INFO] Interval pair: chr1A x=0 y=200000
[INFO] Interval pair: chr1A x=0 y=250000
[INFO] Interval pair: chr1A x=0 y=300000
[INFO] Interval pair: chr1A x=0 y=350000
[INFO] Interval pair: chr1A x=0 y=400000

@viq854
Copy link
Contributor

viq854 commented Jun 22, 2023

Hi @shenweima,

I haven't encountered this issue before and need a bit more info to help debug this.
Everything seems good with the configs -- these are just default values with the custom cram and fasta index files, correct?
Could you also share the versions of the packages installed -- are you using the virtual environment install option or anything custom?

Thanks,
V

@prmunn
Copy link

prmunn commented Nov 12, 2024

Hi @viq854 and @shenweima - I got the same error and was able to work around it by casting p[0] and p[1] as integers on lines 161 and 163 of plotting.py

So, line 161 becomes:
cv2.circle(image, (int(p[0]), int(p[1])), int(image_dim/100), color=color, thickness=-thickness)
And line 163 becomes:
cv2.circle(image, (int(p[0]), int(p[1])), int(image_dim/100), color=(128/255, 128/255, 128/255), thickness=-thickness)

Hope this helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants