Spaces:
Running
on
A100
Running
on
A100
Update app.py
Browse files
app.py
CHANGED
@@ -198,7 +198,7 @@ def generate_images(prompt, quantization_choice, progress=gr.Progress(track_tqdm
|
|
198 |
random.shuffle(shuffled_results)
|
199 |
shuffled_data_for_gallery = [(res["image"], f"Image {i+1}") for i, res in enumerate(shuffled_results)]
|
200 |
correct_mapping = {i: res["label"] for i, res in enumerate(shuffled_results)}
|
201 |
-
|
202 |
|
203 |
return shuffled_data_for_gallery, correct_mapping, prompt, seed, results, "Generation complete! Make your guess.", None, gr.update(interactive=True), gr.update(interactive=True)
|
204 |
|
@@ -233,12 +233,14 @@ EXAMPLES = [
|
|
233 |
"files": ["astronauts_seed_6456306350371904162.png", "astronauts_bnb_8bit.png"],
|
234 |
"quantized_idx": 1,
|
235 |
"quant_method": "8-bit bnb",
|
|
|
236 |
},
|
237 |
{
|
238 |
"prompt": "Water-color painting of a cat wearing sunglasses",
|
239 |
"files": ["watercolor_cat_bnb_8bit.png", "watercolor_cat_seed_14269059182221286790.png"],
|
240 |
"quantized_idx": 0,
|
241 |
"quant_method": "8-bit bnb",
|
|
|
242 |
},
|
243 |
# {
|
244 |
# "prompt": "Neo-tokyo cyberpunk cityscape at night, rain-soaked streets, 8-K",
|
@@ -337,7 +339,7 @@ with gr.Blocks(title="FLUX Quantization Challenge", theme=gr.themes.Soft()) as d
|
|
337 |
|
338 |
gr.Markdown("### Examples")
|
339 |
ex_selector = gr.Radio(
|
340 |
-
choices=[
|
341 |
label="Choose an example prompt",
|
342 |
interactive=True,
|
343 |
)
|
@@ -403,8 +405,15 @@ with gr.Blocks(title="FLUX Quantization Challenge", theme=gr.themes.Soft()) as d
|
|
403 |
seed_state = gr.State(None)
|
404 |
results_state = gr.State([])
|
405 |
|
406 |
-
def _load_example_and_update_dfs(
|
407 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
408 |
gallery_items, mapping, prompt = load_example(idx)
|
409 |
quant_data, overall_user_data, _ = update_leaderboards_data()
|
410 |
return gallery_items, mapping, prompt, True, quant_data, overall_user_data, "", None, []
|
|
|
198 |
random.shuffle(shuffled_results)
|
199 |
shuffled_data_for_gallery = [(res["image"], f"Image {i+1}") for i, res in enumerate(shuffled_results)]
|
200 |
correct_mapping = {i: res["label"] for i, res in enumerate(shuffled_results)}
|
201 |
+
print("Correct mapping (hidden):", correct_mapping)
|
202 |
|
203 |
return shuffled_data_for_gallery, correct_mapping, prompt, seed, results, "Generation complete! Make your guess.", None, gr.update(interactive=True), gr.update(interactive=True)
|
204 |
|
|
|
233 |
"files": ["astronauts_seed_6456306350371904162.png", "astronauts_bnb_8bit.png"],
|
234 |
"quantized_idx": 1,
|
235 |
"quant_method": "8-bit bnb",
|
236 |
+
"summary": "Astronaut on Mars",
|
237 |
},
|
238 |
{
|
239 |
"prompt": "Water-color painting of a cat wearing sunglasses",
|
240 |
"files": ["watercolor_cat_bnb_8bit.png", "watercolor_cat_seed_14269059182221286790.png"],
|
241 |
"quantized_idx": 0,
|
242 |
"quant_method": "8-bit bnb",
|
243 |
+
"summary": "Cat with Sunglasses",
|
244 |
},
|
245 |
# {
|
246 |
# "prompt": "Neo-tokyo cyberpunk cityscape at night, rain-soaked streets, 8-K",
|
|
|
339 |
|
340 |
gr.Markdown("### Examples")
|
341 |
ex_selector = gr.Radio(
|
342 |
+
choices=[ex["summary"] for ex in EXAMPLES],
|
343 |
label="Choose an example prompt",
|
344 |
interactive=True,
|
345 |
)
|
|
|
405 |
seed_state = gr.State(None)
|
406 |
results_state = gr.State([])
|
407 |
|
408 |
+
def _load_example_and_update_dfs(sel_summary):
|
409 |
+
# Find the index of the selected example by its summary
|
410 |
+
idx = next((i for i, ex in enumerate(EXAMPLES) if ex["summary"] == sel_summary), -1)
|
411 |
+
if idx == -1:
|
412 |
+
# Fallback or error handling if summary not found
|
413 |
+
print(f"Error: Example with summary '{sel_summary}' not found.")
|
414 |
+
return (gr.update(), gr.update(), gr.update(), False, gr.update(), gr.update(), "", None, [])
|
415 |
+
|
416 |
+
ex = EXAMPLES[idx]
|
417 |
gallery_items, mapping, prompt = load_example(idx)
|
418 |
quant_data, overall_user_data, _ = update_leaderboards_data()
|
419 |
return gallery_items, mapping, prompt, True, quant_data, overall_user_data, "", None, []
|