{"id":18264538,"url":"https://github.com/modeltc/l2_compression","last_synced_at":"2025-07-08T18:03:15.997Z","repository":{"id":186741451,"uuid":"675664918","full_name":"ModelTC/L2_Compression","owner":"ModelTC","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-16T13:11:09.000Z","size":115,"stargazers_count":13,"open_issues_count":1,"forks_count":0,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-20T19:16:20.257Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ModelTC.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-07T12:48:41.000Z","updated_at":"2025-01-16T13:54:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"ac7c1e6f-4226-491d-9423-60d5ce2bef20","html_url":"https://github.com/ModelTC/L2_Compression","commit_stats":null,"previous_names":["modeltc/l2_compression"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ModelTC%2FL2_Compression","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ModelTC%2FL2_Compression/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ModelTC%2FL2_Compression/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ModelTC%2FL2_Compression/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ModelTC","download_url":"https://codeload.github.com/ModelTC/L2_Compression/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247251971,"owners_count":20908600,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T11:15:03.288Z","updated_at":"2025-04-04T21:30:35.211Z","avatar_url":"https://github.com/ModelTC.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# L^2 compression\n\n## Introduction\n\nDeep neural networks have delivered remarkable performance and have been widely used in various visual tasks. However, their huge size causes significant inconvenience for transmission and storage. This work proposes a unified post-training model size compression method that combines lossy and lossless compression. \n\n## Requirements\n\n* torch\n\n* torchvision\n\n* constriction\n\n* ninja\n\n* matplotlib\n\n* timm\n\n````shell\npip install -r requirements.txt\n````\n\n## Usage\n\n### train\n\n* change the model checkpoints paths in train/train_final\n\n  ```` python\n  state_path = {\n      \"resnet18\": \"\",\n      \"resnet50\": \"\",\n      \"mobilenetv2\": \"\",\n      \"mnasnet\": \"\",\n      \"regnetx_600m\": \"\",\n      \"regnetx_3200m\": \"\"\n  }\n  ````\n\n* change dataset in  train/train_final\n\n  ````python\n  train_dataset = ImageNetDataset(ROOTDIR + '/train/', 'train.txt', train_transform)\n  test_dataset = ImageNetDataset(ROOTDIR + 'val/', METADIR + 'val.txt', val_transform)\n  ````\n\n  * the calibration dataset we provide is train.txt in the repo\n\n* examples are in run.sh\n\n  ````shell\n  # example ResNet18\n  python -u -m train.train_final \\\n      --model_name resnet18 \\\n      --lambda_r 1e-6 \\\n      --lambda_kd 1.0 \\\n      --weight_transform edgescale \\\n      --bias_transform scale \\\n      --transform_iter 300 \\\n      --transform_lr 0.0001 \\\n      --reconstruct_iter 1000 \\\n      --reconstruct_lr 5e-06 \\\n      --resolution 64 \\\n      --diffkernel cos \\\n      --log_path ./log \\\n      --target_CR 10.0  \\\n      --run_name resnet_test\n  ````\n\n## encode and decode\n\nrefer to cal_bit.py","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodeltc%2Fl2_compression","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmodeltc%2Fl2_compression","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodeltc%2Fl2_compression/lists"}