Add renumber prompts button

exit_image
Charles Fettinger 2023-05-19 23:14:59 -07:00
parent b4ded06b66
commit cf2e0d3ed1
3 changed files with 38 additions and 2 deletions

BIN
blends/inf-zoom.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 382 KiB

View File

@ -160,4 +160,29 @@ def find_ffmpeg_binary():
files.sort(key=lambda x: os.path.getmtime(x), reverse=True)
return files[0] if files else 'ffmpeg'
except:
return 'ffmpeg'
return 'ffmpeg'
def renumberDataframe(data):
# Store the first sublist as index0
index0 = data[0]
# Skip the first sublist (index 0)
data = data[1:]
try:
# Sort the data based on the first column
data.sort(key=lambda x: int(x[0]))
# Renumber the index values sequentially
for i in range(len(data)):
data[i][0] = i + 1
except Exception as e:
print(f"An error occurred: {e}")
return [index0] + data
# Prepend index0 to the renumbered data
data.insert(0, index0)
return data

View File

@ -18,7 +18,7 @@ from .static_variables import (
default_sampler,
default_gradient_size,
)
from .helpers import validatePromptJson_throws, putPrompts, clearPrompts
from .helpers import validatePromptJson_throws, putPrompts, clearPrompts, renumberDataframe
from .prompt_util import readJsonPrompt
from .static_variables import promptTableHeaders
@ -319,6 +319,17 @@ Our best experience and trade-off is the R-ERSGAn4x upscaler.
main_seed
],
)
renumberPrompts_button = gr.Button(
value= "Renumber Prompts",
variant="secondary",
elem_classes="sm infzoom_tab_butt",
elem_id="infzoom_rnP_butt",
)
renumberPrompts_button.click(
fn=renumberDataframe,
inputs=[main_prompts],
outputs=[main_prompts]
)
with gr.Column(scale=1, variant="compact"):
output_video = gr.Video(label="Output").style(width=512, height=512)