freddyaboulton HF staff commited on
Commit
496d054
1 Parent(s): 8309062

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. run.ipynb +1 -1
README.md CHANGED
@@ -5,7 +5,7 @@ emoji: 🔥
5
  colorFrom: indigo
6
  colorTo: indigo
7
  sdk: gradio
8
- sdk_version: 3.47.1
9
  app_file: run.py
10
  pinned: false
11
  hf_oauth: true
 
5
  colorFrom: indigo
6
  colorTo: indigo
7
  sdk: gradio
8
+ sdk_version: 3.48.0
9
  app_file: run.py
10
  pinned: false
11
  hf_oauth: true
run.ipynb CHANGED
@@ -1 +1 @@
1
- {"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: tax_calculator\n", "### Calculate taxes using Textbox, Radio, and Dataframe components\n", " "]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "def tax_calculator(income, marital_status, assets):\n", " tax_brackets = [(10, 0), (25, 8), (60, 12), (120, 20), (250, 30)]\n", " total_deductible = sum(assets[\"Cost\"])\n", " taxable_income = income - total_deductible\n", "\n", " total_tax = 0\n", " for bracket, rate in tax_brackets:\n", " if taxable_income > bracket:\n", " total_tax += (taxable_income - bracket) * rate / 100\n", "\n", " if marital_status == \"Married\":\n", " total_tax *= 0.75\n", " elif marital_status == \"Divorced\":\n", " total_tax *= 0.8\n", "\n", " return round(total_tax)\n", "\n", "demo = gr.Interface(\n", " tax_calculator,\n", " [\n", " \"number\",\n", " gr.Radio([\"Single\", \"Married\", \"Divorced\"]),\n", " gr.Dataframe(\n", " headers=[\"Item\", \"Cost\"],\n", " datatype=[\"str\", \"number\"],\n", " label=\"Assets Purchased this Year\",\n", " ),\n", " ],\n", " \"number\",\n", " examples=[\n", " [10000, \"Married\", [[\"Suit\", 5000], [\"Laptop\", 800], [\"Car\", 1800]]],\n", " [80000, \"Single\", [[\"Suit\", 800], [\"Watch\", 1800], [\"Car\", 800]]],\n", " ],\n", ")\n", "\n", "demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
 
1
+ {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: tax_calculator\n", "### Calculate taxes using Textbox, Radio, and Dataframe components\n", " "]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "def tax_calculator(income, marital_status, assets):\n", " tax_brackets = [(10, 0), (25, 8), (60, 12), (120, 20), (250, 30)]\n", " total_deductible = sum(assets[\"Cost\"])\n", " taxable_income = income - total_deductible\n", "\n", " total_tax = 0\n", " for bracket, rate in tax_brackets:\n", " if taxable_income > bracket:\n", " total_tax += (taxable_income - bracket) * rate / 100\n", "\n", " if marital_status == \"Married\":\n", " total_tax *= 0.75\n", " elif marital_status == \"Divorced\":\n", " total_tax *= 0.8\n", "\n", " return round(total_tax)\n", "\n", "demo = gr.Interface(\n", " tax_calculator,\n", " [\n", " \"number\",\n", " gr.Radio([\"Single\", \"Married\", \"Divorced\"]),\n", " gr.Dataframe(\n", " headers=[\"Item\", \"Cost\"],\n", " datatype=[\"str\", \"number\"],\n", " label=\"Assets Purchased this Year\",\n", " ),\n", " ],\n", " \"number\",\n", " examples=[\n", " [10000, \"Married\", [[\"Suit\", 5000], [\"Laptop\", 800], [\"Car\", 1800]]],\n", " [80000, \"Single\", [[\"Suit\", 800], [\"Watch\", 1800], [\"Car\", 800]]],\n", " ],\n", ")\n", "\n", "demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}