Skip to content

Add SwiftFormer, SHViT, StarNet, FasterNet and GhostNetV3 #2499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

brianhou0208
Copy link
Contributor

@brianhou0208 brianhou0208 commented May 21, 2025

New Model

Model Request

resolve #2450

Result

Model Acc@1 MACs Params GPU Throughput CPU Throughput iOS NPU Latency Android NPU Latency
swiftformer_xs 75.586 603.77M 3.48M 3356.03 146.25 0.63 3.288
swiftformer_s 78.466 986.19M 6.09M 2519.29 123.62 0.76 3.386
swiftformer_l1 80.902 1.60G 12.06M 1832.04 100.77 1.07 3.810
swiftformer_l3 83.000 4.01G 28.49M 969.61 43.39 1.88 4.700
fasternet_t0 71.904 335.69M 3.91M 8924.14 461.35 0.50 0.256
fasternet_t1 76.210 850.94M 7.60M 4939.89 262.55 0.67 0.384
fasternet_t2 78.896 1.90G 14.98M 2548.34 133.69 1.04 0.641
fasternet_s 81.290 4.55G 31.18M 1219.00 62.62 1.88 1.257
fasternet_m 82.966 8.72G 53.52M 605.40 28.72 - 2.456
fasternet_l 83.506 15.50G 93.47M 381.80 17.43 - 4.505
shvit_s1 72.778 241.47M 6.31M 13566.14 494.77 0.60 0.461
shvit_s2 75.192 365.58M 11.45M 10214.81 413.26 0.81 0.523
shvit_s3 77.340 600.83M 14.21M 6676.91 299.91 0.96 0.625
shvit_s4 79.378 986.63M 16.55M 4149.87 177.38 1.09 0.798
starnet_s1 73.564 422.89M 2.87M 3859.64 233.59 0.48 0.471
starnet_s2 74.660 545.05M 3.68M 3888.33 203.43 0.51 0.438
starnet_s3 77.380 755.38M 5.75M 2760.39 150.84 0.66 0.548
starnet_s4 78.838 1.05G 7.48M 1938.80 112.58 0.81 0.720
ghostnetv3_100 76.928 168.00M 6.15M 3467.852 168.138 - 0.668
  • Only SHViT S4 uses (256, 256) input image size
  • SwiftFormer weight is on google drive

Param / MACs / Throughput

Figure_1

NPU Latency

  • iOS NPU: Apple iPhone 14 Pro Max / iOS 18.5 / A16
  • Android NPU: Samsung S24 / Android 14 / Snapdragon® 8 Gen 3 | SM8650

Figure_2

  • iOS latency reported for iPhone 14 Pro Max (iOS 18.5) uses the benchmark tool from Xcode 16.3

  • Android latency reported for Samsung Galaxy S24 (Android 14) uses the benchmark tool from Qualcomm® AI Hub Models

Measure Android Latency
import torch
import timm
from timm.utils.model import reparameterize_model
import qai_hub as hub


def latency_android(name, img_size=224):
    torch_model = timm.create_model(name)
    torch_model.eval()
    torch_model = reparameterize_model(torch_model)
    input_shape = (1, 3, img_size, img_size)
    example_input = torch.rand(input_shape)
    traced_model = torch.jit.trace(torch_model, example_input)
    compile_job = hub.submit_compile_job(
        model=traced_model,
        device=hub.Device("Samsung Galaxy S24 (Family)"),
        input_specs=dict(image=input_shape),
    )
    target_model = compile_job.get_target_model()
    profile_job = hub.submit_profile_job(
        model=target_model,
        device=hub.Device("Samsung Galaxy S24 (Family)"),
    )
    profile_result = profile_job.download_profile()
    latency_ms = profile_result["execution_summary"]["estimated_inference_time"] / 1000
    print(f"{name} 📊 Latency: {latency_ms:.3f} ms")


if __name__ == '__main__':
    name_list = timm.list_models('shvit*')
    print(name_list)
    for name in name_list:
        latency_android(name)

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Request for SwiftFormer classifier
2 participants