File size: 1,751 Bytes
e0aba8b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | import gradio as gr
import random
import time
def benchmark_model(model_name, device, precision, batch_size):
# Simulate benchmark
time.sleep(1)
latency = round(random.uniform(5, 50), 2)
throughput = round(random.uniform(10, 200), 2)
power = round(random.uniform(1, 15), 2)
accuracy = round(random.uniform(85, 99), 2)
results = f"""### Benchmark Results for {model_name}
**Device**: {device}
**Precision**: {precision}
**Batch Size**: {batch_size}
π **Performance Metrics**:
- Latency: {latency}ms
- Throughput: {throughput} FPS
- Power Consumption: {power}W
- Accuracy: {accuracy}%
**Anktechsol** - Edge AI Solutions
π [Visit anktechsol.com](https://anktechsol.com)"""
return results
with gr.Blocks(title="Edge AI Benchmarker") as demo:
gr.Markdown("# π Edge AI Model Benchmarker")
gr.Markdown("Benchmark AI models on edge devices - **Anktechsol**")
with gr.Row():
with gr.Column():
model = gr.Dropdown(["MobileNetV2", "EfficientNet-B0", "YOLOv5n", "TinyBERT"], label="Model", value="MobileNetV2")
device = gr.Dropdown(["Raspberry Pi 4", "Jetson Nano", "Coral TPU", "iPhone 13"], label="Device", value="Raspberry Pi 4")
precision = gr.Radio(["FP32", "FP16", "INT8"], label="Precision", value="FP32")
batch = gr.Slider(1, 32, value=1, step=1, label="Batch Size")
btn = gr.Button("Run Benchmark")
with gr.Column():
output = gr.Markdown()
btn.click(benchmark_model, inputs=[model, device, precision, batch], outputs=output)
gr.Markdown("""---
### About Anktechsol
Expert AIoT & Edge AI consulting services. [Learn more β](https://anktechsol.com)""")
demo.launch() |