Spaces:
Running
Running
Upload with huggingface_hub
Browse files
README.md
CHANGED
@@ -5,7 +5,7 @@ emoji: 🔥
|
|
5 |
colorFrom: indigo
|
6 |
colorTo: indigo
|
7 |
sdk: gradio
|
8 |
-
sdk_version: 3.19.
|
9 |
app_file: run.py
|
10 |
pinned: false
|
11 |
---
|
|
|
5 |
colorFrom: indigo
|
6 |
colorTo: indigo
|
7 |
sdk: gradio
|
8 |
+
sdk_version: 3.19.1
|
9 |
app_file: run.py
|
10 |
pinned: false
|
11 |
---
|
requirements.txt
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
|
2 |
-
https://gradio-main-build.s3.amazonaws.com/
|
|
|
1 |
|
2 |
+
https://gradio-main-build.s3.amazonaws.com/ab25bcc96739202c552bc5eab7950528f79eb6b3/gradio-3.19.1-py3-none-any.whl
|
run.ipynb
CHANGED
@@ -1 +1 @@
|
|
1 |
-
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: diff_texts"]}, {"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": ["from difflib import Differ\n", "\n", "import gradio as gr\n", "\n", "\n", "def diff_texts(text1, text2):\n", " d = Differ()\n", " return [\n", " (token[2:], token[0] if token[0] != \" \" else None)\n", " for token in d.compare(text1, text2)\n", " ]\n", "\n", "\n", "demo = gr.Interface(\n", " diff_texts,\n", " [\n", " gr.Textbox(\n", " label=\"Initial text\",\n", " lines=3,\n", " value=\"The quick brown fox jumped over the lazy dogs.\",\n", " ),\n", " gr.Textbox(\n", " label=\"Text to compare\",\n", " lines=3,\n", " value=\"The fast brown fox jumps over lazy dogs.\",\n", " ),\n", " ],\n", " gr.HighlightedText(\n", " label=\"Diff\",\n", " combine_adjacent=True,\n", " ).style(color_map={\"+\": \"red\", \"-\": \"green\"}),\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: diff_texts"]}, {"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": ["from difflib import Differ\n", "\n", "import gradio as gr\n", "\n", "\n", "def diff_texts(text1, text2):\n", " d = Differ()\n", " return [\n", " (token[2:], token[0] if token[0] != \" \" else None)\n", " for token in d.compare(text1, text2)\n", " ]\n", "\n", "\n", "demo = gr.Interface(\n", " diff_texts,\n", " [\n", " gr.Textbox(\n", " label=\"Text 1\",\n", " info=\"Initial text\",\n", " lines=3,\n", " value=\"The quick brown fox jumped over the lazy dogs.\",\n", " ),\n", " gr.Textbox(\n", " label=\"Text 2\",\n", " info=\"Text to compare\",\n", " lines=3,\n", " value=\"The fast brown fox jumps over lazy dogs.\",\n", " ),\n", " ],\n", " gr.HighlightedText(\n", " label=\"Diff\",\n", " combine_adjacent=True,\n", " ).style(color_map={\"+\": \"red\", \"-\": \"green\"}),\n", ")\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
run.py
CHANGED
@@ -15,12 +15,14 @@ demo = gr.Interface(
|
|
15 |
diff_texts,
|
16 |
[
|
17 |
gr.Textbox(
|
18 |
-
label="
|
|
|
19 |
lines=3,
|
20 |
value="The quick brown fox jumped over the lazy dogs.",
|
21 |
),
|
22 |
gr.Textbox(
|
23 |
-
label="Text
|
|
|
24 |
lines=3,
|
25 |
value="The fast brown fox jumps over lazy dogs.",
|
26 |
),
|
|
|
15 |
diff_texts,
|
16 |
[
|
17 |
gr.Textbox(
|
18 |
+
label="Text 1",
|
19 |
+
info="Initial text",
|
20 |
lines=3,
|
21 |
value="The quick brown fox jumped over the lazy dogs.",
|
22 |
),
|
23 |
gr.Textbox(
|
24 |
+
label="Text 2",
|
25 |
+
info="Text to compare",
|
26 |
lines=3,
|
27 |
value="The fast brown fox jumps over lazy dogs.",
|
28 |
),
|