Switch to disable gallery

This commit is contained in:
JeLuF 2023-08-17 23:28:32 +02:00
parent bd980c0b5e
commit 4dc93186da
7 changed files with 50 additions and 25 deletions

View File

@ -100,9 +100,9 @@ def init():
raise HTTPException(status_code=404, detail="Image not found") raise HTTPException(status_code=404, detail="Image not found")
@server_api.get("/all_images") @server_api.get("/all_images")
def get_all_images(prompt: str = "", model: str = "", page: int = 0, images_per_page: int = 50, db: Session = Depends(get_db)): 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 from easydiffusion.easydb.mappings import GalleryImage
images = db.query(GalleryImage).order_by(GalleryImage.time_created.desc()) images = db.query(GalleryImage).filter(GalleryImage.workspace == workspace).order_by(GalleryImage.time_created.desc())
if prompt != "": if prompt != "":
images = images.filter(GalleryImage.prompt.like("%"+prompt+"%")) images = images.filter(GalleryImage.prompt.like("%"+prompt+"%"))
if model != "": if model != "":

View File

@ -85,6 +85,7 @@ class TaskData(BaseModel):
clip_skip: bool = False clip_skip: bool = False
codeformer_upscale_faces: bool = False codeformer_upscale_faces: bool = False
codeformer_fidelity: float = 0.5 codeformer_fidelity: float = 0.5
use_gallery: str = None
class MergeRequest(BaseModel): class MergeRequest(BaseModel):

View File

@ -160,28 +160,30 @@ def save_images_to_disk(
from easydiffusion.easydb.mappings import GalleryImage from easydiffusion.easydb.mappings import GalleryImage
from easydiffusion.easydb.database import SessionLocal from easydiffusion.easydb.database import SessionLocal
session = SessionLocal() if task_data.use_gallery != None:
session.add(GalleryImage( session = SessionLocal()
path = path_i, session.add(GalleryImage(
seed = metadata_entries[i]["seed"], path = path_i,
use_stable_diffusion_model = metadata_entries[i]["use_stable_diffusion_model"], seed = metadata_entries[i]["seed"],
clip_skip = metadata_entries[i]["clip_skip"], use_stable_diffusion_model = metadata_entries[i]["use_stable_diffusion_model"],
use_vae_model = metadata_entries[i]["use_vae_model"], clip_skip = metadata_entries[i]["clip_skip"],
sampler_name = metadata_entries[i]["sampler_name"], use_vae_model = metadata_entries[i]["use_vae_model"],
width = metadata_entries[i]["width"], sampler_name = metadata_entries[i]["sampler_name"],
height = metadata_entries[i]["height"], width = metadata_entries[i]["width"],
num_inference_steps = metadata_entries[i]["num_inference_steps"], height = metadata_entries[i]["height"],
guidance_scale = metadata_entries[i]["guidance_scale"], num_inference_steps = metadata_entries[i]["num_inference_steps"],
lora = createLoraString(metadata_entries, i), guidance_scale = metadata_entries[i]["guidance_scale"],
use_hypernetwork_model = metadata_entries[i]["use_hypernetwork_model"], lora = createLoraString(metadata_entries, i),
tiling = metadata_entries[i]["tiling"], use_hypernetwork_model = metadata_entries[i]["use_hypernetwork_model"],
use_face_correction = metadata_entries[i]["use_face_correction"], tiling = metadata_entries[i]["tiling"],
use_upscale = metadata_entries[i]["use_upscale"], use_face_correction = metadata_entries[i]["use_face_correction"],
prompt = metadata_entries[i]["prompt"], use_upscale = metadata_entries[i]["use_upscale"],
negative_prompt = metadata_entries[i]["negative_prompt"] prompt = metadata_entries[i]["prompt"],
)) negative_prompt = metadata_entries[i]["negative_prompt"],
session.commit() workspace = task_data.use_gallery
session.close() ))
session.commit()
session.close()
if task_data.metadata_output_format: if task_data.metadata_output_format:
for metadata_output_format in task_data.metadata_output_format.split(","): for metadata_output_format in task_data.metadata_output_format.split(","):

View File

@ -1031,6 +1031,9 @@ input::file-selector-button {
.input-toggle > input:checked + label { .input-toggle > input:checked + label {
background: var(--accent-color); background: var(--accent-color);
} }
.input-toggle > input:disabled + label {
background: var(--background-color1);
}
.input-toggle > input:checked + label:before { .input-toggle > input:checked + label:before {
right: calc(var(--input-border-size) + var(--input-switch-padding)); right: calc(var(--input-border-size) + var(--input-switch-padding));
opacity: 1; opacity: 1;

View File

@ -14,6 +14,7 @@ const SETTINGS_IDS_LIST = [
"num_outputs_parallel", "num_outputs_parallel",
"stable_diffusion_model", "stable_diffusion_model",
"clip_skip", "clip_skip",
"use_gallery",
"vae_model", "vae_model",
"hypernetwork_model", "hypernetwork_model",
"sampler_name", "sampler_name",

View File

@ -199,6 +199,7 @@ let undoButton = document.querySelector("#undo")
let undoBuffer = [] let undoBuffer = []
const UNDO_LIMIT = 20 const UNDO_LIMIT = 20
const MAX_IMG_UNDO_ENTRIES = 5 const MAX_IMG_UNDO_ENTRIES = 5
var GALLERY_NAME="default"
let IMAGE_STEP_SIZE = 64 let IMAGE_STEP_SIZE = 64
@ -1542,6 +1543,7 @@ function getCurrentUserRequest() {
output_quality: parseInt(outputQualityField.value), output_quality: parseInt(outputQualityField.value),
output_lossless: outputLosslessField.checked, output_lossless: outputLosslessField.checked,
metadata_output_format: metadataOutputFormatField.value, metadata_output_format: metadataOutputFormatField.value,
use_gallery: useGalleryField.checked?GALLERY_NAME:null,
original_prompt: promptField.value, original_prompt: promptField.value,
active_tags: activeTags.map((x) => x.name), active_tags: activeTags.map((x) => x.name),
inactive_tags: activeTags.filter((tag) => tag.inactive === true).map((x) => x.name), inactive_tags: activeTags.filter((tag) => tag.inactive === true).map((x) => x.name),
@ -2008,6 +2010,7 @@ function onDimensionChange() {
diskPathField.disabled = !saveToDiskField.checked diskPathField.disabled = !saveToDiskField.checked
metadataOutputFormatField.disabled = !saveToDiskField.checked metadataOutputFormatField.disabled = !saveToDiskField.checked
useGalleryField.disabled = !saveToDiskField.checked
gfpganModelField.disabled = !useFaceCorrectionField.checked gfpganModelField.disabled = !useFaceCorrectionField.checked
useFaceCorrectionField.addEventListener("change", function(e) { useFaceCorrectionField.addEventListener("change", function(e) {
@ -3273,7 +3276,12 @@ function layoutGallery() {
galleryModelSearchField.addEventListener("keyup", debounce(e => refreshGallery(true), 500)) galleryModelSearchField.addEventListener("keyup", debounce(e => refreshGallery(true), 500))
galleryPromptSearchField.addEventListener("keyup", debounce(e => refreshGallery(true), 500)) galleryPromptSearchField.addEventListener("keyup", debounce(e => refreshGallery(true), 500))
galleryPageField.addEventListener("keyup", e => {
if (e.code === "Enter") {
e.preventDefault()
refreshGallery(false)
}
})
function refreshGallery(newsearch = false) { function refreshGallery(newsearch = false) {
if (newsearch) { if (newsearch) {
@ -3281,6 +3289,7 @@ function refreshGallery(newsearch = false) {
} }
galleryImageContainer.innerHTML = "" galleryImageContainer.innerHTML = ""
let params = new URLSearchParams({ let params = new URLSearchParams({
workspace: GALLERY_NAME,
prompt: galleryPromptSearchField.value, prompt: galleryPromptSearchField.value,
model: galleryModelSearchField.value, model: galleryModelSearchField.value,
page: galleryPageField.value page: galleryPageField.value

View File

@ -97,6 +97,13 @@ var PARAMETERS = [
}, },
], ],
}, },
{
id: "use_gallery",
type: ParameterType.checkbox,
label: "Save images to the gallery",
note: "Stores metadata of all images into a database so that they show up on the gallery tab.",
default: false,
},
{ {
id: "block_nsfw", id: "block_nsfw",
type: ParameterType.checkbox, type: ParameterType.checkbox,
@ -421,6 +428,7 @@ let uiOpenBrowserOnStartField = document.querySelector("#ui_open_browser_on_star
let confirmDangerousActionsField = document.querySelector("#confirm_dangerous_actions") let confirmDangerousActionsField = document.querySelector("#confirm_dangerous_actions")
let testDiffusers = document.querySelector("#test_diffusers") let testDiffusers = document.querySelector("#test_diffusers")
let profileNameField = document.querySelector("#profileName") let profileNameField = document.querySelector("#profileName")
let useGalleryField = document.querySelector("#use_gallery")
let saveSettingsBtn = document.querySelector("#save-system-settings-btn") let saveSettingsBtn = document.querySelector("#save-system-settings-btn")
@ -560,6 +568,7 @@ function applySettingsFromConfig(config) {
saveToDiskField.addEventListener("change", function(e) { saveToDiskField.addEventListener("change", function(e) {
diskPathField.disabled = !this.checked diskPathField.disabled = !this.checked
metadataOutputFormatField.disabled = !this.checked metadataOutputFormatField.disabled = !this.checked
useGalleryField.disabled = !this.checked
}) })
function getCurrentRenderDeviceSelection() { function getCurrentRenderDeviceSelection() {