z-x-yang / CFBI

The official implementation of CFBI(+): Collaborative Video Object Segmentation by (Multi-scale) Foreground-Background Integration.
BSD 3-Clause "New" or "Revised" License
322 stars 43 forks source link

float16 flag error #40

Closed Meryl-Fang closed 3 years ago

Meryl-Fang commented 3 years ago

Hi! Thank you for sharing this great repo! I was using it to infer on my own data, and when turning float16=True, I got the following error

Ref Frame: 00001.jpg, Time: 4.778830528259277 Traceback (most recent call last): File "tools/eval_net.py", line 65, in <module> main() File "tools/eval_net.py", line 62, in main evaluator.evaluating() File "./networks/engine/eval_manager.py", line 189, in evaluating all_pred, current_embedding = self.model.forward_for_eval(ref_emb, ref_m, prev_emb, prev_m, current_img, gt_ids=obj_num, pred_size=[ori_height,ori_width]) File "./networks/cfbi/cfbi.py", line 93, in forward_for_eval tf_board=False) File "./networks/cfbi/cfbi.py", line 184, in before_seghead_process use_float16=cfg.MODEL_FLOAT16_MATCHING) File "./networks/layers/matching.py", line 305, in global_matching_for_eval reference_embeddings_flat, query_embeddings_flat, reference_labels_flat, n_chunks) File "./networks/layers/matching.py", line 107, in _nearest_neighbor_features_per_object_in_chunks ref_square = reference_embeddings_flat.pow(2).sum(1) RuntimeError: "pow" not implemented for 'Half'

I wonder if there's a solution to this, or should I use some mix-precision package. Thank you very much for your help!

z-x-yang commented 3 years ago

What's your pytorch version? The code of float 16 should be ok for pytorch >= 1.4.

Meryl-Fang commented 3 years ago

What's your pytorch version? The code of float 16 should be ok for pytorch >= 1.4.

pytorch 1.8

z-x-yang commented 3 years ago

Emmm...

Maybe pytorch 1.4 is OK.

Meryl-Fang commented 3 years ago

Emmm...

Maybe pytorch 1.4 is OK.

Okay, will try that and let you know, thank you!!