mohammed-aljafry commited on
Commit
0abf9da
·
verified ·
1 Parent(s): d62455e

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. modeling_interfuser.py +32 -5
  2. pytorch_model.bin +1 -1
modeling_interfuser.py CHANGED
@@ -1,7 +1,6 @@
1
 
2
  # -*- coding: utf-8 -*-
3
  # This file contains all custom class definitions required to run the Interfuser model.
4
-
5
  import torch
6
  from torch import nn
7
  import torch.nn.functional as F
@@ -198,7 +197,33 @@ class GRUWaypointsPredictor(nn.Module):
198
 
199
  # --- The ORIGINAL Interfuser Model Class ---
200
  class Interfuser(nn.Module):
201
- def __init__(self, img_size=224, multi_view_img_size=112, patch_size=8, in_chans=3, embed_dim=768, enc_depth=6, dec_depth=6, dim_feedforward=2048, normalize_before=False, rgb_backbone_name="r26", lidar_backbone_name="r26", num_heads=8, norm_layer=None, dropout=0.1, end2end=False, direct_concat=True, separate_view_attention=False, separate_all_attention=False, act_layer=None, weight_init="", freeze_num=-1, with_lidar=False, with_right_left_sensors=True, with_center_sensor=False, traffic_pred_head_type="det", waypoints_pred_head="heatmap", reverse_pos=True, use_different_backbone=False, use_view_embed=True, use_mmad_pretrain=None):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
  super().__init__()
203
  self.num_features = self.embed_dim = embed_dim
204
  norm_layer = norm_layer or partial(nn.LayerNorm, eps=1e-6)
@@ -295,6 +320,8 @@ class InterfuserConfig(PretrainedConfig):
295
 
296
  model_type = "interfuser"
297
 
 
 
298
  def __init__(
299
  self,
300
  embed_dim=256,
@@ -336,6 +363,7 @@ class InterfuserForHuggingFace(PreTrainedModel):
336
  # The parameters are taken from our config object.
337
  # This requires the original 'Interfuser' class to be defined in the notebook.
338
  self.interfuser_model = Interfuser(
 
339
  embed_dim=self.config.embed_dim,
340
  enc_depth=self.config.enc_depth,
341
  dec_depth=self.config.dec_depth,
@@ -346,7 +374,7 @@ class InterfuserForHuggingFace(PreTrainedModel):
346
  waypoints_pred_head=self.config.waypoints_pred_head,
347
  use_different_backbone=self.config.use_different_backbone
348
  )
349
-
350
  def forward(self, rgb, rgb_left, rgb_right, rgb_center, lidar, measurements, target_point, **kwargs):
351
 
352
  # The original model expects a dictionary, so we create one.
@@ -364,5 +392,4 @@ class InterfuserForHuggingFace(PreTrainedModel):
364
  # The output is already a tuple, which is what HF expects.
365
  return self.interfuser_model.forward(inputs_dict)
366
 
367
- # --- رسالة تأكيد ---
368
- print("✅ Hugging Face wrapper classes (InterfuserConfig, InterfuserForHuggingFace) are now defined.")
 
1
 
2
  # -*- coding: utf-8 -*-
3
  # This file contains all custom class definitions required to run the Interfuser model.
 
4
  import torch
5
  from torch import nn
6
  import torch.nn.functional as F
 
197
 
198
  # --- The ORIGINAL Interfuser Model Class ---
199
  class Interfuser(nn.Module):
200
+ def __init__(self, img_size=224,
201
+ multi_view_img_size=112,
202
+ patch_size=8, in_chans=3,
203
+ embed_dim=768,
204
+ enc_depth=6,
205
+ dec_depth=6,
206
+ dim_feedforward=2048,
207
+ normalize_before=False,
208
+ rgb_backbone_name="r26",
209
+ lidar_backbone_name="r26",
210
+ num_heads=8, norm_layer=None,
211
+ dropout=0.1, end2end=False,
212
+ direct_concat=True,
213
+ separate_view_attention=False,
214
+ separate_all_attention=False,
215
+ act_layer=None,
216
+ weight_init="",
217
+ freeze_num=-1,
218
+ with_lidar=False,
219
+ with_right_left_sensors=True,
220
+ with_center_sensor=False,
221
+ traffic_pred_head_type="det",
222
+ waypoints_pred_head="heatmap",
223
+ reverse_pos=True,
224
+ use_different_backbone=False,
225
+ use_view_embed=True,
226
+ use_mmad_pretrain=None):
227
  super().__init__()
228
  self.num_features = self.embed_dim = embed_dim
229
  norm_layer = norm_layer or partial(nn.LayerNorm, eps=1e-6)
 
320
 
321
  model_type = "interfuser"
322
 
323
+
324
+
325
  def __init__(
326
  self,
327
  embed_dim=256,
 
363
  # The parameters are taken from our config object.
364
  # This requires the original 'Interfuser' class to be defined in the notebook.
365
  self.interfuser_model = Interfuser(
366
+ in_chans=self.config.in_chans, # هنا تُمرّر القيمه
367
  embed_dim=self.config.embed_dim,
368
  enc_depth=self.config.enc_depth,
369
  dec_depth=self.config.dec_depth,
 
374
  waypoints_pred_head=self.config.waypoints_pred_head,
375
  use_different_backbone=self.config.use_different_backbone
376
  )
377
+
378
  def forward(self, rgb, rgb_left, rgb_right, rgb_center, lidar, measurements, target_point, **kwargs):
379
 
380
  # The original model expects a dictionary, so we create one.
 
392
  # The output is already a tuple, which is what HF expects.
393
  return self.interfuser_model.forward(inputs_dict)
394
 
395
+
 
pytorch_model.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:7900840868237b4916efd78f996eb338480b79985dc09a29e574d1e9b130da29
3
  size 212282626
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b96a031dc969bdb3c572e0945311632e6c7737489bec69df1c418308d04506ea
3
  size 212282626