Added single-image-site

This commit is contained in:
ManInDark 2023-08-09 23:56:06 +02:00
parent 2bf7116f01
commit 8014ed2055
No known key found for this signature in database
GPG Key ID: 72EC12A5B2D62779
3 changed files with 43 additions and 0 deletions

View File

@ -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 = "<head><link rel='stylesheet' href='/media/css/single-gallery.css'></head>"
body = "<body><img src='/image/" + image.path + "'>" + image.htmlForm() + "</body>"
return Response(content="<html>" + head + body + "</head>", 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

View File

@ -31,5 +31,26 @@ class GalleryImage(Base):
return "<GalleryImage(path='%s', seed='%s', use_stable_diffusion_model='%s', clip_skip='%s', use_vae_model='%s', sampler_name='%s', width='%s', height='%s', num_inference_steps='%s', guidance_scale='%s', lora='%s', use_hypernetwork_model='%s', tiling='%s', use_face_correction='%s', use_upscale='%s', prompt='%s', negative_prompt='%s')>" % (
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 "<div><p>Path: " + str(self.path) + "</p>" + \
"Seed: " + str(self.seed) + "</p>" + \
"Stable Diffusion Model: " + str(self.use_stable_diffusion_model) + "</p>" + \
"Prompt: " + str(self.prompt) + "</p>" + \
"Negative Prompt: " + str(self.negative_prompt) + "</p>" + \
"Clip Skip: " + str(self.clip_skip) + "</p>" + \
"VAE Model: " + str(self.use_vae_model) + "</p>" + \
"Sampler: " + str(self.sampler_name) + "</p>" + \
"Size: " + str(self.height) + "x" + str(self.width) + "</p>" + \
"Inference Steps: " + str(self.num_inference_steps) + "</p>" + \
"Guidance Scale: " + str(self.guidance_scale) + "</p>" + \
"LoRA: " + str(self.lora) + "</p>" + \
"Hypernetwork: " + str(self.use_hypernetwork_model) + "</p>" + \
"Tiling: " + str(self.tiling) + "</p>" + \
"Face Correction: " + str(self.use_face_correction) + "</p>" + \
"Upscale: " + str(self.use_upscale) + "</p>" + \
"Time Created: " + str(self.time_created) + "</p>" + \
"NSFW: " + str(self.nsfw) + "</p></div>"
from easydiffusion.easydb.database import engine
GalleryImage.metadata.create_all(engine)

View File

@ -0,0 +1,9 @@
body {
display: flex;
flex-direction: column;
align-items: center;
}
p {
margin: 0px;
}