float16 weights

#1
by pcuenq HF Staff - opened
README.md CHANGED
@@ -1,7 +1,5 @@
1
- ---
2
- license: apache-2.0
3
- ---
4
  This repo compiles the two safetensors files required to support the Candle version of Depth Anything v2 (Small):
5
 
6
  * dinov2_vits14.safetensors, copied from [lmz/candle-dino-v2](https://huggingface.co/lmz/candle-dino-v2).
7
- * depth_anything_v2_vits.safetensors, copied from [jeroenvlek/depth-anything-v2-safetensors](https://huggingface.co/jeroenvlek/depth-anything-v2-safetensors)
 
 
 
 
 
1
  This repo compiles the two safetensors files required to support the Candle version of Depth Anything v2 (Small):
2
 
3
  * dinov2_vits14.safetensors, copied from [lmz/candle-dino-v2](https://huggingface.co/lmz/candle-dino-v2).
4
+ * depth_anything_v2_vits.safetensors, copied from [jeroenvlek/depth-anything-v2-safetensors](https://huggingface.co/jeroenvlek/depth-anything-v2-safetensors)
5
+
convert.ipynb ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 13,
6
+ "id": "5051b2d0-973e-435f-bf84-1dd1e306fdfa",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "import torch\n",
11
+ "from safetensors.torch import load_file, save_file\n",
12
+ "from pathlib import Path"
13
+ ]
14
+ },
15
+ {
16
+ "cell_type": "code",
17
+ "execution_count": 17,
18
+ "id": "174d9aee-f341-4a46-a04c-3587f63e56f1",
19
+ "metadata": {},
20
+ "outputs": [],
21
+ "source": [
22
+ "def load_as_fp16(filename):\n",
23
+ " weights = load_file(filename)\n",
24
+ " weights = {k: v.to(dtype=torch.float16) for k, v in weights.items()}\n",
25
+ " return weights"
26
+ ]
27
+ },
28
+ {
29
+ "cell_type": "code",
30
+ "execution_count": 10,
31
+ "id": "1770b346-151a-4588-b5b7-46ec8ed6f64c",
32
+ "metadata": {},
33
+ "outputs": [],
34
+ "source": [
35
+ "def convert_to_fp16(filename):\n",
36
+ " weights = load_as_fp16(filename)\n",
37
+ " save_file(weights, str(Path(filename).with_suffix(\".fp16.safetensors\"))"
38
+ ]
39
+ },
40
+ {
41
+ "cell_type": "code",
42
+ "execution_count": 23,
43
+ "id": "dffe8f2b-dfab-4d8c-b101-05c952a34f79",
44
+ "metadata": {},
45
+ "outputs": [],
46
+ "source": [
47
+ "convert_to_fp16(\"dinov2_vits14.safetensors\")"
48
+ ]
49
+ },
50
+ {
51
+ "cell_type": "code",
52
+ "execution_count": 23,
53
+ "id": "099077e5-e612-4cf5-9a5e-feb1fca61113",
54
+ "metadata": {},
55
+ "outputs": [],
56
+ "source": [
57
+ "convert_to_fp16(\"depth_anything_v2_vits.safetensors\")"
58
+ ]
59
+ },
60
+ {
61
+ "cell_type": "code",
62
+ "execution_count": null,
63
+ "id": "205cdf2f-32f7-4f2d-8808-cf38bf2eba0a",
64
+ "metadata": {},
65
+ "outputs": [],
66
+ "source": []
67
+ },
68
+ {
69
+ "cell_type": "code",
70
+ "execution_count": 27,
71
+ "id": "ce4532a7-e85c-4683-990e-05fd43b427d4",
72
+ "metadata": {},
73
+ "outputs": [
74
+ {
75
+ "data": {
76
+ "text/plain": [
77
+ "PosixPath('dinov2_vits14.fp16.safetensors')"
78
+ ]
79
+ },
80
+ "execution_count": 27,
81
+ "metadata": {},
82
+ "output_type": "execute_result"
83
+ }
84
+ ],
85
+ "source": [
86
+ "p.with_suffix(\".fp16.safetensors\")"
87
+ ]
88
+ },
89
+ {
90
+ "cell_type": "code",
91
+ "execution_count": null,
92
+ "id": "f3d6a203-e5e5-4db7-a17c-4167cdb13485",
93
+ "metadata": {},
94
+ "outputs": [],
95
+ "source": []
96
+ }
97
+ ],
98
+ "metadata": {
99
+ "kernelspec": {
100
+ "display_name": "Python 3 (ipykernel)",
101
+ "language": "python",
102
+ "name": "python3"
103
+ },
104
+ "language_info": {
105
+ "codemirror_mode": {
106
+ "name": "ipython",
107
+ "version": 3
108
+ },
109
+ "file_extension": ".py",
110
+ "mimetype": "text/x-python",
111
+ "name": "python",
112
+ "nbconvert_exporter": "python",
113
+ "pygments_lexer": "ipython3",
114
+ "version": "3.12.7"
115
+ }
116
+ },
117
+ "nbformat": 4,
118
+ "nbformat_minor": 5
119
+ }
depth_anything_v2_vits.fp16.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:73e34d35b475bc075ac0b061671e5780800ed734c7eba2f702755f756b60b171
3
+ size 49595170
dinov2_vits14.fp16.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ebfaef20f34130315ced79ef159f27acfba48ba271d6a2261483199b02a02983
3
+ size 45667104