Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -403,16 +403,6 @@ def SaveFileNameClicked():
|
|
403 |
newFileText = st.session_state.file_content_area
|
404 |
oldFileText = st.session_state.filetext
|
405 |
|
406 |
-
|
407 |
-
#if newFileName:
|
408 |
-
#os.rename(file_name, newFileName)
|
409 |
-
#file_name = newFileName
|
410 |
-
|
411 |
-
|
412 |
-
#if file_name_save_name:
|
413 |
-
# with open(file_name, 'w', encoding='utf-8') as file:
|
414 |
-
# file.write(file_content_area)
|
415 |
-
|
416 |
def FileSidebar():
|
417 |
# ----------------------------------------------------- File Sidebar for Jump Gates ------------------------------------------
|
418 |
# Compose a file sidebar of markdown md files:
|
@@ -486,13 +476,19 @@ def FileSidebar():
|
|
486 |
if 'filetext' not in st.session_state:
|
487 |
st.session_state['filetext'] = ''
|
488 |
open1, open2 = st.columns(spec=[.8,.2])
|
|
|
489 |
with open1:
|
|
|
490 |
file_name_input = st.text_input(key='file_name_input', on_change=SaveFileNameClicked, label="File Name:",value=file_name )
|
491 |
-
file_content_area = st.text_area(key='file_content_area', on_change=SaveFileTextClicked, label="File Contents:", value=file_contents, height=
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
|
|
|
|
|
|
|
|
496 |
new_file_content_area = st.session_state['file_content_area']
|
497 |
if new_file_content_area != file_contents:
|
498 |
st.markdown(new_file_content_area) #changed
|
@@ -545,20 +541,26 @@ def get_image_as_base64(url):
|
|
545 |
def create_download_link(filename, base64_str):
|
546 |
href = f'<a href="data:file/png;base64,{base64_str}" download="{filename}">Download Image</a>'
|
547 |
return href
|
548 |
-
image_urls = [
|
549 |
-
"https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/cfhJIasuxLkT5fnaAE6Gj.png",
|
550 |
-
"https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/UMo4oWNrrd6RLLzsFxQAi.png",
|
551 |
-
"https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/o_EH4cTs5Qxiu7xTZw9I3.png",
|
552 |
-
"https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/cmCZ5RTdSx3usMm7MwwWK.png",
|
553 |
-
]
|
554 |
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
562 |
|
563 |
# Ensure the directory for storing scores exists
|
564 |
score_dir = "scores"
|
@@ -722,7 +724,7 @@ def display_videos_and_links():
|
|
722 |
display_glossary_entity(k)
|
723 |
col_index += 1 # Increment column index to place the next video in the next column
|
724 |
|
725 |
-
|
726 |
def display_images_and_wikipedia_summaries(num_columns=4):
|
727 |
image_files = [f for f in os.listdir('.') if f.endswith('.png')]
|
728 |
if not image_files:
|
|
|
403 |
newFileText = st.session_state.file_content_area
|
404 |
oldFileText = st.session_state.filetext
|
405 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
406 |
def FileSidebar():
|
407 |
# ----------------------------------------------------- File Sidebar for Jump Gates ------------------------------------------
|
408 |
# Compose a file sidebar of markdown md files:
|
|
|
476 |
if 'filetext' not in st.session_state:
|
477 |
st.session_state['filetext'] = ''
|
478 |
open1, open2 = st.columns(spec=[.8,.2])
|
479 |
+
|
480 |
with open1:
|
481 |
+
# Use onchange functions to autoexecute file name and text save functions.
|
482 |
file_name_input = st.text_input(key='file_name_input', on_change=SaveFileNameClicked, label="File Name:",value=file_name )
|
483 |
+
file_content_area = st.text_area(key='file_content_area', on_change=SaveFileTextClicked, label="File Contents:", value=file_contents, height=300)
|
484 |
+
bp1,bp2 = st.columns([.5,.5])
|
485 |
+
with bp1:
|
486 |
+
if st.button(label='💾 Save Name'):
|
487 |
+
SaveFileNameClicked()
|
488 |
+
with bp2:
|
489 |
+
if st.button(label='💾 Save File'):
|
490 |
+
SaveFileTextClicked()
|
491 |
+
|
492 |
new_file_content_area = st.session_state['file_content_area']
|
493 |
if new_file_content_area != file_contents:
|
494 |
st.markdown(new_file_content_area) #changed
|
|
|
541 |
def create_download_link(filename, base64_str):
|
542 |
href = f'<a href="data:file/png;base64,{base64_str}" download="{filename}">Download Image</a>'
|
543 |
return href
|
|
|
|
|
|
|
|
|
|
|
|
|
544 |
|
545 |
+
def SideBarImageShuffle():
|
546 |
+
image_urls = [
|
547 |
+
"https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/cfhJIasuxLkT5fnaAE6Gj.png",
|
548 |
+
"https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/UMo4oWNrrd6RLLzsFxQAi.png",
|
549 |
+
"https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/o_EH4cTs5Qxiu7xTZw9I3.png",
|
550 |
+
"https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/cmCZ5RTdSx3usMm7MwwWK.png",
|
551 |
+
]
|
552 |
+
|
553 |
+
selected_image_url = random.choice(image_urls)
|
554 |
+
selected_image_base64 = get_image_as_base64(selected_image_url)
|
555 |
+
if selected_image_base64 is not None:
|
556 |
+
with st.sidebar:
|
557 |
+
st.markdown(f"![image](data:image/png;base64,{selected_image_base64})")
|
558 |
+
else:
|
559 |
+
st.sidebar.write("Failed to load the image.")
|
560 |
+
|
561 |
+
ShowSideImages=False
|
562 |
+
if ShowSideImages:
|
563 |
+
SideBarImageShuffle()
|
564 |
|
565 |
# Ensure the directory for storing scores exists
|
566 |
score_dir = "scores"
|
|
|
724 |
display_glossary_entity(k)
|
725 |
col_index += 1 # Increment column index to place the next video in the next column
|
726 |
|
727 |
+
#@st.cache_resource
|
728 |
def display_images_and_wikipedia_summaries(num_columns=4):
|
729 |
image_files = [f for f in os.listdir('.') if f.endswith('.png')]
|
730 |
if not image_files:
|