Upload app.py
Browse files
app.py
CHANGED
|
@@ -31,7 +31,7 @@ def create_comparison_app(file_paths):
|
|
| 31 |
files_left = len(file_paths) - (current_file_index + 1)
|
| 32 |
if current_filepath:
|
| 33 |
prompts_left = len(results_data[current_filepath]) - (current_prompt_index + 1) if current_prompt_index < len(results_data[current_filepath]) else 0
|
| 34 |
-
return f"File {current_file_index + 1}/{len(file_paths)}
|
| 35 |
else:
|
| 36 |
return "No file loaded."
|
| 37 |
|
|
@@ -77,7 +77,7 @@ def create_comparison_app(file_paths):
|
|
| 77 |
else:
|
| 78 |
# All files finished, prepare zip archive for download
|
| 79 |
zip_filepath = create_zip_archive(results_data)
|
| 80 |
-
return "Comparison finished for all files!
|
| 81 |
else:
|
| 82 |
# Should not reach here normally, but handle for robustness - in case record_choice is called after file is finished
|
| 83 |
if current_file_index < len(file_paths) - 1:
|
|
@@ -88,7 +88,7 @@ def create_comparison_app(file_paths):
|
|
| 88 |
else:
|
| 89 |
# All files finished, prepare zip archive for download
|
| 90 |
zip_filepath = create_zip_archive(results_data)
|
| 91 |
-
return "Comparison finished for all files!
|
| 92 |
|
| 93 |
def create_zip_archive(results_data):
|
| 94 |
"""Creates a zip archive of all result files."""
|
|
@@ -102,20 +102,21 @@ def create_comparison_app(file_paths):
|
|
| 102 |
|
| 103 |
with gr.Blocks() as iface:
|
| 104 |
progress_markdown = gr.Markdown(get_progress_text()) # Progress indication at the top
|
| 105 |
-
gr.Markdown("# LLM
|
| 106 |
-
|
|
|
|
| 107 |
|
| 108 |
with gr.Row(): # Row for side-by-side outputs
|
| 109 |
with gr.Column(): # Column for Finetuned Output
|
| 110 |
-
finetuned_output_box = gr.Textbox(label="
|
| 111 |
with gr.Column(): # Column for Base Output
|
| 112 |
-
base_output_box = gr.Textbox(label="
|
| 113 |
|
| 114 |
with gr.Row(): # Row for buttons
|
| 115 |
-
finetuned_button = gr.Button("
|
| 116 |
-
base_button = gr.Button("
|
| 117 |
|
| 118 |
-
file_download_output = gr.DownloadButton(label="Download
|
| 119 |
|
| 120 |
def load_initial_file(files):
|
| 121 |
if files:
|
|
|
|
| 31 |
files_left = len(file_paths) - (current_file_index + 1)
|
| 32 |
if current_filepath:
|
| 33 |
prompts_left = len(results_data[current_filepath]) - (current_prompt_index + 1) if current_prompt_index < len(results_data[current_filepath]) else 0
|
| 34 |
+
return f"File {current_file_index + 1}/{len(file_paths)} - {prompts_left + 1} prompts left in this file, {files_left} files remaining."
|
| 35 |
else:
|
| 36 |
return "No file loaded."
|
| 37 |
|
|
|
|
| 77 |
else:
|
| 78 |
# All files finished, prepare zip archive for download
|
| 79 |
zip_filepath = create_zip_archive(results_data)
|
| 80 |
+
return "Comparison finished for all files! Please download the results ('Download results' button).", "", "", "Comparison finished for all files!", gr.update(visible=True, value=zip_filepath, label="Download results") # Final completion, with file download
|
| 81 |
else:
|
| 82 |
# Should not reach here normally, but handle for robustness - in case record_choice is called after file is finished
|
| 83 |
if current_file_index < len(file_paths) - 1:
|
|
|
|
| 88 |
else:
|
| 89 |
# All files finished, prepare zip archive for download
|
| 90 |
zip_filepath = create_zip_archive(results_data)
|
| 91 |
+
return "Comparison finished for all files! Please download the results ('Download results' button).", "", "", "Comparison finished for all files!", gr.update(visible=True, value=zip_filepath, label="Download results")
|
| 92 |
|
| 93 |
def create_zip_archive(results_data):
|
| 94 |
"""Creates a zip archive of all result files."""
|
|
|
|
| 102 |
|
| 103 |
with gr.Blocks() as iface:
|
| 104 |
progress_markdown = gr.Markdown(get_progress_text()) # Progress indication at the top
|
| 105 |
+
gr.Markdown("# LLM song lyrics generation ranking")
|
| 106 |
+
gr.Markdown("There are 5 files (each with 50 prompts) to compare. For each prompt, choose the better lyrics between Model A and Model B. After you complete all files and prompts, you can download the results.")
|
| 107 |
+
prompt_output = gr.Textbox(label="Lyrics description", lines=3, interactive=False, max_lines=3) # Fixed lines for prompt
|
| 108 |
|
| 109 |
with gr.Row(): # Row for side-by-side outputs
|
| 110 |
with gr.Column(): # Column for Finetuned Output
|
| 111 |
+
finetuned_output_box = gr.Textbox(label="Model A", lines=10, interactive=False, max_lines=10) # Fixed lines for finetuned
|
| 112 |
with gr.Column(): # Column for Base Output
|
| 113 |
+
base_output_box = gr.Textbox(label="Model B", lines=10, interactive=False, max_lines=10) # Fixed lines for base
|
| 114 |
|
| 115 |
with gr.Row(): # Row for buttons
|
| 116 |
+
finetuned_button = gr.Button("Model A is better")
|
| 117 |
+
base_button = gr.Button("Model B is better")
|
| 118 |
|
| 119 |
+
file_download_output = gr.DownloadButton(label="Download results", visible=False) # File output component
|
| 120 |
|
| 121 |
def load_initial_file(files):
|
| 122 |
if files:
|