From 3333f94c3026b368e6bc0e3e2f9acb1d963e1d08 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Sun, 26 Feb 2023 12:37:26 -0300 Subject: [PATCH] Make the gallery extension work on colab --- extensions/gallery/script.py | 38 +++++++++++++++++++++++++----------- modules/html_generator.py | 2 +- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/extensions/gallery/script.py b/extensions/gallery/script.py index 8d606352..87216a15 100644 --- a/extensions/gallery/script.py +++ b/extensions/gallery/script.py @@ -4,6 +4,8 @@ from pathlib import Path import gradio as gr +from modules.html_generator import image_to_base64 + def generate_html(): css = """ @@ -29,10 +31,14 @@ def generate_html(): background-color: gray; } - .character-gallery td { - text-align: center; - vertical-align: middle; + .character-gallery .image-td { + width: 150px; } + + .character-gallery .character-td { + text-align: center !important; + } + """ table_html = f'
{image_html} | {image_name} | " + image_html = "" + + for i in [ + f"characters/{character}.png", + f"characters/{character}.jpg", + f"characters/{character}.jpeg", + ]: + + path = Path(i) + if path.exists(): + try: + image_html = f'' + break + except: + continue + + table_html += f'{image_html} | {character} | ' table_html += "