Spaces:
Runtime error
Runtime error
EliottZemour
commited on
Commit
·
f3bd71a
1
Parent(s):
7f4a2af
clean app repo
Browse files- __pycache__/arxiv_util.cpython-310.pyc +0 -0
- __pycache__/get_paperinfo_fromurls.cpython-310.pyc +0 -0
- a.html +0 -40
- app.py +2 -4
- arxiv-logo.png +0 -0
- arxiv-logo.svg +0 -1
- htmlgen.ipynb +0 -576
- icml.txt +0 -1
__pycache__/arxiv_util.cpython-310.pyc
DELETED
Binary file (1.53 kB)
|
|
__pycache__/get_paperinfo_fromurls.cpython-310.pyc
DELETED
Binary file (715 Bytes)
|
|
a.html
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
<head>
|
2 |
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
3 |
-
<link href="csscard.css" rel="stylesheet" type="text/css"/>
|
4 |
-
|
5 |
-
</head>
|
6 |
-
|
7 |
-
<body>
|
8 |
-
|
9 |
-
<div class="container">
|
10 |
-
<div class="square">
|
11 |
-
<div class="mask">
|
12 |
-
<div class="left">
|
13 |
-
<img src="https://static.arxiv.org/static/browse/0.3.4/images/arxiv-logo-one-color-white.svg" alt="arxiv logo">
|
14 |
-
</div>
|
15 |
-
<h2 class="right">[2208.13511]</h2>
|
16 |
-
</div>
|
17 |
-
<div class="h1">Galaxies with Fuzzy Dark Matter</div>
|
18 |
-
<ul id="links">
|
19 |
-
|
20 |
-
<li><div class="auth">Jae-Weon Lee</div></li>
|
21 |
-
|
22 |
-
</ul>
|
23 |
-
<p>This is a brief review on some properties of galaxies in the fuzzy dark
|
24 |
-
matter model, where dark matter is an ultra-light scalar particle with mass $m
|
25 |
-
= O(10^{-22})eV$. From quantum pressure, dark matter has a halo length scale
|
26 |
-
which can solve the small scale issues of the cold dark matter model, such as
|
27 |
-
the core-cusp problem, and explain many other observed mysteries of galaxies.</p>
|
28 |
-
|
29 |
-
<!-- <ul id="urllinks">
|
30 |
-
<li>
|
31 |
-
<a href="http://arxiv.org/pdf/2208.13511v1" target="_" class="button">Article</a>
|
32 |
-
</li>
|
33 |
-
<li>
|
34 |
-
<a href="http://arxiv.org/abs/2208.13511v1" target="_" class="button">Abstract</a>
|
35 |
-
</li>
|
36 |
-
</ul> -->
|
37 |
-
</div>
|
38 |
-
</div>
|
39 |
-
|
40 |
-
</body>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
CHANGED
@@ -51,8 +51,6 @@ CSS = """
|
|
51 |
color: white;
|
52 |
font-weight: bold;
|
53 |
font-size: 16px;
|
54 |
-
display: flex;
|
55 |
-
float: none;
|
56 |
}
|
57 |
|
58 |
#htel {
|
@@ -80,12 +78,12 @@ with demo:
|
|
80 |
with gr.Row():
|
81 |
text = gr.Textbox(
|
82 |
show_label=False,
|
83 |
-
placeholder="
|
84 |
lines=1,
|
85 |
max_lines=1,
|
86 |
elem_id="url-textbox",
|
87 |
)
|
88 |
-
button = gr.Button("Generate
|
89 |
with gr.Row():
|
90 |
card = gr.HTML(elem_id="htel")
|
91 |
|
|
|
51 |
color: white;
|
52 |
font-weight: bold;
|
53 |
font-size: 16px;
|
|
|
|
|
54 |
}
|
55 |
|
56 |
#htel {
|
|
|
78 |
with gr.Row():
|
79 |
text = gr.Textbox(
|
80 |
show_label=False,
|
81 |
+
placeholder="Paste arXiv link (abs of pdf)",
|
82 |
lines=1,
|
83 |
max_lines=1,
|
84 |
elem_id="url-textbox",
|
85 |
)
|
86 |
+
button = gr.Button("Generate", variant="primary")
|
87 |
with gr.Row():
|
88 |
card = gr.HTML(elem_id="htel")
|
89 |
|
arxiv-logo.png
DELETED
Binary file (5.37 kB)
|
|
arxiv-logo.svg
DELETED
htmlgen.ipynb
DELETED
@@ -1,576 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"cells": [
|
3 |
-
{
|
4 |
-
"cell_type": "code",
|
5 |
-
"execution_count": 1,
|
6 |
-
"metadata": {},
|
7 |
-
"outputs": [],
|
8 |
-
"source": [
|
9 |
-
"import os\n",
|
10 |
-
"from jinja2 import Environment, FileSystemLoader, select_autoescape\n",
|
11 |
-
"from get_paperinfo_fromurls import get_paperinfo_fromurls"
|
12 |
-
]
|
13 |
-
},
|
14 |
-
{
|
15 |
-
"cell_type": "code",
|
16 |
-
"execution_count": 2,
|
17 |
-
"metadata": {},
|
18 |
-
"outputs": [],
|
19 |
-
"source": [
|
20 |
-
"\n",
|
21 |
-
"class CARDS_TEMPLATE(object):\n",
|
22 |
-
" def __init__(self, path_to_template, template_filename):\n",
|
23 |
-
" self.path_to_template = path_to_template\n",
|
24 |
-
" self.template_filename = template_filename\n",
|
25 |
-
" self.template = self._get_template()\n",
|
26 |
-
" self.rendered_html = None\n",
|
27 |
-
"\n",
|
28 |
-
" def _get_template(self):\n",
|
29 |
-
" env = Environment(\n",
|
30 |
-
" autoescape=select_autoescape(\n",
|
31 |
-
" enabled_extensions=('html'),\n",
|
32 |
-
" default_for_string=True,\n",
|
33 |
-
" ),\n",
|
34 |
-
" loader=FileSystemLoader(self.path_to_template)\n",
|
35 |
-
" )\n",
|
36 |
-
" return env.get_template(self.template_filename)\n",
|
37 |
-
"\n",
|
38 |
-
" def render(self, paper_details_iterator):\n",
|
39 |
-
" self.rendered_html = self.template.render(paper_details=paper_details_iterator)\n",
|
40 |
-
"\n",
|
41 |
-
" def save_html(self, output_dir=None, output_htmlfile=None):\n",
|
42 |
-
" with open(os.path.join(output_dir, output_htmlfile), \"w\") as f:\n",
|
43 |
-
" f.write(self.rendered_html)\n"
|
44 |
-
]
|
45 |
-
},
|
46 |
-
{
|
47 |
-
"cell_type": "code",
|
48 |
-
"execution_count": null,
|
49 |
-
"metadata": {},
|
50 |
-
"outputs": [],
|
51 |
-
"source": [
|
52 |
-
"template_file = \"htmlcard.html\"\n",
|
53 |
-
"template_path = \"\"\n",
|
54 |
-
"card_template = CARDS_TEMPLATE(\n",
|
55 |
-
" path_to_template = template_path,\n",
|
56 |
-
" template_filename = template_file,\n",
|
57 |
-
" )\n",
|
58 |
-
"\n",
|
59 |
-
"def create_html_card(arxiv_link):\n",
|
60 |
-
" paper_details = get_paperinfo_fromurls(arxiv_link)\n",
|
61 |
-
" card_template.render(paper_details_iterator=paper_details)\n",
|
62 |
-
" return card_template.rendered_html"
|
63 |
-
]
|
64 |
-
},
|
65 |
-
{
|
66 |
-
"cell_type": "code",
|
67 |
-
"execution_count": 3,
|
68 |
-
"metadata": {},
|
69 |
-
"outputs": [],
|
70 |
-
"source": []
|
71 |
-
},
|
72 |
-
{
|
73 |
-
"cell_type": "code",
|
74 |
-
"execution_count": 4,
|
75 |
-
"metadata": {},
|
76 |
-
"outputs": [],
|
77 |
-
"source": [
|
78 |
-
"paper_details = get_paperinfo_fromurls(\"https://arxiv.org/abs/2208.13511\")"
|
79 |
-
]
|
80 |
-
},
|
81 |
-
{
|
82 |
-
"cell_type": "code",
|
83 |
-
"execution_count": 5,
|
84 |
-
"metadata": {},
|
85 |
-
"outputs": [
|
86 |
-
{
|
87 |
-
"data": {
|
88 |
-
"text/plain": [
|
89 |
-
"{'https://arxiv.org/abs/2208.13511': ArxivPaper(title='Galaxies with Fuzzy Dark Matter', authors=[{'name': 'Jae-Weon Lee'}], abstract='This is a brief review on some properties of galaxies in the fuzzy dark\\nmatter model, where dark matter is an ultra-light scalar particle with mass $m\\n= O(10^{-22})eV$. From quantum pressure, dark matter has a halo length scale\\nwhich can solve the small scale issues of the cold dark matter model, such as\\nthe core-cusp problem, and explain many other observed mysteries of galaxies.', linktopdf='http://arxiv.org/pdf/2208.13511v1', linktoabs='http://arxiv.org/abs/2208.13511v1', arxiv_id='2208.13511')}"
|
90 |
-
]
|
91 |
-
},
|
92 |
-
"execution_count": 5,
|
93 |
-
"metadata": {},
|
94 |
-
"output_type": "execute_result"
|
95 |
-
}
|
96 |
-
],
|
97 |
-
"source": [
|
98 |
-
"paper_details"
|
99 |
-
]
|
100 |
-
},
|
101 |
-
{
|
102 |
-
"cell_type": "code",
|
103 |
-
"execution_count": 6,
|
104 |
-
"metadata": {},
|
105 |
-
"outputs": [],
|
106 |
-
"source": [
|
107 |
-
"card_template.render(paper_details_iterator=paper_details)"
|
108 |
-
]
|
109 |
-
},
|
110 |
-
{
|
111 |
-
"cell_type": "code",
|
112 |
-
"execution_count": 8,
|
113 |
-
"metadata": {},
|
114 |
-
"outputs": [],
|
115 |
-
"source": [
|
116 |
-
"card_template.save_html(output_dir = template_path, output_htmlfile = \"a.html\")"
|
117 |
-
]
|
118 |
-
},
|
119 |
-
{
|
120 |
-
"cell_type": "code",
|
121 |
-
"execution_count": 7,
|
122 |
-
"metadata": {},
|
123 |
-
"outputs": [
|
124 |
-
{
|
125 |
-
"data": {
|
126 |
-
"text/plain": [
|
127 |
-
"' <head>\\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\\n <link href=\"csscard.css\" rel=\"stylesheet\" type=\"text/css\"/>\\n\\n </head>\\n\\n <body>\\n \\n <div class=\"container\">\\n <div class=\"square\">\\n <div class=\"mask\">\\n <div class=\"left\">\\n <img src=\"https://static.arxiv.org/static/browse/0.3.4/images/arxiv-logo-one-color-white.svg\" alt=\"arxiv logo\">\\n </div>\\n <h2 class=\"right\">[2208.13511]</h2>\\n </div>\\n <div class=\"h1\">Galaxies with Fuzzy Dark Matter</div>\\n <ul id=\"links\">\\n \\n <li><div class=\"auth\">Jae-Weon Lee</div></li>\\n \\n </ul>\\n <p>This is a brief review on some properties of galaxies in the fuzzy dark\\nmatter model, where dark matter is an ultra-light scalar particle with mass $m\\n= O(10^{-22})eV$. From quantum pressure, dark matter has a halo length scale\\nwhich can solve the small scale issues of the cold dark matter model, such as\\nthe core-cusp problem, and explain many other observed mysteries of galaxies.</p>\\n\\n <!-- <ul id=\"urllinks\">\\n <li>\\n <a href=\"http://arxiv.org/pdf/2208.13511v1\" target=\"_\" class=\"button\">Article</a>\\n </li>\\n <li>\\n <a href=\"http://arxiv.org/abs/2208.13511v1\" target=\"_\" class=\"button\">Abstract</a>\\n </li>\\n </ul> -->\\n </div>\\n </div>\\n \\n </body>'"
|
128 |
-
]
|
129 |
-
},
|
130 |
-
"execution_count": 7,
|
131 |
-
"metadata": {},
|
132 |
-
"output_type": "execute_result"
|
133 |
-
}
|
134 |
-
],
|
135 |
-
"source": [
|
136 |
-
"card_template.rendered_html"
|
137 |
-
]
|
138 |
-
},
|
139 |
-
{
|
140 |
-
"cell_type": "code",
|
141 |
-
"execution_count": 9,
|
142 |
-
"metadata": {},
|
143 |
-
"outputs": [
|
144 |
-
{
|
145 |
-
"name": "stdout",
|
146 |
-
"output_type": "stream",
|
147 |
-
"text": [
|
148 |
-
" <head>\n",
|
149 |
-
" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n",
|
150 |
-
" <link href=\"csscard.css\" rel=\"stylesheet\" type=\"text/css\"/>\n",
|
151 |
-
"\n",
|
152 |
-
" </head>\n",
|
153 |
-
"\n",
|
154 |
-
" <body>\n",
|
155 |
-
" \n",
|
156 |
-
" <div class=\"container\">\n",
|
157 |
-
" <div class=\"square\">\n",
|
158 |
-
" <div class=\"mask\">\n",
|
159 |
-
" <div class=\"left\">\n",
|
160 |
-
" <img src=\"https://static.arxiv.org/static/browse/0.3.4/images/arxiv-logo-one-color-white.svg\" alt=\"arxiv logo\">\n",
|
161 |
-
" </div>\n",
|
162 |
-
" <h2 class=\"right\">[2208.13511]</h2>\n",
|
163 |
-
" </div>\n",
|
164 |
-
" <div class=\"h1\">Galaxies with Fuzzy Dark Matter</div>\n",
|
165 |
-
" <ul id=\"links\">\n",
|
166 |
-
" \n",
|
167 |
-
" <li><div class=\"auth\">Jae-Weon Lee</div></li>\n",
|
168 |
-
" \n",
|
169 |
-
" </ul>\n",
|
170 |
-
" <p>This is a brief review on some properties of galaxies in the fuzzy dark\n",
|
171 |
-
"matter model, where dark matter is an ultra-light scalar particle with mass $m\n",
|
172 |
-
"= O(10^{-22})eV$. From quantum pressure, dark matter has a halo length scale\n",
|
173 |
-
"which can solve the small scale issues of the cold dark matter model, such as\n",
|
174 |
-
"the core-cusp problem, and explain many other observed mysteries of galaxies.</p>\n",
|
175 |
-
"\n",
|
176 |
-
" <!-- <ul id=\"urllinks\">\n",
|
177 |
-
" <li>\n",
|
178 |
-
" <a href=\"http://arxiv.org/pdf/2208.13511v1\" target=\"_\" class=\"button\">Article</a>\n",
|
179 |
-
" </li>\n",
|
180 |
-
" <li>\n",
|
181 |
-
" <a href=\"http://arxiv.org/abs/2208.13511v1\" target=\"_\" class=\"button\">Abstract</a>\n",
|
182 |
-
" </li>\n",
|
183 |
-
" </ul> -->\n",
|
184 |
-
" </div>\n",
|
185 |
-
" </div>\n",
|
186 |
-
" \n",
|
187 |
-
" </body>\n"
|
188 |
-
]
|
189 |
-
}
|
190 |
-
],
|
191 |
-
"source": [
|
192 |
-
"print(card_template.rendered_html)"
|
193 |
-
]
|
194 |
-
},
|
195 |
-
{
|
196 |
-
"cell_type": "code",
|
197 |
-
"execution_count": 34,
|
198 |
-
"metadata": {},
|
199 |
-
"outputs": [],
|
200 |
-
"source": [
|
201 |
-
"html = \"\"\"<head>\n",
|
202 |
-
" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n",
|
203 |
-
" \n",
|
204 |
-
" <style>\n",
|
205 |
-
" @import url(\"https://fonts.googleapis.com/css?family=Merriweather|Open+Sans\");\n",
|
206 |
-
"\n",
|
207 |
-
".container {\n",
|
208 |
-
" display: flex;\n",
|
209 |
-
" justify-content: center;\n",
|
210 |
-
" padding: 80px;\n",
|
211 |
-
"}\n",
|
212 |
-
"\n",
|
213 |
-
"ul {\n",
|
214 |
-
" list-style-type: none;\n",
|
215 |
-
" display: flex;\n",
|
216 |
-
" float: none;\n",
|
217 |
-
" justify-content: center;\n",
|
218 |
-
" align-items: center;\n",
|
219 |
-
"}\n",
|
220 |
-
"\n",
|
221 |
-
"#urllinks li {\n",
|
222 |
-
" padding: 0px 30px 5px 5px;\n",
|
223 |
-
"}\n",
|
224 |
-
"\n",
|
225 |
-
".square {\n",
|
226 |
-
" width: 700px;\n",
|
227 |
-
" background: white;\n",
|
228 |
-
" border-radius: 4px;\n",
|
229 |
-
" box-shadow: 0px 20px 50px #d9dbdf;\n",
|
230 |
-
"}\n",
|
231 |
-
"\n",
|
232 |
-
".mask {\n",
|
233 |
-
" width: 700px;\n",
|
234 |
-
" height: 65px;\n",
|
235 |
-
" clip: rect(0px, 700px, 150px, 0px);\n",
|
236 |
-
" border-radius: 4px;\n",
|
237 |
-
" position: absolute;\n",
|
238 |
-
" background-color: #b31b1b;\n",
|
239 |
-
" display: flex;\n",
|
240 |
-
"}\n",
|
241 |
-
"\n",
|
242 |
-
".mask .left,\n",
|
243 |
-
".mask .right {\n",
|
244 |
-
" flex: 1;\n",
|
245 |
-
"}\n",
|
246 |
-
"\n",
|
247 |
-
"img {\n",
|
248 |
-
" position: absolute;\n",
|
249 |
-
" width: 60px;\n",
|
250 |
-
" padding: 20px 30px;\n",
|
251 |
-
"}\n",
|
252 |
-
"\n",
|
253 |
-
".h1 {\n",
|
254 |
-
" margin: auto;\n",
|
255 |
-
" text-align: left;\n",
|
256 |
-
" margin-top: 90px;\n",
|
257 |
-
" padding-left: 30px;\n",
|
258 |
-
" font-family: \"Merriweather\", serif;\n",
|
259 |
-
" font-size: 22px;\n",
|
260 |
-
"}\n",
|
261 |
-
"\n",
|
262 |
-
"h2 {\n",
|
263 |
-
" color: white;\n",
|
264 |
-
" text-align: center;\n",
|
265 |
-
" font-size: 14px;\n",
|
266 |
-
" padding: 10px 0px;\n",
|
267 |
-
" font-family: \"Open Sans\", sans-serif;\n",
|
268 |
-
" font-weight: 400;\n",
|
269 |
-
"}\n",
|
270 |
-
"\n",
|
271 |
-
"p {\n",
|
272 |
-
" text-align: justify;\n",
|
273 |
-
" padding-left: 30px;\n",
|
274 |
-
" padding-right: 30px;\n",
|
275 |
-
" font-family: \"Open Sans\", sans-serif;\n",
|
276 |
-
" font-size: 12px;\n",
|
277 |
-
" color: #949494;\n",
|
278 |
-
" line-height: 18px;\n",
|
279 |
-
"}\n",
|
280 |
-
"\n",
|
281 |
-
".auth {\n",
|
282 |
-
" text-align: justify;\n",
|
283 |
-
" padding-left: 0px;\n",
|
284 |
-
" padding-right: 20px;\n",
|
285 |
-
" font-family: \"Open Sans\", sans-serif;\n",
|
286 |
-
" font-size: 14px;\n",
|
287 |
-
" line-height: 18px;\n",
|
288 |
-
"}\n",
|
289 |
-
"\n",
|
290 |
-
".button {\n",
|
291 |
-
" background-color: #b31b1b;\n",
|
292 |
-
" color: white;\n",
|
293 |
-
" width: 150px;\n",
|
294 |
-
" padding: 10px 10px;\n",
|
295 |
-
" border-radius: 3px;\n",
|
296 |
-
" text-align: center;\n",
|
297 |
-
" text-decoration: none;\n",
|
298 |
-
" display: block;\n",
|
299 |
-
" margin-top: 20px;\n",
|
300 |
-
" margin-left: 20px;\n",
|
301 |
-
" margin-right: 20px;\n",
|
302 |
-
" font-size: 12px;\n",
|
303 |
-
" cursor: pointer;\n",
|
304 |
-
" font-family: \"merriweather\";\n",
|
305 |
-
"}\n",
|
306 |
-
"\n",
|
307 |
-
" </style>\n",
|
308 |
-
"\n",
|
309 |
-
"\n",
|
310 |
-
" </head>\n",
|
311 |
-
"\n",
|
312 |
-
" <body>\n",
|
313 |
-
" \n",
|
314 |
-
" <div class=\"container\">\n",
|
315 |
-
" <div class=\"square\">\n",
|
316 |
-
" <div class=\"mask\">\n",
|
317 |
-
" <h2 class=\"left\">\n",
|
318 |
-
" <img src=\"https://static.arxiv.org/static/browse/0.3.4/images/arxiv-logo-one-color-white.svg\" alt=\"arxiv logo\">\n",
|
319 |
-
" </h2>\n",
|
320 |
-
" <h2 class=\"right\">http://arxiv.org/abs/2208.14178v1</h2>\n",
|
321 |
-
" </div>\n",
|
322 |
-
" <div class=\"h1\">Observational Signatures of Galactic Turbulent Dynamos</div>\n",
|
323 |
-
" <ul id=\"links\">\n",
|
324 |
-
" \n",
|
325 |
-
" <li><div class=\"auth\">Yann Carteret</div></li>\n",
|
326 |
-
" \n",
|
327 |
-
" <li><div class=\"auth\">Abhijit B. Bendre</div></li>\n",
|
328 |
-
" \n",
|
329 |
-
" <li><div class=\"auth\">Jennifer Schober</div></li>\n",
|
330 |
-
" \n",
|
331 |
-
" </ul>\n",
|
332 |
-
" <p>We analyse the observational signatures of galactic magnetic fields that are\n",
|
333 |
-
"self-consistently generated in magnetohydrodynamic simulations of the\n",
|
334 |
-
"interstellar medium through turbulence driven by supernova (SN) explosions and\n",
|
335 |
-
"differential rotation. In particular, we study the time evolution of the\n",
|
336 |
-
"Faraday rotation measure (RM), synchrotron radiation, and Stokes parameters by\n",
|
337 |
-
"characterising the typical structures formed in the plane of observation. We do\n",
|
338 |
-
"this by defining two distinct models for both thermal and cosmic ray (CR)\n",
|
339 |
-
"electron distributions. Our results indicate that the maps of RM have\n",
|
340 |
-
"structures which are sheared and rendered anisotropically by differential\n",
|
341 |
-
"rotation and that they depend on the choice of thermal electrons model as well\n",
|
342 |
-
"as the SN rate. Synchrotron maps are qualitatively similar to the maps of the\n",
|
343 |
-
"mean magnetic field along the line of sight and structures are only marginally\n",
|
344 |
-
"affected by the CR model. Stokes parameters and related quantities, such as the\n",
|
345 |
-
"degree of linear polarisation, are highly dependent on both frequency and\n",
|
346 |
-
"resolution of the observation.</p>\n",
|
347 |
-
"\n",
|
348 |
-
" <!-- <ul id=\"urllinks\">\n",
|
349 |
-
" <li>\n",
|
350 |
-
" <a href=\"http://arxiv.org/pdf/2208.14178v1\" target=\"_\" class=\"button\">Article</a>\n",
|
351 |
-
" </li>\n",
|
352 |
-
" <li>\n",
|
353 |
-
" <a href=\"http://arxiv.org/abs/2208.14178v1\" target=\"_\" class=\"button\">Abstract</a>\n",
|
354 |
-
" </li>\n",
|
355 |
-
" </ul> -->\n",
|
356 |
-
" </div>\n",
|
357 |
-
" </div>\n",
|
358 |
-
" \n",
|
359 |
-
" </body>\"\"\""
|
360 |
-
]
|
361 |
-
},
|
362 |
-
{
|
363 |
-
"cell_type": "code",
|
364 |
-
"execution_count": 35,
|
365 |
-
"metadata": {},
|
366 |
-
"outputs": [],
|
367 |
-
"source": [
|
368 |
-
"import gradio as gr\n",
|
369 |
-
"\n",
|
370 |
-
"def text_analysis(text):\n",
|
371 |
-
" return html\n",
|
372 |
-
"\n",
|
373 |
-
"\n",
|
374 |
-
"# demo = gr.Interface(\n",
|
375 |
-
"# text_analysis,\n",
|
376 |
-
"# gr.Textbox(placeholder=\"Enter sentence here...\"),\n",
|
377 |
-
"# gr.HTML(),\n",
|
378 |
-
"# examples=[\n",
|
379 |
-
"# [\"What a beautiful morning for a walk!\"],\n",
|
380 |
-
"# [\"It was the best of times, it was the worst of times.\"],\n",
|
381 |
-
"# ],\n",
|
382 |
-
"# )\n"
|
383 |
-
]
|
384 |
-
},
|
385 |
-
{
|
386 |
-
"cell_type": "code",
|
387 |
-
"execution_count": 32,
|
388 |
-
"metadata": {},
|
389 |
-
"outputs": [],
|
390 |
-
"source": [
|
391 |
-
"CSS = \"\"\"\n",
|
392 |
-
"#url-textbox {\n",
|
393 |
-
" padding: 0 !important;\n",
|
394 |
-
"}\n",
|
395 |
-
"#short-upload-box .w-full {\n",
|
396 |
-
" min-height: 10rem !important;\n",
|
397 |
-
"}\n",
|
398 |
-
"\n",
|
399 |
-
".gradio-container .gr-button-primary {\n",
|
400 |
-
" background: #b31b1b;\n",
|
401 |
-
" border: 1px solid #b31b1b;\n",
|
402 |
-
" border-radius: 8px;\n",
|
403 |
-
" color: white;\n",
|
404 |
-
" font-weight: bold;\n",
|
405 |
-
"}\n",
|
406 |
-
".gradio-container.dark button#submit-button {\n",
|
407 |
-
" background: linear-gradient(180deg, #CDF9BE 0%, #AFF497 100%);\n",
|
408 |
-
" border: 1px solid #B0DCCC;\n",
|
409 |
-
" border-radius: 8px;\n",
|
410 |
-
" color: #b31b1b\n",
|
411 |
-
"}\n",
|
412 |
-
"table.gr-samples-table tr td {\n",
|
413 |
-
" border: none;\n",
|
414 |
-
" outline: none;\n",
|
415 |
-
"}\n",
|
416 |
-
"table.gr-samples-table tr td:first-of-type {\n",
|
417 |
-
" width: 0%;\n",
|
418 |
-
"}\n",
|
419 |
-
"div#short-upload-box div.absolute {\n",
|
420 |
-
" display: none !important;\n",
|
421 |
-
"}\n",
|
422 |
-
"gradio-app > div > div > div > div.w-full > div, .gradio-app > div > div > div > div.w-full > div {\n",
|
423 |
-
" gap: 0px 2%;\n",
|
424 |
-
"}\n",
|
425 |
-
"gradio-app div div div div.w-full, .gradio-app div div div div.w-full {\n",
|
426 |
-
" gap: 0px;\n",
|
427 |
-
"}\n",
|
428 |
-
"\n",
|
429 |
-
"#htel {\n",
|
430 |
-
" justify-content: center;\n",
|
431 |
-
"}\n",
|
432 |
-
"\n",
|
433 |
-
"#answer {\n",
|
434 |
-
" overflow-y: scroll;\n",
|
435 |
-
" color: white;\n",
|
436 |
-
" background: #666;\n",
|
437 |
-
" border-color: #666;\n",
|
438 |
-
" font-size: 20px;\n",
|
439 |
-
" font-weight: bold;\n",
|
440 |
-
"}\n",
|
441 |
-
"#answer span {\n",
|
442 |
-
" color: white;\n",
|
443 |
-
"}\n",
|
444 |
-
"#answer textarea {\n",
|
445 |
-
" color:white;\n",
|
446 |
-
" background: #777;\n",
|
447 |
-
" border-color: #777;\n",
|
448 |
-
" font-size: 18px;\n",
|
449 |
-
"}\n",
|
450 |
-
"#url-error input {\n",
|
451 |
-
" color: red;\n",
|
452 |
-
"}\n",
|
453 |
-
"\"\"\""
|
454 |
-
]
|
455 |
-
},
|
456 |
-
{
|
457 |
-
"cell_type": "code",
|
458 |
-
"execution_count": 33,
|
459 |
-
"metadata": {},
|
460 |
-
"outputs": [
|
461 |
-
{
|
462 |
-
"name": "stdout",
|
463 |
-
"output_type": "stream",
|
464 |
-
"text": [
|
465 |
-
"Running on local URL: http://127.0.0.1:7874/\n",
|
466 |
-
"\n",
|
467 |
-
"To create a public link, set `share=True` in `launch()`.\n"
|
468 |
-
]
|
469 |
-
},
|
470 |
-
{
|
471 |
-
"data": {
|
472 |
-
"text/html": [
|
473 |
-
"<div><iframe src=\"http://127.0.0.1:7874/\" width=\"900\" height=\"500\" allow=\"autoplay; camera; microphone;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
474 |
-
],
|
475 |
-
"text/plain": [
|
476 |
-
"<IPython.core.display.HTML object>"
|
477 |
-
]
|
478 |
-
},
|
479 |
-
"metadata": {},
|
480 |
-
"output_type": "display_data"
|
481 |
-
},
|
482 |
-
{
|
483 |
-
"data": {
|
484 |
-
"text/plain": [
|
485 |
-
"(<gradio.routes.App at 0x157e48fa0>, 'http://127.0.0.1:7874/', None)"
|
486 |
-
]
|
487 |
-
},
|
488 |
-
"execution_count": 33,
|
489 |
-
"metadata": {},
|
490 |
-
"output_type": "execute_result"
|
491 |
-
},
|
492 |
-
{
|
493 |
-
"name": "stderr",
|
494 |
-
"output_type": "stream",
|
495 |
-
"text": [
|
496 |
-
"Traceback (most recent call last):\n",
|
497 |
-
" File \"/Users/eliott/Desktop/arxiv-cards/venv/lib/python3.10/site-packages/gradio/routes.py\", line 259, in run_predict\n",
|
498 |
-
" output = await app.blocks.process_api(\n",
|
499 |
-
" File \"/Users/eliott/Desktop/arxiv-cards/venv/lib/python3.10/site-packages/gradio/blocks.py\", line 687, in process_api\n",
|
500 |
-
" predictions, duration = await self.call_function(fn_index, inputs)\n",
|
501 |
-
" File \"/Users/eliott/Desktop/arxiv-cards/venv/lib/python3.10/site-packages/gradio/blocks.py\", line 604, in call_function\n",
|
502 |
-
" prediction = await anyio.to_thread.run_sync(\n",
|
503 |
-
" File \"/Users/eliott/Desktop/arxiv-cards/venv/lib/python3.10/site-packages/anyio/to_thread.py\", line 31, in run_sync\n",
|
504 |
-
" return await get_asynclib().run_sync_in_worker_thread(\n",
|
505 |
-
" File \"/Users/eliott/Desktop/arxiv-cards/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py\", line 937, in run_sync_in_worker_thread\n",
|
506 |
-
" return await future\n",
|
507 |
-
" File \"/Users/eliott/Desktop/arxiv-cards/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py\", line 867, in run\n",
|
508 |
-
" result = context.run(func, *args)\n",
|
509 |
-
" File \"/var/folders/7k/c2q_b15953b9d0vfdn2h_mv00000gn/T/ipykernel_31384/2614688053.py\", line 4, in text_analysis\n",
|
510 |
-
" return html\n",
|
511 |
-
"NameError: name 'html' is not defined\n"
|
512 |
-
]
|
513 |
-
}
|
514 |
-
],
|
515 |
-
"source": [
|
516 |
-
"demo = gr.Blocks(css=CSS)\n",
|
517 |
-
"with demo:\n",
|
518 |
-
" with gr.Row(equal_height=True):\n",
|
519 |
-
" with gr.Column():\n",
|
520 |
-
" with gr.Row():\n",
|
521 |
-
" text = gr.Textbox(\n",
|
522 |
-
" show_label=False,\n",
|
523 |
-
" placeholder=\"URL\",\n",
|
524 |
-
" lines=1,\n",
|
525 |
-
" max_lines=1,\n",
|
526 |
-
" elem_id=\"url-textbox\",\n",
|
527 |
-
" )\n",
|
528 |
-
" button = gr.Button(\"Get\", variant=\"primary\")\n",
|
529 |
-
" with gr.Row():\n",
|
530 |
-
" card = gr.HTML(elem_id=\"htel\")\n",
|
531 |
-
"\n",
|
532 |
-
" button.click(\n",
|
533 |
-
" fn=text_analysis,\n",
|
534 |
-
" inputs=[text],\n",
|
535 |
-
" outputs=[card]\n",
|
536 |
-
" )\n",
|
537 |
-
"\n",
|
538 |
-
"demo.launch()"
|
539 |
-
]
|
540 |
-
},
|
541 |
-
{
|
542 |
-
"cell_type": "code",
|
543 |
-
"execution_count": null,
|
544 |
-
"metadata": {},
|
545 |
-
"outputs": [],
|
546 |
-
"source": []
|
547 |
-
}
|
548 |
-
],
|
549 |
-
"metadata": {
|
550 |
-
"kernelspec": {
|
551 |
-
"display_name": "Python 3.10.6 ('venv': venv)",
|
552 |
-
"language": "python",
|
553 |
-
"name": "python3"
|
554 |
-
},
|
555 |
-
"language_info": {
|
556 |
-
"codemirror_mode": {
|
557 |
-
"name": "ipython",
|
558 |
-
"version": 3
|
559 |
-
},
|
560 |
-
"file_extension": ".py",
|
561 |
-
"mimetype": "text/x-python",
|
562 |
-
"name": "python",
|
563 |
-
"nbconvert_exporter": "python",
|
564 |
-
"pygments_lexer": "ipython3",
|
565 |
-
"version": "3.10.6"
|
566 |
-
},
|
567 |
-
"orig_nbformat": 4,
|
568 |
-
"vscode": {
|
569 |
-
"interpreter": {
|
570 |
-
"hash": "ae98d664624800dd4d9fc88411f6d5cdeab1df903964a5ddc213cbd271aad7df"
|
571 |
-
}
|
572 |
-
}
|
573 |
-
},
|
574 |
-
"nbformat": 4,
|
575 |
-
"nbformat_minor": 2
|
576 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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