wuchendi commited on
Commit
da8a9cc
·
1 Parent(s): 3bc2007

feat: Add MODNet model configuration and quantization settings

Browse files

- Added config.json file to configure MODNet model type and data type
- Added ONNX model files, including FP32, FP16, and quantized versions
- Added preprocessor configuration and quantization configuration files
- Removed unnecessary requirements.txt file
- Deleted test and training scripts to simplify project structure

config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "modnet",
3
+ "transformers.js_config": {
4
+ "dtype": "fp32"
5
+ }
6
+ }
onnx/model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:07c308cf0fc7e6e8b2065a12ed7fc07e1de8febb7dc7839d7b7f15dd66584df9
3
+ size 25888640
onnx/model_fp16.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:25f165da9bfd30830a575f1f0490f1acd995975cb349bc02f3d79332e1fe5cf6
3
+ size 12984781
onnx/model_quantized.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:92e49898c3e05a6d7a944fc67a8cb87c4aad754ffb6ebd949528c7d1105fee3a
3
+ size 6632188
preprocessor_config.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_normalize": true,
3
+ "do_pad": false,
4
+ "do_rescale": true,
5
+ "do_resize": true,
6
+ "image_mean": [
7
+ 0.5,
8
+ 0.5,
9
+ 0.5
10
+ ],
11
+ "feature_extractor_type": "ImageFeatureExtractor",
12
+ "image_std": [
13
+ 0.5,
14
+ 0.5,
15
+ 0.5
16
+ ],
17
+ "resample": 2,
18
+ "rescale_factor": 0.00392156862745098,
19
+ "size": {
20
+ "shortest_edge": 512
21
+ },
22
+ "size_divisibility": 32
23
+ }
quantize_config.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "per_channel": false,
3
+ "reduce_range": false,
4
+ "per_model_config": {
5
+ "model": {
6
+ "op_types": [
7
+ "Sigmoid",
8
+ "Constant",
9
+ "Resize",
10
+ "Gather",
11
+ "MatMul",
12
+ "Clip",
13
+ "BatchNormalization",
14
+ "Concat",
15
+ "Conv",
16
+ "GlobalAveragePool",
17
+ "Expand",
18
+ "Add",
19
+ "Slice",
20
+ "Shape",
21
+ "Unsqueeze",
22
+ "Reshape",
23
+ "InstanceNormalization",
24
+ "Relu",
25
+ "Mul"
26
+ ],
27
+ "weight_type": "QUInt8"
28
+ }
29
+ }
30
+ }
requirements.txt DELETED
@@ -1,3 +0,0 @@
1
- # onnx==1.17.0
2
- torch==2.7.0
3
- swanlab==0.5.7
 
 
 
 
test.py DELETED
@@ -1,6 +0,0 @@
1
- import torch
2
- x = torch.rand(5, 3)
3
- print(x)
4
-
5
- print(torch.__version__)
6
- print(torch.cuda.is_available())
 
 
 
 
 
 
 
train.py DELETED
@@ -1,29 +0,0 @@
1
- import swanlab
2
- import random
3
-
4
- # 初始化一个新的swanlab run类来跟踪这个脚本
5
- swanlab.init(
6
- # 设置将记录此次运行的项目信息
7
- project="MODNet",
8
- workspace="wudi",
9
- # 跟踪超参数和运行元数据
10
- config={
11
- "learning_rate": 0.02,
12
- "architecture": "CNN",
13
- "dataset": "CIFAR-100",
14
- "epochs": 10
15
- }
16
- )
17
-
18
- # 模拟训练
19
- epochs = 10
20
- offset = random.random() / 5
21
- for epoch in range(2, epochs):
22
- acc = 1 - 2 ** -epoch - random.random() / epoch - offset
23
- loss = 2 ** -epoch + random.random() / epoch + offset
24
-
25
- # 向swanlab上传训练指标
26
- swanlab.log({"acc": acc, "loss": loss})
27
-
28
- # [可选] 完成训练,这在notebook环境中是必要的
29
- swanlab.finish()