Loading other app
Browse files
app-bk.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from difflib import Differ
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
|
6 |
+
def diff_texts(text1, text2):
|
7 |
+
d = Differ()
|
8 |
+
return [
|
9 |
+
(token[2:], token[0] if token[0] != " " else None)
|
10 |
+
for token in d.compare(text1, text2)
|
11 |
+
]
|
12 |
+
|
13 |
+
|
14 |
+
demo = gr.Interface(
|
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 |
+
),
|
29 |
+
],
|
30 |
+
gr.HighlightedText(
|
31 |
+
label="Diff",
|
32 |
+
combine_adjacent=True,
|
33 |
+
show_legend=True,
|
34 |
+
color_map={"+": "red", "-": "green"}),
|
35 |
+
theme=gr.themes.Base()
|
36 |
+
)
|
37 |
+
if __name__ == "__main__":
|
38 |
+
demo.launch()
|
app.py
CHANGED
@@ -1,38 +1,5 @@
|
|
1 |
-
from difflib import Differ
|
2 |
-
|
3 |
import gradio as gr
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
return [
|
9 |
-
(token[2:], token[0] if token[0] != " " else None)
|
10 |
-
for token in d.compare(text1, text2)
|
11 |
-
]
|
12 |
-
|
13 |
-
|
14 |
-
demo = gr.Interface(
|
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 |
-
),
|
29 |
-
],
|
30 |
-
gr.HighlightedText(
|
31 |
-
label="Diff",
|
32 |
-
combine_adjacent=True,
|
33 |
-
show_legend=True,
|
34 |
-
color_map={"+": "red", "-": "green"}),
|
35 |
-
theme=gr.themes.Base()
|
36 |
-
)
|
37 |
-
if __name__ == "__main__":
|
38 |
-
demo.launch()
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
gr.Interface.load("huggingface/EleutherAI/gpt-j-6B",
|
4 |
+
inputs=gr.Textbox(lines=5, label="Input Text") # customizes the input component
|
5 |
+
).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|