CoolFace
Apppublic

dispatchAI/phone-vs-cloud

sourceHugging Faceapache-2.0updated 3mo agoView on Hugging Face
0likes
app.py86 linesDownload Raw Back to root
1import gradio as gr2 3def calculate_cost(daily_queries, cloud_cost_per_1k, days=365):4    """Compare cloud vs on-device costs."""5    # Cloud cost6    cloud_daily = (daily_queries / 1000) * cloud_cost_per_1k7    cloud_annual = cloud_daily * days8    9    # On-device cost (one-time model download, then $0)10    # Average model size: 500MB, data cost: $1/GB (conservative)11    onetime_download_cost = 0.5  # 500MB at $1/GB12    on_device_annual = onetime_download_cost  # No per-query cost13    14    # Savings15    savings = cloud_annual - on_device_annual16    savings_pct = (savings / cloud_annual * 100) if cloud_annual > 0 else 017    18    result = f"""19## ๐Ÿ’ฐ Cost Comparison: Cloud vs On-Device20 21| Metric | Cloud API | dispatchAI On-Device |22|--------|-----------|---------------------|23| Cost per 1K queries | ${cloud_cost_per_1k:.2f} | $0.00 |24| Daily cost | ${cloud_daily:.2f} | $0.00 |25| Monthly cost | ${cloud_daily * 30:.2f} | $0.00 |26| **Annual cost** | **${cloud_annual:.2f}** | **${on_device_annual:.2f}** |27| One-time setup | $0 | ${onetime_download_cost:.2f} (data) |28 29## ๐Ÿ“Š Your Savings30 31- **Annual savings: ${savings:.2f}**32- **Savings: {savings_pct:.0f}%**33- **5-year savings: ${savings * 5:.2f}**34- **10-year savings: ${savings * 10:.2f}**35 36## Why On-Device Wins37 381. **Zero per-query cost** โ€” Once the model is on the phone, every inference is free392. **No network needed** โ€” Works offline, on airplanes, in tunnels403. **Zero latency** โ€” No round-trip to a server414. **Privacy** โ€” Data never leaves the device425. **No rate limits** โ€” Process a million queries, still $043 44## dispatchAI Models for On-Device45 46| Model | Size | Best For |47|-------|------|----------|48| SmolLM2-135M | 270MB | Classification, simple QA |49| Qwen2.5-0.5B | 350MB (Q4) | Chat, summarization |50| Llama-3.2-1B | 650MB (Q4) | General assistant |51| Llama-3.2-3B | 2.1GB (Q5) | Complex tasks |52 53[Browse all 39 models โ†’](https://huggingface.co/dispatchAI)54"""55    return result56 57with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue"), title="Phone vs Cloud Cost Calculator") as demo:58    gr.Markdown("""59    # ๐Ÿ’ฐ Phone vs Cloud Cost Calculator60    61    See how much you save by running AI on-device with dispatchAI instead of paying for cloud API inference.62    """)63    64    with gr.Row():65        daily_queries = gr.Slider(100, 100000, value=10000, step=100, 66                                   label="Daily Queries", info="How many AI queries per day?")67        cloud_cost = gr.Slider(0.1, 10.0, value=0.5, step=0.1,68                                label="Cloud API Cost ($/1K queries)",69                                info="What does your cloud API charge per 1000 queries?")70    71    calc_btn = gr.Button("Calculate Savings", variant="primary", size="lg")72    output = gr.Markdown()73    74    calc_btn.click(fn=calculate_cost, inputs=[daily_queries, cloud_cost], outputs=output)75    76    # Pre-populate with defaults77    demo.load(fn=calculate_cost, inputs=[daily_queries, cloud_cost], outputs=output)78    79    gr.Markdown("""80    ---81    ๐Ÿš€ [dispatchAI](https://huggingface.co/dispatchAI) โ€” Small. Mobile. Free. UAE-built.82    """)83 84if __name__ == "__main__":85    demo.launch()86