From 8014ed2055eac792a8ec738ceaa2e07f8cafe9ee Mon Sep 17 00:00:00 2001 From: ManInDark <61268856+ManInDark@users.noreply.github.com> Date: Wed, 9 Aug 2023 23:56:06 +0200 Subject: [PATCH] Added single-image-site --- ui/easydiffusion/bucket_manager.py | 13 +++++++++++++ ui/easydiffusion/easydb/mappings.py | 21 +++++++++++++++++++++ ui/media/css/single-gallery.css | 9 +++++++++ 3 files changed, 43 insertions(+) create mode 100644 ui/media/css/single-gallery.css diff --git a/ui/easydiffusion/bucket_manager.py b/ui/easydiffusion/bucket_manager.py index 43b5f147..9b7aeae1 100644 --- a/ui/easydiffusion/bucket_manager.py +++ b/ui/easydiffusion/bucket_manager.py @@ -108,6 +108,19 @@ def init(): if model != "": images = images.filter(GalleryImage.use_stable_diffusion_model.like("%"+model+"%")) return images.all() + + @server_api.get("/single_image") + def get_single_image(image_path: str, db: Session = Depends(get_db)): + from easydiffusion.easydb.mappings import GalleryImage + image_path = str(abspath(image_path)) + try: + image: GalleryImage = db.query(GalleryImage).filter(GalleryImage.path == image_path).first() + head = "" + body = "" + image.htmlForm() + "" + return Response(content="" + head + body + "", media_type="text/html") + except Exception as e: + print(e) + raise HTTPException(status_code=404, detail="Image not found") def get_filename_from_url(url): path = urlparse(url).path diff --git a/ui/easydiffusion/easydb/mappings.py b/ui/easydiffusion/easydb/mappings.py index 035f2ee8..653539ad 100644 --- a/ui/easydiffusion/easydb/mappings.py +++ b/ui/easydiffusion/easydb/mappings.py @@ -31,5 +31,26 @@ class GalleryImage(Base): 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) + "

" + + from easydiffusion.easydb.database import engine GalleryImage.metadata.create_all(engine) diff --git a/ui/media/css/single-gallery.css b/ui/media/css/single-gallery.css new file mode 100644 index 00000000..dbaedfa1 --- /dev/null +++ b/ui/media/css/single-gallery.css @@ -0,0 +1,9 @@ +body { + display: flex; + flex-direction: column; + align-items: center; +} + +p { + margin: 0px; +} \ No newline at end of file