From 756cba2edc1804ce930b1c40436bc641c60225ab Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Sun, 26 Feb 2023 12:17:57 -0300 Subject: [PATCH] Add character gallery extension --- extensions/gallery/script.py | 62 ++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 extensions/gallery/script.py diff --git a/extensions/gallery/script.py b/extensions/gallery/script.py new file mode 100644 index 00000000..8d606352 --- /dev/null +++ b/extensions/gallery/script.py @@ -0,0 +1,62 @@ +import json +import os +from pathlib import Path + +import gradio as gr + + +def generate_html(): + css = """ + .character-gallery table { + border-collapse: collapse; + table-layout: fixed; + width: 100%; + } + + .character-gallery th, .character-gallery td { + padding: 8px; + } + + .character-gallery img { + width: 150px; + height: 200px; + object-fit: cover; + } + + .character-gallery .placeholder { + width: 150px; + height: 200px; + background-color: gray; + } + + .character-gallery td { + text-align: center; + vertical-align: middle; + } + """ + + table_html = f'" + + return table_html + +def ui(): + with gr.Accordion("Character gallery"): + update = gr.Button("Refresh") + gallery = gr.HTML(value=generate_html()) + update.click(generate_html, [], gallery)