diff --git a/ui/easydiffusion/bucket_manager.py b/ui/easydiffusion/bucket_manager.py
index cf09c581..0d72ed06 100644
--- a/ui/easydiffusion/bucket_manager.py
+++ b/ui/easydiffusion/bucket_manager.py
@@ -91,24 +91,18 @@ def init():
@server_api.get("/image/{image_path:path}")
def get_image(image_path: str, db: Session = Depends(get_db)):
- from easydiffusion.easydb.mappings import Image
+ from easydiffusion.easydb.mappings import GalleryImage
image_path = str(abspath(image_path))
try:
- image = db.query(Image).filter(Image.path == image_path).first()
+ image = db.query(GalleryImage).filter(GalleryImage.path == image_path).first()
return FileResponse(image.path)
except Exception as e:
raise HTTPException(status_code=404, detail="Image not found")
@server_api.get("/all_images")
def get_all_images(db: Session = Depends(get_db)):
- from easydiffusion.easydb.mappings import Image
- images = db.query(Image).all()
- # sum_string = "
"
- # for img in images:
- # options = f"Path: {img.path}\nPrompt: {img.prompt}\nNegative Prompt: {img.negative_prompt}\nSeed: {img.seed}\nModel: {img.use_stable_diffusion_model}\nSize: {img.height}x{img.width}\nSampler: {img.sampler_name}\nSteps: {img.num_inference_steps}\nGuidance Scale: {img.guidance_scale}\nLoRA: {img.lora}\nUpscaling: {img.use_upscale}\nFace Correction: {img.use_face_correction}\n"
- # sum_string += f"

"
- # sum_string += "
"
- # return Response(content=sum_string, media_type="text/html")
+ from easydiffusion.easydb.mappings import GalleryImage
+ images = db.query(GalleryImage).all()
return images
diff --git a/ui/easydiffusion/easydb/mappings.py b/ui/easydiffusion/easydb/mappings.py
index ad68ecab..31549709 100644
--- a/ui/easydiffusion/easydb/mappings.py
+++ b/ui/easydiffusion/easydb/mappings.py
@@ -1,9 +1,10 @@
-from sqlalchemy import Column, Integer, String, Float, Boolean
+from sqlalchemy import Column, Integer, String, Float, Boolean, DateTime
from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.sql import func
Base = declarative_base()
-class Image(Base):
+class GalleryImage(Base):
__tablename__ = 'images'
path = Column(String, primary_key=True)
@@ -23,10 +24,11 @@ class Image(Base):
use_upscale = Column(String)
prompt = Column(String)
negative_prompt = Column(String)
+ time_created = Column(DateTime(timezone=True), server_default=func.now())
def __repr__(self):
- return "" % (
+ return "" % (
self.path, self.seed, self.use_stable_diffusion_model, self.clip_skip, self.use_vae_model, self.sampler_name, self.width, self.height, self.num_inference_steps, self.guidance_scale, self.lora, self.use_hypernetwork_model, self.tiling, self.use_face_correction, self.use_upscale, self.prompt, self.negative_prompt)
from easydiffusion.easydb.database import engine
-Image.metadata.create_all(engine)
\ No newline at end of file
+GalleryImage.metadata.create_all(engine)
diff --git a/ui/easydiffusion/utils/save_utils.py b/ui/easydiffusion/utils/save_utils.py
index a21e32b8..7f668280 100644
--- a/ui/easydiffusion/utils/save_utils.py
+++ b/ui/easydiffusion/utils/save_utils.py
@@ -157,11 +157,11 @@ def save_images_to_disk(
else:
return metadata_entries[i]["use_lora_model"] + ":" + str(metadata_entries[i]["lora_alpha"])
- from easydiffusion.easydb.mappings import Image
+ from easydiffusion.easydb.mappings import GalleryImage
from easydiffusion.easydb.database import SessionLocal
session = SessionLocal()
- session.add(Image(
+ session.add(GalleryImage(
path = path_i,
seed = metadata_entries[i]["seed"],
use_stable_diffusion_model = metadata_entries[i]["use_stable_diffusion_model"],
diff --git a/ui/index.html b/ui/index.html
index 65be9480..d5803fcc 100644
--- a/ui/index.html
+++ b/ui/index.html
@@ -518,7 +518,9 @@
diff --git a/ui/media/css/main.css b/ui/media/css/main.css
index dfd12c32..e0d1d02d 100644
--- a/ui/media/css/main.css
+++ b/ui/media/css/main.css
@@ -1889,21 +1889,40 @@ div#enlarge-buttons {
}
/* Gallery CSS */
-#imagecontainer {
- display: flex;
- justify-content: space-around;
- flex-flow: row wrap;
- align-items: center;
+.gallery {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ flex-direction: column;
+ font-family: sans-serif;
}
-#imagecontainer>img {
- width: 30vw;
- min-width: 256px;
- max-width: 1024px;
- height: auto;
- margin-block: 1vh;
- border: 4px white solid;
+.gallery-container {
+ columns: 5 ;
+ column-gap: 1.5rem;
+ width: 95%;
+ margin: 0 0 ;
}
+.gallery-container div {
+ margin: 0 1.5rem 1.5rem 0;
+ display: inline-block;
+ width: 100%;
+ padding: 5px;
+
+ transition: all .75s ease-in-out;
+}
+
+.gallery-container div img {
+ width: 100%;
+ border-radius: 5px;
+ transition: all .25s ease-in-out;
+ box-shadow: 5px 5px 5px rgba(0,0,0,0.4);
+}
+
+.gallery-container div img:hover {
+ box-shadow: 1px 1px 15px rgba(32,0,128,0.8);
+}
+
#tab-content-gallery>button {
margin: 8px;
diff --git a/ui/media/js/main.js b/ui/media/js/main.js
index 6799a648..a4476252 100644
--- a/ui/media/js/main.js
+++ b/ui/media/js/main.js
@@ -3085,13 +3085,25 @@ let recentResolutionsValues = []
})()
/* Gallery JS */
+function galleryImage(item) {
+ let div = document.createElement("div")
+ let img = document.createElement("img")
+
+ img.src = "/image/" + item.path
+ img.dataset["request"] = JSON.stringify(item)
+ div.appendChild(img)
+ return div
+}
function refreshGallery() {
let container = document.getElementById("imagecontainer")
- container.remove()
+ container.innerHTML=""
fetch('/all_images')
- .then(response => response.text())
- .then(text => new DOMParser().parseFromString(text, 'text/html'))
- .then(html_like => html_like.getElementsByTagName('div')[0])
- .then(div => document.getElementById("tab-content-gallery").appendChild(div))
-}
\ No newline at end of file
+ .then(response => response.json())
+ .then(json => {
+ console.log(json)
+ json.forEach( item => {
+ container.appendChild(galleryImage(item))
+ })
+ })
+}