Update config.py
Browse files
config.py
CHANGED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
git clone https://github.com/opendilab/InterFuser.git
|
| 2 |
+
pip install timm
|
| 3 |
+
import sys
|
| 4 |
+
sys.path.append('/content/InterFuser')
|
| 5 |
+
import math
|
| 6 |
+
import copy
|
| 7 |
+
import sys
|
| 8 |
+
from collections import OrderedDict
|
| 9 |
+
from functools import partial
|
| 10 |
+
from typing import Optional, List
|
| 11 |
+
from huggingface_hub import HfApi
|
| 12 |
+
|
| 13 |
+
import numpy as np
|
| 14 |
+
import torch
|
| 15 |
+
from torch import nn, Tensor
|
| 16 |
+
import torch.nn.functional as F
|
| 17 |
+
from InterFuser.modeling_interfuser import InterfuserConfig, InterfuserForHuggingFace
|
| 18 |
+
from huggingface_hub import notebook_login
|
| 19 |
+
# --- هذه هي الأسطر المهمة التي يجب التأكد من وجودها ---
|
| 20 |
+
from InterFuser.interfuser.timm.models.layers import StdConv2dSame, StdConv2d, to_2tuple
|
| 21 |
+
from InterFuser.interfuser.timm.models.registry import register_model
|
| 22 |
+
from InterFuser.interfuser.timm.models.resnet import resnet26d, resnet50d, resnet18d, resnet26, resnet50, resnet101d
|
| 23 |
+
# --------------------------------------------------------
|
| 24 |
+
from transformers import AutoConfig, AutoModel
|
| 25 |
+
import os
|
| 26 |
+
|
| 27 |
+
class InterfuserConfig(PretrainedConfig):
|
| 28 |
+
|
| 29 |
+
model_type = "interfuser"
|
| 30 |
+
def __init__(
|
| 31 |
+
self,
|
| 32 |
+
embed_dim=256,
|
| 33 |
+
enc_depth=6,
|
| 34 |
+
dec_depth=6,
|
| 35 |
+
num_heads=8,
|
| 36 |
+
dim_feedforward=2048,
|
| 37 |
+
rgb_backbone_name="r50",
|
| 38 |
+
lidar_backbone_name="r18",
|
| 39 |
+
waypoints_pred_head="gru",
|
| 40 |
+
use_different_backbone=True,
|
| 41 |
+
**kwargs
|
| 42 |
+
):
|
| 43 |
+
super().__init__(**kwargs)
|
| 44 |
+
self.embed_dim = embed_dim
|
| 45 |
+
self.enc_depth = enc_depth
|
| 46 |
+
self.dec_depth = dec_depth
|
| 47 |
+
self.num_heads = num_heads
|
| 48 |
+
self.dim_feedforward = dim_feedforward
|
| 49 |
+
self.rgb_backbone_name = rgb_backbone_name
|
| 50 |
+
self.lidar_backbone_name = lidar_backbone_name
|
| 51 |
+
self.waypoints_pred_head = waypoints_pred_head
|
| 52 |
+
self.use_different_backbone = use_different_backbone
|
| 53 |
+
# Add the architectures key for auto-mapping
|
| 54 |
+
self.architectures = ["InterfuserForHuggingFace"]
|