anktechsol's picture
Create app.py
e0aba8b verified
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()