EliottZemour commited on
Commit
4c1af0e
·
1 Parent(s): 7c48605

update app

Browse files
Files changed (2) hide show
  1. app.py +96 -5
  2. htmlgen.ipynb +86 -25
app.py CHANGED
@@ -34,17 +34,108 @@ card_template = CARDS_TEMPLATE(
34
  template_filename = template_file,
35
  )
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  def create_html_card(arxiv_link):
38
  paper_details = get_paperinfo_fromurls(arxiv_link)
39
  card_template.render(paper_details_iterator=paper_details)
40
  return card_template.rendered_html
41
 
42
- demo = gr.Blocks()
43
  with demo:
44
- with gr.Row():
45
- text = gr.inputs.Textbox()
46
- with gr.Row():
47
- button = gr.Button("Generate card !")
 
 
 
 
 
 
 
48
  with gr.Row():
49
  card = gr.HTML()
50
 
 
34
  template_filename = template_file,
35
  )
36
 
37
+ CSS = """
38
+ #question input {
39
+ font-size: 16px;
40
+ }
41
+ #url-textbox {
42
+ padding: 0 !important;
43
+ }
44
+ #short-upload-box .w-full {
45
+ min-height: 10rem !important;
46
+ }
47
+ /* I think something like this can be used to re-shape
48
+ * the table
49
+ */
50
+ /*
51
+ .gr-samples-table tr {
52
+ display: inline;
53
+ }
54
+ .gr-samples-table .p-2 {
55
+ width: 100px;
56
+ }
57
+ */
58
+ #select-a-file {
59
+ width: 100%;
60
+ }
61
+ #file-clear {
62
+ padding-top: 2px !important;
63
+ padding-bottom: 2px !important;
64
+ padding-left: 8px !important;
65
+ padding-right: 8px !important;
66
+ margin-top: 10px;
67
+ }
68
+ .gradio-container .gr-button-primary {
69
+ background: linear-gradient(180deg, #CDF9BE 0%, #AFF497 100%);
70
+ border: 1px solid #B0DCCC;
71
+ border-radius: 8px;
72
+ color: #1B8700;
73
+ }
74
+ .gradio-container.dark button#submit-button {
75
+ background: linear-gradient(180deg, #CDF9BE 0%, #AFF497 100%);
76
+ border: 1px solid #B0DCCC;
77
+ border-radius: 8px;
78
+ color: #1B8700
79
+ }
80
+ table.gr-samples-table tr td {
81
+ border: none;
82
+ outline: none;
83
+ }
84
+ table.gr-samples-table tr td:first-of-type {
85
+ width: 0%;
86
+ }
87
+ div#short-upload-box div.absolute {
88
+ display: none !important;
89
+ }
90
+ gradio-app > div > div > div > div.w-full > div, .gradio-app > div > div > div > div.w-full > div {
91
+ gap: 0px 2%;
92
+ }
93
+ gradio-app div div div div.w-full, .gradio-app div div div div.w-full {
94
+ gap: 0px;
95
+ }
96
+ gradio-app h2, .gradio-app h2 {
97
+ padding-top: 10px;
98
+ }
99
+ #answer {
100
+ overflow-y: scroll;
101
+ color: white;
102
+ background: #666;
103
+ border-color: #666;
104
+ font-size: 20px;
105
+ font-weight: bold;
106
+ }
107
+ #answer span {
108
+ color: white;
109
+ }
110
+ #answer textarea {
111
+ color:white;
112
+ background: #777;
113
+ border-color: #777;
114
+ font-size: 18px;
115
+ }
116
+ #url-error input {
117
+ color: red;
118
+ }
119
+ """
120
+
121
  def create_html_card(arxiv_link):
122
  paper_details = get_paperinfo_fromurls(arxiv_link)
123
  card_template.render(paper_details_iterator=paper_details)
124
  return card_template.rendered_html
125
 
126
+ demo = gr.Blocks(css=CSS)
127
  with demo:
128
+ with gr.Row(equal_height=True):
129
+ with gr.Column():
130
+ with gr.Row():
131
+ text = gr.Textbox(
132
+ show_label=False,
133
+ placeholder="URL",
134
+ lines=1,
135
+ max_lines=1,
136
+ elem_id="url-textbox",
137
+ )
138
+ button = gr.Button("Get", variant="primary")
139
  with gr.Row():
140
  card = gr.HTML()
141
 
htmlgen.ipynb CHANGED
@@ -361,7 +361,7 @@
361
  },
362
  {
363
  "cell_type": "code",
364
- "execution_count": 95,
365
  "metadata": {},
366
  "outputs": [],
367
  "source": [
@@ -384,28 +384,82 @@
384
  },
385
  {
386
  "cell_type": "code",
387
- "execution_count": 96,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
388
  "metadata": {},
389
  "outputs": [
390
- {
391
- "name": "stderr",
392
- "output_type": "stream",
393
- "text": [
394
- "/Users/eliott/Desktop/arxiv-cards/venv/lib/python3.10/site-packages/gradio/inputs.py:26: UserWarning: Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your component from gradio.components\n",
395
- " warnings.warn(\n",
396
- "/Users/eliott/Desktop/arxiv-cards/venv/lib/python3.10/site-packages/gradio/deprecation.py:40: UserWarning: `optional` parameter is deprecated, and it has no effect\n",
397
- " warnings.warn(value)\n",
398
- "/Users/eliott/Desktop/arxiv-cards/venv/lib/python3.10/site-packages/gradio/deprecation.py:40: UserWarning: `numeric` parameter is deprecated, and it has no effect\n",
399
- " warnings.warn(value)\n",
400
- "/Users/eliott/Desktop/arxiv-cards/venv/lib/python3.10/site-packages/gradio/deprecation.py:40: UserWarning: The 'type' parameter has been deprecated. Use the Number component instead.\n",
401
- " warnings.warn(value)\n"
402
- ]
403
- },
404
  {
405
  "name": "stdout",
406
  "output_type": "stream",
407
  "text": [
408
- "Running on local URL: http://127.0.0.1:7866/\n",
409
  "\n",
410
  "To create a public link, set `share=True` in `launch()`.\n"
411
  ]
@@ -413,7 +467,7 @@
413
  {
414
  "data": {
415
  "text/html": [
416
- "<div><iframe src=\"http://127.0.0.1:7866/\" width=\"900\" height=\"500\" allow=\"autoplay; camera; microphone;\" frameborder=\"0\" allowfullscreen></iframe></div>"
417
  ],
418
  "text/plain": [
419
  "<IPython.core.display.HTML object>"
@@ -425,21 +479,28 @@
425
  {
426
  "data": {
427
  "text/plain": [
428
- "(<gradio.routes.App at 0x133347cd0>, 'http://127.0.0.1:7866/', None)"
429
  ]
430
  },
431
- "execution_count": 96,
432
  "metadata": {},
433
  "output_type": "execute_result"
434
  }
435
  ],
436
  "source": [
437
- "demo = gr.Blocks()\n",
438
  "with demo:\n",
439
- " with gr.Row():\n",
440
- " text = gr.inputs.Textbox()\n",
441
- " with gr.Row():\n",
442
- " button = gr.Button(\"Generate reviews !\")\n",
 
 
 
 
 
 
 
443
  " with gr.Row():\n",
444
  " card = gr.HTML()\n",
445
  "\n",
 
361
  },
362
  {
363
  "cell_type": "code",
364
+ "execution_count": 11,
365
  "metadata": {},
366
  "outputs": [],
367
  "source": [
 
384
  },
385
  {
386
  "cell_type": "code",
387
+ "execution_count": 21,
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: linear-gradient(180deg, #CDF9BE 0%, #AFF497 100%);\n",
401
+ " border: 1px solid #B0DCCC;\n",
402
+ " border-radius: 8px;\n",
403
+ " color: #1B8700;\n",
404
+ "}\n",
405
+ ".gradio-container.dark button#submit-button {\n",
406
+ " background: linear-gradient(180deg, #CDF9BE 0%, #AFF497 100%);\n",
407
+ " border: 1px solid #B0DCCC;\n",
408
+ " border-radius: 8px;\n",
409
+ " color: #1B8700\n",
410
+ "}\n",
411
+ "table.gr-samples-table tr td {\n",
412
+ " border: none;\n",
413
+ " outline: none;\n",
414
+ "}\n",
415
+ "table.gr-samples-table tr td:first-of-type {\n",
416
+ " width: 0%;\n",
417
+ "}\n",
418
+ "div#short-upload-box div.absolute {\n",
419
+ " display: none !important;\n",
420
+ "}\n",
421
+ "gradio-app > div > div > div > div.w-full > div, .gradio-app > div > div > div > div.w-full > div {\n",
422
+ " gap: 0px 2%;\n",
423
+ "}\n",
424
+ "gradio-app div div div div.w-full, .gradio-app div div div div.w-full {\n",
425
+ " gap: 0px;\n",
426
+ "}\n",
427
+ "gradio-app h2, .gradio-app h2 {\n",
428
+ " padding-top: 10px;\n",
429
+ "}\n",
430
+ "#answer {\n",
431
+ " overflow-y: scroll;\n",
432
+ " color: white;\n",
433
+ " background: #666;\n",
434
+ " border-color: #666;\n",
435
+ " font-size: 20px;\n",
436
+ " font-weight: bold;\n",
437
+ "}\n",
438
+ "#answer span {\n",
439
+ " color: white;\n",
440
+ "}\n",
441
+ "#answer textarea {\n",
442
+ " color:white;\n",
443
+ " background: #777;\n",
444
+ " border-color: #777;\n",
445
+ " font-size: 18px;\n",
446
+ "}\n",
447
+ "#url-error input {\n",
448
+ " color: red;\n",
449
+ "}\n",
450
+ "\"\"\""
451
+ ]
452
+ },
453
+ {
454
+ "cell_type": "code",
455
+ "execution_count": 22,
456
  "metadata": {},
457
  "outputs": [
 
 
 
 
 
 
 
 
 
 
 
 
 
 
458
  {
459
  "name": "stdout",
460
  "output_type": "stream",
461
  "text": [
462
+ "Running on local URL: http://127.0.0.1:7868/\n",
463
  "\n",
464
  "To create a public link, set `share=True` in `launch()`.\n"
465
  ]
 
467
  {
468
  "data": {
469
  "text/html": [
470
+ "<div><iframe src=\"http://127.0.0.1:7868/\" width=\"900\" height=\"500\" allow=\"autoplay; camera; microphone;\" frameborder=\"0\" allowfullscreen></iframe></div>"
471
  ],
472
  "text/plain": [
473
  "<IPython.core.display.HTML object>"
 
479
  {
480
  "data": {
481
  "text/plain": [
482
+ "(<gradio.routes.App at 0x157b389d0>, 'http://127.0.0.1:7868/', None)"
483
  ]
484
  },
485
+ "execution_count": 22,
486
  "metadata": {},
487
  "output_type": "execute_result"
488
  }
489
  ],
490
  "source": [
491
+ "demo = gr.Blocks(css=CSS)\n",
492
  "with demo:\n",
493
+ " with gr.Row(equal_height=True):\n",
494
+ " with gr.Column():\n",
495
+ " with gr.Row():\n",
496
+ " text = gr.Textbox(\n",
497
+ " show_label=False,\n",
498
+ " placeholder=\"URL\",\n",
499
+ " lines=1,\n",
500
+ " max_lines=1,\n",
501
+ " elem_id=\"url-textbox\",\n",
502
+ " )\n",
503
+ " button = gr.Button(\"Get\", variant=\"primary\")\n",
504
  " with gr.Row():\n",
505
  " card = gr.HTML()\n",
506
  "\n",