diff --git a/3rd-PARTY-LICENSES b/3rd-PARTY-LICENSES index 78bfe3bb..10f359d0 100644 --- a/3rd-PARTY-LICENSES +++ b/3rd-PARTY-LICENSES @@ -740,3 +740,30 @@ croppr.js is licensed under the MIT license: LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Masonry +======= +https://masonry.desandro.com/ + +Masonry is licensed under the MIT license: + + The MIT License (MIT) + + Copyright © 2023 David DeSandro + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the “Software”), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is furnished + to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ui/easydiffusion/bucket_manager.py b/ui/easydiffusion/bucket_manager.py index 0d72ed06..c168f91a 100644 --- a/ui/easydiffusion/bucket_manager.py +++ b/ui/easydiffusion/bucket_manager.py @@ -100,12 +100,16 @@ def init(): raise HTTPException(status_code=404, detail="Image not found") @server_api.get("/all_images") - def get_all_images(db: Session = Depends(get_db)): + def get_all_images(prompt: str = "", model: str = "", page: int = 0, images_per_page: int = 50, db: Session = Depends(get_db)): from easydiffusion.easydb.mappings import GalleryImage - images = db.query(GalleryImage).all() - return images - - + images = db.query(GalleryImage).order_by(GalleryImage.time_created.desc()) + if prompt != "": + images = images.filter(GalleryImage.path.like("%"+prompt+"%")) + if model != "": + images = images.filter(GalleryImage.use_stable_diffusion_model.like("%"+model+"%")) + images = images.offset(page*images_per_page).limit(images_per_page) + return images.all() + def get_filename_from_url(url): path = urlparse(url).path name = path[path.rfind('/')+1:] diff --git a/ui/easydiffusion/easydb/mappings.py b/ui/easydiffusion/easydb/mappings.py index 31549709..214a4c68 100644 --- a/ui/easydiffusion/easydb/mappings.py +++ b/ui/easydiffusion/easydb/mappings.py @@ -25,10 +25,57 @@ class GalleryImage(Base): prompt = Column(String) negative_prompt = Column(String) time_created = Column(DateTime(timezone=True), server_default=func.now()) + nsfw = Column(Boolean, server_default=None) def __repr__(self): 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) + def htmlForm(self) -> str: + return "

Path: " + str(self.path) + "

" + \ + "

Seed: " + str(self.seed) + "

" + \ + "

Stable Diffusion Model: " + str(self.use_stable_diffusion_model) + "

" + \ + "

Prompt: " + str(self.prompt) + "

" + \ + "

Negative Prompt: " + str(self.negative_prompt) + "

" + \ + "

Clip Skip: " + str(self.clip_skip) + "

" + \ + "

VAE Model: " + str(self.use_vae_model) + "

" + \ + "

Sampler: " + str(self.sampler_name) + "

" + \ + "

Size: " + str(self.height) + "x" + str(self.width) + "

" + \ + "

Inference Steps: " + str(self.num_inference_steps) + "

" + \ + "

Guidance Scale: " + str(self.guidance_scale) + "

" + \ + "

LoRA: " + str(self.lora) + "

" + \ + "

Hypernetwork: " + str(self.use_hypernetwork_model) + "

" + \ + "

Tiling: " + str(self.tiling) + "

" + \ + "

Face Correction: " + str(self.use_face_correction) + "

" + \ + "

Upscale: " + str(self.use_upscale) + "

" + \ + "

Time Created: " + str(self.time_created) + "

" + \ + "

NSFW: " + str(self.nsfw) + "

" + + def settingsJSON(self) -> str: + # some are still missing: prompt strength, lora + json = { + "numOutputsTotal": 1, + "seed": self.seed, + "reqBody": { + "prompt": self.prompt, + "negative_prompt": self.negative_prompt, + "width": self.width, + "height": self.height, + "seed": self.seed, + "num_inference_steps": self.num_inference_steps, + "guidance_scale": self.guidance_scale, + "use_face_correction": self.use_face_correction, + "use_upscale": self.use_upscale, + "sampler_name": self.sampler_name, + "use_stable_diffusion_model": self.use_stable_diffusion_model, + "clip_skip": self.clip_skip, + "tiling": self.tiling, + "use_vae_model": self.use_vae_model, + "use_hypernetwork_model": self.use_hypernetwork_model + }} + from json import dumps + return dumps(json) + + from easydiffusion.easydb.database import engine GalleryImage.metadata.create_all(engine) diff --git a/ui/easydiffusion/server.py b/ui/easydiffusion/server.py index 1ecbbbd3..afe869bb 100644 --- a/ui/easydiffusion/server.py +++ b/ui/easydiffusion/server.py @@ -143,6 +143,10 @@ def init(): def read_root(): return FileResponse(os.path.join(app.SD_UI_DIR, "index.html"), headers=NOCACHE_HEADERS) + @server_api.get("/gallery-image.html") + def read_gallery_image(): + return FileResponse(os.path.join(app.SD_UI_DIR, "gallery-image.html"), headers=NOCACHE_HEADERS) + @server_api.on_event("shutdown") def shutdown_event(): # Signal render thread to close on shutdown task_manager.current_state_error = SystemExit("Application shutting down.") diff --git a/ui/gallery-image.html b/ui/gallery-image.html new file mode 100644 index 00000000..ad6258e1 --- /dev/null +++ b/ui/gallery-image.html @@ -0,0 +1,14 @@ + + + + + +
+ + +
+ + +
+
+ diff --git a/ui/index.html b/ui/index.html index e4b7a589..cf514fe9 100644 --- a/ui/index.html +++ b/ui/index.html @@ -26,6 +26,7 @@ +
@@ -517,7 +518,16 @@