diff --git a/3rd-PARTY-LICENSES b/3rd-PARTY-LICENSES index 05ba4541..93f533ea 100644 --- a/3rd-PARTY-LICENSES +++ b/3rd-PARTY-LICENSES @@ -1120,3 +1120,29 @@ ExifReader is licensed under the Mozilla Public License: This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. +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/README.md b/README.md index 281b4da4..ec46dea7 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,9 @@ Does not require technical knowledge, does not require pre-installed software. 1 Click the download button for your operating system:
**Hardware requirements:** diff --git a/ui/easydiffusion/bucket_manager.py b/ui/easydiffusion/bucket_manager.py index c4f4c7e1..c06974bd 100644 --- a/ui/easydiffusion/bucket_manager.py +++ b/ui/easydiffusion/bucket_manager.py @@ -1,12 +1,14 @@ from typing import List from fastapi import Depends, FastAPI, HTTPException, Response, File +from fastapi.responses import FileResponse from sqlalchemy.orm import Session from easydiffusion.easydb import crud, models, schemas from easydiffusion.easydb.database import SessionLocal, engine from requests.compat import urlparse +from os.path import abspath import base64, json @@ -92,7 +94,28 @@ def init(): result.data = base64.encodestring(result.data) return result + @server_api.get("/image/{image_path:path}") + def get_image(image_path: str, db: Session = Depends(get_db)): + from easydiffusion.easydb.mappings import GalleryImage + image_path = str(abspath(image_path)) + try: + 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(prompt: str = "", model: str = "", page: int = 0, images_per_page: int = 50, workspace : str = "default", db: Session = Depends(get_db)): + from easydiffusion.easydb.mappings import GalleryImage + images = db.query(GalleryImage).filter(GalleryImage.workspace == workspace).order_by(GalleryImage.time_created.desc()) + if prompt != "": + images = images.filter(GalleryImage.prompt.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 new file mode 100644 index 00000000..9a01f0c9 --- /dev/null +++ b/ui/easydiffusion/easydb/mappings.py @@ -0,0 +1,82 @@ +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 GalleryImage(Base): + __tablename__ = 'images' + + path = Column(String, primary_key=True) + seed = Column(Integer) + use_stable_diffusion_model = Column(String) + clip_skip = Column(Boolean) + use_vae_model = Column(String) + sampler_name = Column(String) + width = Column(Integer) + height = Column(Integer) + num_inference_steps = Column(Integer) + guidance_scale = Column(Float) + lora = Column(String) + use_hypernetwork_model = Column(String) + tiling = Column(String) + use_face_correction = Column(String) + use_upscale = Column(String) + prompt = Column(String) + negative_prompt = Column(String) + workspace = Column(String, server_default="default") + time_created = Column(DateTime(timezone=True), server_default=func.now()) + nsfw = Column(Boolean, server_default=None) + + def __repr__(self): + 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) + "