Jorgvt commited on
Commit
2b37d03
·
1 Parent(s): 809bcea

:tada: Uploaded fully trained model

Browse files
Files changed (4) hide show
  1. README.md +71 -0
  2. config.json +1 -0
  3. weights.msgpack +3 -0
  4. weights.safetensors +3 -0
README.md CHANGED
@@ -1,3 +1,74 @@
1
  ---
2
  license: apache-2.0
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ tags:
4
+ - jax
5
+ - safetensors
6
  ---
7
+
8
+ # Parametric PerceptNet Fully Trained
9
+
10
+ ## Model Description
11
+
12
+ ## How to use it
13
+
14
+ ### Install the model's package from source:
15
+ ```
16
+ git clone https://github.com/Jorgvt/paramperceptnet.git
17
+ cd paramperceptnet
18
+ pip install -e .
19
+ ```
20
+
21
+ ### 1.Import necessary libraries:
22
+
23
+ ```
24
+ import json
25
+
26
+ from huggingface_hub import hf_hub_download
27
+ import flax
28
+ import orbax.checkpoint
29
+ from ml_collections import ConfigDict
30
+
31
+ from paramperceptnet.models import PerceptNet
32
+ ```
33
+
34
+ ### 2.Download the configuration
35
+
36
+ ```
37
+ config_path = hf_hub_download(repo_id="Jorgvt/ppnet-fully-trained",
38
+ filename="config.json")
39
+ with open(config_path, "r") as f:
40
+ config = ConfigDict(json.load(f))
41
+ ```
42
+
43
+ ### 3. Download the weights
44
+
45
+ #### 3.1. Using `safetensors`
46
+
47
+ ```
48
+ from safetensors.flax import load_file
49
+
50
+ weights_path = hf_hub_download(repo_id="Jorgvt/ppnet-fully-trained",
51
+ filename="weights.safetensors")
52
+ variables = load_file(weights_path)
53
+ variables = flax.traverse_util.unflatten_dict(variables, sep=".")
54
+ state = variables["state"]
55
+ params = variables["params"]
56
+ ```
57
+
58
+ #### 3.2. Using `mgspack`
59
+ ```
60
+ weights_path = hf_hub_download(repo_id="Jorgvt/ppnet-fully-trained",
61
+ filename="weights.msgpack")
62
+ with open(weights_path, "rb") as f:
63
+ variables = orbax.checkpoint.msgpack_utils.msgpack_restore(f.read())
64
+ variables = jax.tree_util.tree_map(lambda x: jnp.array(x), variables)
65
+ state = variables["state"]
66
+ params = variables["params"]
67
+ ```
68
+
69
+ ### 4. Use the model
70
+
71
+ ```
72
+ from jax import numpy as jnp
73
+ pred = model.apply({"params": params, **state}, jnp.ones((1,384,512,3)))
74
+ ```
config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"A_GABOR": true, "A_GDNSPATIOFREQORIENT": true, "BATCH_SIZE": 64, "CS_KERNEL_SIZE": 21, "END_LR": 0.005, "EPOCHS": 500, "GABOR_KERNEL_SIZE": 31, "GDNFINAL_KERNEL_SIZE": 21, "GDNGAUSSIAN_KERNEL_SIZE": 11, "GDN_CLIPPING": true, "INITIAL_LR": 0.01, "INIT_GABOR": true, "INIT_JH": true, "LEARNING_RATE": 0.003, "NORMALIZE_ENERGY": true, "NORMALIZE_PROB": false, "PEAK_LR": 0.04, "SEED": 42, "TRAIN_CS": true, "TRAIN_GABOR": true, "TRAIN_GDNCOLOR": false, "TRAIN_GDNGAMMA": true, "TRAIN_GDNGAUSSIAN": true, "TRAIN_JH": true, "TRAIN_ONLY_LAST_GDN": false, "USE_BIAS": false, "USE_GAMMA": true, "WARMUP_EPOCHS": 15, "ZERO_MEAN": true}
weights.msgpack ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6e331558c13e18656a6c1688e3fee2eeab7057260cd9301362b87a95b7ac9fd2
3
+ size 1724898
weights.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:44866a40fa4e0ada8a5db1991c395df904e24dbe52da2edb1f8110a054aa8e7e
3
+ size 1727968