Spaces:
Runtime error
Runtime error
File size: 2,811 Bytes
e4c59f6 |
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"c:\\Users\\ardit\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\gradio\\deprecation.py:43: UserWarning: You have unused kwarg parameters in Radio, please remove them: {'multiselect': False}\n",
" warnings.warn(\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Running on local URL: http://127.0.0.1:7861\n",
"\n",
"To create a public link, set `share=True` in `launch()`.\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"http://127.0.0.1:7861/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": []
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[40]\n",
"[40, 30]\n",
"[40, 30, 10]\n",
"[40, 30, 10, 10]\n",
"[40, 30, 10, 10, 10]\n"
]
}
],
"source": [
"import gradio as gr\n",
"import statistics\n",
"\n",
"def predict(history, input1):\n",
" history.append(input1)\n",
"\n",
" print(history)\n",
" total = statistics.mean(history)\n",
"\n",
" return total\n",
"\n",
"with gr.Blocks(theme=gr.themes.Soft(primary_hue='amber', secondary_hue='gray', neutral_hue='amber')) as demo:\n",
" gr.Markdown(\n",
" \"\"\"\n",
" # Gradio with History\n",
" \"\"\"\n",
" )\n",
" history = gr.Variable(value=[]) #beginning\n",
" input1 = gr.Radio([10, 20, 30, 40, 50], multiselect=False, label='value')\n",
" btn = gr.Button(value=\"Search for a Room\")\n",
" output1 = gr.Textbox(label='value')\n",
" # btn.click(greet, inputs='text', outputs=['dataframe'])\n",
" btn.click(predict, [history, input1], [output1])\n",
"demo.launch(share=False)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
|