Spaces:
Paused
Paused
add example
Browse files
app.py
CHANGED
@@ -17,7 +17,7 @@ tokenizers = {
|
|
17 |
|
18 |
|
19 |
@spaces.GPU
|
20 |
-
def run_example(html_content, model_id):
|
21 |
print("Start Model Processing")
|
22 |
model = models[model_id]
|
23 |
tokenizer = tokenizers[model_id]
|
@@ -40,6 +40,23 @@ css = """
|
|
40 |
}
|
41 |
"""
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
with gr.Blocks(css=css) as demo:
|
44 |
gr.Markdown("""
|
45 |
# HTML-to-Markdown
|
@@ -47,13 +64,24 @@ with gr.Blocks(css=css) as demo:
|
|
47 |
""")
|
48 |
with gr.Row():
|
49 |
with gr.Column():
|
50 |
-
model_selector = gr.Dropdown(choices=list(models.keys()), label="Model", value="jinaai/reader-lm-
|
51 |
html_content = gr.Textbox(label="HTML")
|
52 |
submit_btn = gr.Button(value="Submit")
|
53 |
with gr.Column():
|
54 |
model_output_text = gr.Textbox(label="Reader LM Output")
|
55 |
markdownify_output = gr.Textbox(label="Markdownify Output")
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
submit_btn.click(run_example, [html_content, model_selector], [model_output_text, markdownify_output])
|
58 |
|
59 |
demo.launch(debug=True)
|
|
|
17 |
|
18 |
|
19 |
@spaces.GPU
|
20 |
+
def run_example(html_content, model_id="jinaai/reader-lm-1.5b"):
|
21 |
print("Start Model Processing")
|
22 |
model = models[model_id]
|
23 |
tokenizer = tokenizers[model_id]
|
|
|
40 |
}
|
41 |
"""
|
42 |
|
43 |
+
example_html = """
|
44 |
+
<div id="myDIV" class="header">
|
45 |
+
<h2>My To Do List</h2>
|
46 |
+
<input type="text" id="myInput" placeholder="Title...">
|
47 |
+
<span onclick="newElement()" class="addBtn">Add</span>
|
48 |
+
</div>
|
49 |
+
|
50 |
+
<ul id="myUL">
|
51 |
+
<li>Hit the gym</li>
|
52 |
+
<li class="checked">Pay bills</li>
|
53 |
+
<li>Meet George</li>
|
54 |
+
<li>Buy eggs</li>
|
55 |
+
<li>Read a book</li>
|
56 |
+
<li>Organize office</li>
|
57 |
+
</ul>
|
58 |
+
"""
|
59 |
+
|
60 |
with gr.Blocks(css=css) as demo:
|
61 |
gr.Markdown("""
|
62 |
# HTML-to-Markdown
|
|
|
64 |
""")
|
65 |
with gr.Row():
|
66 |
with gr.Column():
|
67 |
+
model_selector = gr.Dropdown(choices=list(models.keys()), label="Model", value="jinaai/reader-lm-1.5b")
|
68 |
html_content = gr.Textbox(label="HTML")
|
69 |
submit_btn = gr.Button(value="Submit")
|
70 |
with gr.Column():
|
71 |
model_output_text = gr.Textbox(label="Reader LM Output")
|
72 |
markdownify_output = gr.Textbox(label="Markdownify Output")
|
73 |
|
74 |
+
gr.Examples(
|
75 |
+
examples=[
|
76 |
+
[example_html],
|
77 |
+
],
|
78 |
+
inputs=[example_html],
|
79 |
+
outputs=[model_output_text, markdownify_output],
|
80 |
+
fn=run_example,
|
81 |
+
cache_examples=True,
|
82 |
+
label="Try examples"
|
83 |
+
)
|
84 |
+
|
85 |
submit_btn.click(run_example, [html_content, model_selector], [model_output_text, markdownify_output])
|
86 |
|
87 |
demo.launch(debug=True)
|