aliabd HF staff commited on
Commit
7846c5d
1 Parent(s): 6b1ca83

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. requirements.txt +2 -2
  2. run.ipynb +1 -1
  3. run.py +2 -5
requirements.txt CHANGED
@@ -1,2 +1,2 @@
1
- gradio-client @ git+https://github.com/gradio-app/gradio@de997e67c9a7feb9e2eccebf92969366dbd67eba#subdirectory=client/python
2
- https://gradio-builds.s3.amazonaws.com/de997e67c9a7feb9e2eccebf92969366dbd67eba/gradio-4.39.0-py3-none-any.whl
 
1
+ gradio-client @ git+https://github.com/gradio-app/gradio@9b42ba8f1006c05d60a62450d3036ce0d6784f86#subdirectory=client/python
2
+ https://gradio-builds.s3.amazonaws.com/9b42ba8f1006c05d60a62450d3036ce0d6784f86/gradio-4.39.0-py3-none-any.whl
run.ipynb CHANGED
@@ -1 +1 @@
1
- {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: blocks_form"]}, {"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", "with gr.Blocks() as demo:\n", " error_box = gr.Textbox(label=\"Error\", visible=False)\n", "\n", " name_box = gr.Textbox(label=\"Name\")\n", " age_box = gr.Number(label=\"Age\", minimum=0, maximum=100)\n", " symptoms_box = gr.CheckboxGroup([\"Cough\", \"Fever\", \"Runny Nose\"])\n", " submit_btn = gr.Button(\"Submit\")\n", "\n", " with gr.Column(visible=False) as output_col:\n", " diagnosis_box = gr.Textbox(label=\"Diagnosis\")\n", " patient_summary_box = gr.Textbox(label=\"Patient Summary\")\n", "\n", " def submit(name, age, symptoms):\n", " if len(name) == 0:\n", " return {error_box: gr.Textbox(value=\"Enter name\", visible=True)}\n", " return {\n", " output_col: gr.Column(visible=True),\n", " diagnosis_box: \"covid\" if \"Cough\" in symptoms else \"flu\",\n", " patient_summary_box: f\"{name}, {age} y/o\",\n", " }\n", "\n", " submit_btn.click(\n", " submit,\n", " [name_box, age_box, symptoms_box],\n", " [error_box, diagnosis_box, patient_summary_box, output_col],\n", " )\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
 
1
+ {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: blocks_form"]}, {"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", "with gr.Blocks() as demo:\n", " name_box = gr.Textbox(label=\"Name\")\n", " age_box = gr.Number(label=\"Age\", minimum=0, maximum=100)\n", " symptoms_box = gr.CheckboxGroup([\"Cough\", \"Fever\", \"Runny Nose\"])\n", " submit_btn = gr.Button(\"Submit\")\n", "\n", " with gr.Column(visible=False) as output_col:\n", " diagnosis_box = gr.Textbox(label=\"Diagnosis\")\n", " patient_summary_box = gr.Textbox(label=\"Patient Summary\")\n", "\n", " def submit(name, age, symptoms):\n", " return {\n", " submit_btn: gr.Button(visible=False),\n", " output_col: gr.Column(visible=True),\n", " diagnosis_box: \"covid\" if \"Cough\" in symptoms else \"flu\",\n", " patient_summary_box: f\"{name}, {age} y/o\",\n", " }\n", "\n", " submit_btn.click(\n", " submit,\n", " [name_box, age_box, symptoms_box],\n", " [submit_btn, diagnosis_box, patient_summary_box, output_col],\n", " )\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
run.py CHANGED
@@ -1,8 +1,6 @@
1
  import gradio as gr
2
 
3
  with gr.Blocks() as demo:
4
- error_box = gr.Textbox(label="Error", visible=False)
5
-
6
  name_box = gr.Textbox(label="Name")
7
  age_box = gr.Number(label="Age", minimum=0, maximum=100)
8
  symptoms_box = gr.CheckboxGroup(["Cough", "Fever", "Runny Nose"])
@@ -13,9 +11,8 @@ with gr.Blocks() as demo:
13
  patient_summary_box = gr.Textbox(label="Patient Summary")
14
 
15
  def submit(name, age, symptoms):
16
- if len(name) == 0:
17
- return {error_box: gr.Textbox(value="Enter name", visible=True)}
18
  return {
 
19
  output_col: gr.Column(visible=True),
20
  diagnosis_box: "covid" if "Cough" in symptoms else "flu",
21
  patient_summary_box: f"{name}, {age} y/o",
@@ -24,7 +21,7 @@ with gr.Blocks() as demo:
24
  submit_btn.click(
25
  submit,
26
  [name_box, age_box, symptoms_box],
27
- [error_box, diagnosis_box, patient_summary_box, output_col],
28
  )
29
 
30
  if __name__ == "__main__":
 
1
  import gradio as gr
2
 
3
  with gr.Blocks() as demo:
 
 
4
  name_box = gr.Textbox(label="Name")
5
  age_box = gr.Number(label="Age", minimum=0, maximum=100)
6
  symptoms_box = gr.CheckboxGroup(["Cough", "Fever", "Runny Nose"])
 
11
  patient_summary_box = gr.Textbox(label="Patient Summary")
12
 
13
  def submit(name, age, symptoms):
 
 
14
  return {
15
+ submit_btn: gr.Button(visible=False),
16
  output_col: gr.Column(visible=True),
17
  diagnosis_box: "covid" if "Cough" in symptoms else "flu",
18
  patient_summary_box: f"{name}, {age} y/o",
 
21
  submit_btn.click(
22
  submit,
23
  [name_box, age_box, symptoms_box],
24
+ [submit_btn, diagnosis_box, patient_summary_box, output_col],
25
  )
26
 
27
  if __name__ == "__main__":