whuanle commited on
Commit
9aabe0c
·
1 Parent(s): c377926
README.md CHANGED
@@ -13,8 +13,3 @@
13
  ### Instructions
14
 
15
 
16
- ```
17
- conda install pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch -c nvidia
18
- pip install protobuf 'transformers>=4.41.2' cpm_kernels 'torch>=2.0' gradio mdtex2html sentencepiece accelerate
19
- pip install leb128
20
- ```
 
13
  ### Instructions
14
 
15
 
 
 
 
 
 
dats/alexnet.dat.md5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f8a48e2cc5fa4ce4947d2b66231a53a136313a8dab55fcc86c47714d4957a004
3
+ size 32
dats/googlenet.dat.md5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3fb4117f57a4cf129c7711ddd67db0909c7a6463e79e2684331cd3669b75ab69
3
+ size 32
dats/inception_v3.dat.md5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bee7356a4d8b538912806477f28204a203b82471d579d1a417558b6438929f92
3
+ size 32
dats/mobilenet_v2.dat.md5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e3e9c6c8499cbcb95b54f822b07104c45018a9d3b18197ac787b6ff3c5c879ce
3
+ size 32
dats/mobilenet_v3_large.dat.md5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f7e6c63102530549020ac2c7a5b1de01c4ebb27e4d81e623b3636c9badb74209
3
+ size 32
dats/mobilenet_v3_small.dat.md5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c5b42c62cdb0e7b2a4953ed93a564c79e0fe71e67a9313fbcdc24811150fc682
3
+ size 32
dats/resnet101.dat.md5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e571feceda4d79262412d0c22291aef44b83a45c91be4e74df07398e53c54896
3
+ size 32
dats/resnet152.dat.md5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:be5cebc7c0a18ddd63a0b2070298165b3799f99f4815d6c300ccab9f4ec05c81
3
+ size 32
dats/resnet18.dat.md5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:848465fd61c5df121fc6a9a8756e8585450c1cb8ee991b7322c8579ad35852a2
3
+ size 32
dats/resnet34.dat.md5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b14ade059a7f28e6f7f954a795c0d627a56ad60e738574628142a90b1d965552
3
+ size 32
dats/resnet50.dat.md5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:89e600d90718154e7b64e8ca56e68514150237c291105c34df406b7d48151a90
3
+ size 32
dats/vgg11.dat.md5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0b3e5e38d2bfa8f381a3c040a945407df7911ec4daf41fdb9242094cac34ce93
3
+ size 32
dats/vgg11_bn.dat.md5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b8b8dbf5aa4abdbb35cd03ee6ef795de6be935c458798820ee0e1edab5caf81b
3
+ size 32
dats/vgg13.dat.md5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fc23b5a547a3997801f86612d65ccb65ce63b7e9c6c60cb371edc4a99c052e45
3
+ size 32
dats/vgg13_bn.dat.md5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:366477853753d62a462627c4cdcc6997695bcd306456ea4354c12be122e6d234
3
+ size 32
dats/vgg16.dat.md5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2cd484e7518689faefdf14845605bbbd303384f84f4686ab147f47c9f63257b5
3
+ size 32
dats/vgg16_bn.dat.md5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c0ff25ba3c7947209dccdbb1a62c3b24f654d62841c427f136c4f5d6ff21ea78
3
+ size 32
dats/vgg19.dat.md5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1e5c62c0a695b40b946800d55ccf362062d31cb28581e2124c55152c5b0608c0
3
+ size 32
main.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import os
2
 
3
  import torch
@@ -32,12 +33,36 @@ else:
32
  torch.set_default_device(cuda_device)
33
 
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  def export_model(model: torch.nn.Module, model_name: str):
36
  cpu_filepath = os.path.join(dats_path, f"{model_name}.dat")
37
  if os.path.exists(cpu_filepath):
38
  os.remove(cpu_filepath)
39
  with open(cpu_filepath, "wb") as f_cpu:
40
  exportsd.save_state_dict(model.to(cpu_device).state_dict(), f_cpu)
 
 
41
 
42
  # if is_support_cuda:
43
  # cuda_filepath = os.path.join(dats_path, f"{model_name}.dat")
 
1
+ import hashlib
2
  import os
3
 
4
  import torch
 
33
  torch.set_default_device(cuda_device)
34
 
35
 
36
+ def generate_md5(file_path):
37
+ md5_hash = hashlib.md5()
38
+
39
+ try:
40
+ with open(file_path, 'rb') as file:
41
+ for byte_block in iter(lambda: file.read(4096), b""):
42
+ md5_hash.update(byte_block)
43
+ except FileNotFoundError:
44
+ print(f"Error: The file {file_path} was not found.")
45
+ return None
46
+ return md5_hash.hexdigest()
47
+
48
+
49
+ def save_md5_to_file(file_path, md5_value):
50
+ md5_file_path = f"{file_path}.md5"
51
+ try:
52
+ with open(md5_file_path, 'w') as md5_file:
53
+ md5_file.write(md5_value)
54
+ except IOError as e:
55
+ print(f"Error: Unable to write to {md5_file_path} - {e}")
56
+
57
+
58
  def export_model(model: torch.nn.Module, model_name: str):
59
  cpu_filepath = os.path.join(dats_path, f"{model_name}.dat")
60
  if os.path.exists(cpu_filepath):
61
  os.remove(cpu_filepath)
62
  with open(cpu_filepath, "wb") as f_cpu:
63
  exportsd.save_state_dict(model.to(cpu_device).state_dict(), f_cpu)
64
+ md5_hash = generate_md5(cpu_filepath)
65
+ save_md5_to_file(cpu_filepath, md5_hash)
66
 
67
  # if is_support_cuda:
68
  # cuda_filepath = os.path.join(dats_path, f"{model_name}.dat")