Spaces:
Running
Running
use model locally
Browse files- app.py +2 -4
- dinov2-base/config.json +48 -0
- dinov2-base/preprocessor_config.json +27 -0
- dinov2-base/pytorch_model.bin +3 -0
app.py
CHANGED
@@ -14,10 +14,8 @@ load_dotenv()
|
|
14 |
|
15 |
# Init similarity search AI model and processor
|
16 |
torch_device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
17 |
-
dino_v2_model = AutoModel.from_pretrained(
|
18 |
-
|
19 |
-
).to(torch_device)
|
20 |
-
dino_v2_image_processor = AutoImageProcessor.from_pretrained("facebook/dinov2-base")
|
21 |
|
22 |
# MongoDB
|
23 |
MONGO_URI = os.environ.get("MONGO_URI")
|
|
|
14 |
|
15 |
# Init similarity search AI model and processor
|
16 |
torch_device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
17 |
+
dino_v2_model = AutoModel.from_pretrained("./dinov2-base").to(torch_device)
|
18 |
+
dino_v2_image_processor = AutoImageProcessor.from_pretrained("./dinov2-base")
|
|
|
|
|
19 |
|
20 |
# MongoDB
|
21 |
MONGO_URI = os.environ.get("MONGO_URI")
|
dinov2-base/config.json
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "facebook/dinov2-base",
|
3 |
+
"apply_layernorm": true,
|
4 |
+
"architectures": [
|
5 |
+
"Dinov2Model"
|
6 |
+
],
|
7 |
+
"attention_probs_dropout_prob": 0.0,
|
8 |
+
"drop_path_rate": 0.0,
|
9 |
+
"hidden_act": "gelu",
|
10 |
+
"hidden_dropout_prob": 0.0,
|
11 |
+
"hidden_size": 768,
|
12 |
+
"image_size": 518,
|
13 |
+
"initializer_range": 0.02,
|
14 |
+
"layer_norm_eps": 1e-06,
|
15 |
+
"layerscale_value": 1.0,
|
16 |
+
"mlp_ratio": 4,
|
17 |
+
"model_type": "dinov2",
|
18 |
+
"num_attention_heads": 12,
|
19 |
+
"num_channels": 3,
|
20 |
+
"num_hidden_layers": 12,
|
21 |
+
"out_features": [
|
22 |
+
"stage12"
|
23 |
+
],
|
24 |
+
"out_indices": [
|
25 |
+
12
|
26 |
+
],
|
27 |
+
"patch_size": 14,
|
28 |
+
"qkv_bias": true,
|
29 |
+
"reshape_hidden_states": true,
|
30 |
+
"stage_names": [
|
31 |
+
"stem",
|
32 |
+
"stage1",
|
33 |
+
"stage2",
|
34 |
+
"stage3",
|
35 |
+
"stage4",
|
36 |
+
"stage5",
|
37 |
+
"stage6",
|
38 |
+
"stage7",
|
39 |
+
"stage8",
|
40 |
+
"stage9",
|
41 |
+
"stage10",
|
42 |
+
"stage11",
|
43 |
+
"stage12"
|
44 |
+
],
|
45 |
+
"torch_dtype": "float32",
|
46 |
+
"transformers_version": "4.34.0",
|
47 |
+
"use_swiglu_ffn": false
|
48 |
+
}
|
dinov2-base/preprocessor_config.json
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"crop_size": {
|
3 |
+
"height": 224,
|
4 |
+
"width": 224
|
5 |
+
},
|
6 |
+
"do_center_crop": true,
|
7 |
+
"do_convert_rgb": true,
|
8 |
+
"do_normalize": true,
|
9 |
+
"do_rescale": true,
|
10 |
+
"do_resize": true,
|
11 |
+
"image_mean": [
|
12 |
+
0.485,
|
13 |
+
0.456,
|
14 |
+
0.406
|
15 |
+
],
|
16 |
+
"image_processor_type": "BitImageProcessor",
|
17 |
+
"image_std": [
|
18 |
+
0.229,
|
19 |
+
0.224,
|
20 |
+
0.225
|
21 |
+
],
|
22 |
+
"resample": 3,
|
23 |
+
"rescale_factor": 0.00392156862745098,
|
24 |
+
"size": {
|
25 |
+
"shortest_edge": 256
|
26 |
+
}
|
27 |
+
}
|
dinov2-base/pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2520984c95638107c8d7366b0fb35d6690ed903e4f3bb8a36cdf15b835853b5c
|
3 |
+
size 346393158
|