timeki commited on
Commit
d5c9c65
1 Parent(s): 7d9ec3d

Change figures display to gradio modal

Browse files
Files changed (3) hide show
  1. app.py +13 -2
  2. front/utils.py +1 -1
  3. requirements.txt +1 -0
app.py CHANGED
@@ -27,6 +27,8 @@ from azure.storage.fileshare import ShareServiceClient
27
 
28
  from utils import create_user_id
29
 
 
 
30
 
31
 
32
  # ClimateQ&A imports
@@ -452,7 +454,16 @@ with gr.Blocks(title="Climate Q&A", css_paths=os.getcwd()+ "/style.css", theme=t
452
 
453
 
454
  with gr.Tab("Figures",elem_id = "tab-figures",id = 3):
 
 
 
 
 
 
455
  figures_cards = gr.HTML(show_label=False, elem_id="sources-figures")
 
 
 
456
 
457
 
458
 
@@ -461,8 +472,8 @@ with gr.Blocks(title="Climate Q&A", css_paths=os.getcwd()+ "/style.css", theme=t
461
  #---------------------------------------------------------------------------------------
462
 
463
 
464
- with gr.Tab("Figures",elem_id = "tab-images",elem_classes = "max-height other-tabs"):
465
- gallery_component = gr.Gallery()
466
 
467
  # with gr.Tab("Papers (beta)",elem_id = "tab-papers",elem_classes = "max-height other-tabs"):
468
 
 
27
 
28
  from utils import create_user_id
29
 
30
+ from gradio_modal import Modal
31
+
32
 
33
 
34
  # ClimateQ&A imports
 
454
 
455
 
456
  with gr.Tab("Figures",elem_id = "tab-figures",id = 3):
457
+ with Modal(visible=False, elem_id="modal_figure_galery") as modal:
458
+ gallery_component = gr.Gallery(object_fit='scale-down',elem_id="gallery-component", height="80vh")
459
+
460
+ show_full_size_figures = gr.Button("Show figures in full size",elem_id="show-figures",interactive=True)
461
+ show_full_size_figures.click(lambda : Modal(visible=True),None,modal)
462
+
463
  figures_cards = gr.HTML(show_label=False, elem_id="sources-figures")
464
+
465
+
466
+
467
 
468
 
469
 
 
472
  #---------------------------------------------------------------------------------------
473
 
474
 
475
+ # with gr.Tab("Figures",elem_id = "tab-images",elem_classes = "max-height other-tabs"):
476
+ # gallery_component = gr.Gallery(object_fit='cover')
477
 
478
  # with gr.Tab("Papers (beta)",elem_id = "tab-papers",elem_classes = "max-height other-tabs"):
479
 
front/utils.py CHANGED
@@ -138,7 +138,7 @@ def make_html_figure_sources(source,i,img_str):
138
  <div class="card-content">
139
  <h2>Image {i} - {title} - Page {int(meta['page_number'])}</h2>
140
  <p class='ai-generated'>AI-generated description</p>
141
- <img src="data:image/png;base64, { img_str } alt="Alt text" />
142
 
143
  <p>{content}</p>
144
 
 
138
  <div class="card-content">
139
  <h2>Image {i} - {title} - Page {int(meta['page_number'])}</h2>
140
  <p class='ai-generated'>AI-generated description</p>
141
+ <img src="data:image/png;base64, { img_str }" alt="Alt text" />
142
 
143
  <p>{content}</p>
144
 
requirements.txt CHANGED
@@ -18,3 +18,4 @@ nvidia-cudnn-cu12==8.9.2.26
18
  langchain-community==0.2
19
  msal==1.31
20
  matplotlib==3.9.2
 
 
18
  langchain-community==0.2
19
  msal==1.31
20
  matplotlib==3.9.2
21
+ gradio-modal==0.0.4