mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-15 02:11:15 +08:00
597337dcb8
* added playground with 12 demos * change name to recipes, restyle navbar * add explanatory text to page * fix demo mapping * categorize demos, clean up design * styling * cateogry naming and emojis * refactor and add text demos * add view code button * remove opening slash in embed * styling * add image demos * adding plot demos * remove see code button * removed submodules * changes * add audio models * remove fun section * remove tests in image semgentation demo repo * requested changes * add outbreak_forecast * fix broken demos * remove images and models, add new demos * remove readmes, change to run.py, add description as comment * move to /demos folder, clean up dict * add upload_to_spaces script * fix script, clean repos, and add to docker file * fix python versioning issue * env variable * fix * env fixes * spaces instead of tabs * revert to original networking.py * fix rate limiting in asr and autocomplete * change name to demos * clean up navbar * move url and description, remove code comments * add tabs to demos * remove margins and footer from embedded demo * font consistency Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
39 lines
1.0 KiB
Python
39 lines
1.0 KiB
Python
import gradio as gr
|
|
|
|
def tax_calculator(income, marital_status, assets):
|
|
tax_brackets = [(10, 0), (25, 8), (60, 12), (120, 20), (250, 30)]
|
|
total_deductible = sum(assets["Cost"])
|
|
taxable_income = income - total_deductible
|
|
|
|
total_tax = 0
|
|
for bracket, rate in tax_brackets:
|
|
if taxable_income > bracket:
|
|
total_tax += (taxable_income - bracket) * rate / 100
|
|
|
|
if marital_status == "Married":
|
|
total_tax *= 0.75
|
|
elif marital_status == "Divorced":
|
|
total_tax *= 0.8
|
|
|
|
return round(total_tax)
|
|
|
|
demo = gr.Interface(
|
|
tax_calculator,
|
|
[
|
|
"number",
|
|
gr.Radio(["Single", "Married", "Divorced"]),
|
|
gr.Dataframe(
|
|
headers=["Item", "Cost"],
|
|
datatype=["str", "number"],
|
|
label="Assets Purchased this Year",
|
|
),
|
|
],
|
|
"number",
|
|
examples=[
|
|
[10000, "Married", [["Suit", 5000], ["Laptop", 800], ["Car", 1800]]],
|
|
[80000, "Single", [["Suit", 800], ["Watch", 1800], ["Car", 800]]],
|
|
],
|
|
)
|
|
|
|
demo.launch()
|