Skip to content

Commit

Permalink
add image browser
Browse files Browse the repository at this point in the history
Signed-off-by: ふぁ <[email protected]>
  • Loading branch information
fa0311 committed May 13, 2023
1 parent a55cc85 commit 5bdee78
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions modules/tabs/images_browser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from typing import *

import gradio as gr
import glob
import os
from modules.components import image_generation_options

from modules import setting
from modules.ui import Tab

from PIL import Image


class ImagesBrowser(Tab):
def title(self):
return "Images Browser"

def sort(self):
return 3

def ui(self, outlet):
with gr.Column():
outputs_dir = glob.glob(os.path.join("outputs", "*"))
with gr.Tabs():
for dir in outputs_dir:
with gr.Tab(dir.split(os.sep)[-1]):
outputs_img = glob.glob(os.path.join(dir, "*"))
imgs = [f for f in outputs_img if os.path.isfile(f)]
imgs_sorted = sorted(imgs, key=os.path.getmtime)
gr.Gallery(
value=[Image.open(img) for img in imgs_sorted]
).style(columns=4)

0 comments on commit 5bdee78

Please sign in to comment.