mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
experimenting with image queries
This commit is contained in:
parent
dca5a2ce26
commit
a03c895668
@ -157,3 +157,14 @@ async def get_uncategorized_image_counts() -> UncategorizedImageCounts:
|
|||||||
"""Gets count of images and assets for uncategorized images (images with no board assocation)"""
|
"""Gets count of images and assets for uncategorized images (images with no board assocation)"""
|
||||||
|
|
||||||
return ApiDependencies.invoker.services.board_records.get_uncategorized_image_counts()
|
return ApiDependencies.invoker.services.board_records.get_uncategorized_image_counts()
|
||||||
|
|
||||||
|
|
||||||
|
@boards_router.get(
|
||||||
|
"/uncategorized/names",
|
||||||
|
operation_id="get_uncategorized_image_names",
|
||||||
|
response_model=list[str],
|
||||||
|
)
|
||||||
|
async def get_uncategorized_image_names() -> list[str]:
|
||||||
|
"""Gets count of images and assets for uncategorized images (images with no board assocation)"""
|
||||||
|
|
||||||
|
return ApiDependencies.invoker.services.board_records.get_uncategorized_image_names()
|
||||||
|
61
invokeai/app/api/routers/dupe images.ipynb
Normal file
61
invokeai/app/api/routers/dupe images.ipynb
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"from pathlib import Path\n",
|
||||||
|
"import sqlite3\n",
|
||||||
|
"from uuid import uuid4\n",
|
||||||
|
"\n",
|
||||||
|
"# duplicate _all_ images in gallery\n",
|
||||||
|
"\n",
|
||||||
|
"def duplicate_images(database_path: Path, num_copies: int):\n",
|
||||||
|
" conn = sqlite3.connect(database_path)\n",
|
||||||
|
" cursor = conn.cursor()\n",
|
||||||
|
"\n",
|
||||||
|
" cursor.execute(\"SELECT * FROM images\")\n",
|
||||||
|
" rows = cursor.fetchall()\n",
|
||||||
|
"\n",
|
||||||
|
" for _ in range(num_copies):\n",
|
||||||
|
" for row in rows:\n",
|
||||||
|
" new_row = list(row)\n",
|
||||||
|
" new_row[0] = str(uuid4()) # image_name is the first column\n",
|
||||||
|
" placeholders = \", \".join(\"?\" for _ in new_row)\n",
|
||||||
|
" cursor.execute(f\"INSERT INTO images VALUES ({placeholders})\", new_row)\n",
|
||||||
|
"\n",
|
||||||
|
" conn.commit()\n",
|
||||||
|
" conn.close()\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"if __name__ == \"__main__\":\n",
|
||||||
|
" database_path = Path(\"/home/bat/invokeai-4.0.0/databases/invokeai.db\")\n",
|
||||||
|
" num_copies = 50\n",
|
||||||
|
" duplicate_images(database_path, num_copies)"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": ".venv",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.10.12"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 2
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
import io
|
import io
|
||||||
import traceback
|
import traceback
|
||||||
from typing import Optional
|
from typing import Literal, Optional
|
||||||
|
|
||||||
from fastapi import BackgroundTasks, Body, HTTPException, Path, Query, Request, Response, UploadFile
|
from fastapi import BackgroundTasks, Body, HTTPException, Path, Query, Request, Response, UploadFile
|
||||||
from fastapi.responses import FileResponse
|
from fastapi.responses import FileResponse
|
||||||
@ -12,10 +12,11 @@ from invokeai.app.api.dependencies import ApiDependencies
|
|||||||
from invokeai.app.invocations.fields import MetadataField
|
from invokeai.app.invocations.fields import MetadataField
|
||||||
from invokeai.app.services.image_records.image_records_common import (
|
from invokeai.app.services.image_records.image_records_common import (
|
||||||
ImageCategory,
|
ImageCategory,
|
||||||
|
ImageRecord,
|
||||||
ImageRecordChanges,
|
ImageRecordChanges,
|
||||||
ResourceOrigin,
|
ResourceOrigin,
|
||||||
)
|
)
|
||||||
from invokeai.app.services.images.images_common import ImageDTO, ImageUrlsDTO
|
from invokeai.app.services.images.images_common import ImageDTO, ImageUrlsDTO, image_record_to_dto
|
||||||
from invokeai.app.services.shared.pagination import OffsetPaginatedResults
|
from invokeai.app.services.shared.pagination import OffsetPaginatedResults
|
||||||
from invokeai.app.services.shared.sqlite.sqlite_common import SQLiteDirection
|
from invokeai.app.services.shared.sqlite.sqlite_common import SQLiteDirection
|
||||||
|
|
||||||
@ -450,3 +451,76 @@ async def get_bulk_download_item(
|
|||||||
return response
|
return response
|
||||||
except Exception:
|
except Exception:
|
||||||
raise HTTPException(status_code=404)
|
raise HTTPException(status_code=404)
|
||||||
|
|
||||||
|
|
||||||
|
@images_router.get(
|
||||||
|
"/image_names",
|
||||||
|
operation_id="list_image_names",
|
||||||
|
response_model=list[str],
|
||||||
|
)
|
||||||
|
async def list_image_names(
|
||||||
|
board_id: str | None = Query(default=None),
|
||||||
|
category: Literal["images", "assets"] = Query(default="images"),
|
||||||
|
starred_first: bool = Query(default=True),
|
||||||
|
order_dir: SQLiteDirection = Query(default=SQLiteDirection.Descending),
|
||||||
|
search_term: Optional[str] = Query(default=None),
|
||||||
|
) -> list[str]:
|
||||||
|
"""Gets a list of image names"""
|
||||||
|
|
||||||
|
return ApiDependencies.invoker.services.image_records.get_image_names(
|
||||||
|
board_id,
|
||||||
|
category,
|
||||||
|
starred_first,
|
||||||
|
order_dir,
|
||||||
|
search_term,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@images_router.get(
|
||||||
|
"/images",
|
||||||
|
operation_id="list_images",
|
||||||
|
response_model=list[ImageRecord],
|
||||||
|
)
|
||||||
|
async def images(
|
||||||
|
board_id: str | None = Query(default=None),
|
||||||
|
category: Literal["images", "assets"] = Query(default="images"),
|
||||||
|
starred_first: bool = Query(default=True),
|
||||||
|
order_dir: SQLiteDirection = Query(default=SQLiteDirection.Descending),
|
||||||
|
search_term: str | None = Query(default=None),
|
||||||
|
from_image_name: str | None = Query(default=None),
|
||||||
|
count: int = Query(default=10),
|
||||||
|
) -> list[ImageRecord]:
|
||||||
|
"""Gets a list of image names"""
|
||||||
|
|
||||||
|
return ApiDependencies.invoker.services.image_records.get_images(
|
||||||
|
board_id,
|
||||||
|
category,
|
||||||
|
starred_first,
|
||||||
|
order_dir,
|
||||||
|
search_term,
|
||||||
|
from_image_name,
|
||||||
|
count,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@images_router.post(
|
||||||
|
"/images/by_name",
|
||||||
|
operation_id="get_images_by_name",
|
||||||
|
response_model=list[ImageDTO],
|
||||||
|
)
|
||||||
|
async def get_images_by_name(image_names: list[str] = Body(embed=True)) -> list[ImageDTO]:
|
||||||
|
"""Gets a list of image names"""
|
||||||
|
|
||||||
|
image_records = ApiDependencies.invoker.services.image_records.get_images_by_name(image_names)
|
||||||
|
|
||||||
|
image_dtos = [
|
||||||
|
image_record_to_dto(
|
||||||
|
image_record=r,
|
||||||
|
image_url=ApiDependencies.invoker.services.urls.get_image_url(r.image_name),
|
||||||
|
thumbnail_url=ApiDependencies.invoker.services.urls.get_image_url(r.image_name, True),
|
||||||
|
board_id=ApiDependencies.invoker.services.board_image_records.get_board_for_image(r.image_name),
|
||||||
|
)
|
||||||
|
for r in image_records
|
||||||
|
]
|
||||||
|
|
||||||
|
return image_dtos
|
||||||
|
@ -53,3 +53,8 @@ class BoardRecordStorageBase(ABC):
|
|||||||
def get_uncategorized_image_counts(self) -> UncategorizedImageCounts:
|
def get_uncategorized_image_counts(self) -> UncategorizedImageCounts:
|
||||||
"""Gets count of images and assets for uncategorized images (images with no board assocation)."""
|
"""Gets count of images and assets for uncategorized images (images with no board assocation)."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def get_uncategorized_image_names(self) -> list[str]:
|
||||||
|
"""Gets names of uncategorized images."""
|
||||||
|
pass
|
||||||
|
@ -300,3 +300,22 @@ class SqliteBoardRecordStorage(BoardRecordStorageBase):
|
|||||||
return UncategorizedImageCounts(image_count=image_count, asset_count=asset_count)
|
return UncategorizedImageCounts(image_count=image_count, asset_count=asset_count)
|
||||||
finally:
|
finally:
|
||||||
self._lock.release()
|
self._lock.release()
|
||||||
|
|
||||||
|
def get_uncategorized_image_names(self) -> list[str]:
|
||||||
|
try:
|
||||||
|
self._lock.acquire()
|
||||||
|
self._cursor.execute(
|
||||||
|
"""--sql
|
||||||
|
SELECT image_name
|
||||||
|
FROM images
|
||||||
|
WHERE image_name NOT IN (
|
||||||
|
SELECT image_name
|
||||||
|
FROM board_images
|
||||||
|
);
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
result = cast(list[sqlite3.Row], self._cursor.fetchall())
|
||||||
|
image_names = [r[0] for r in result]
|
||||||
|
return image_names
|
||||||
|
finally:
|
||||||
|
self._lock.release()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Optional
|
from typing import Literal, Optional
|
||||||
|
|
||||||
from invokeai.app.invocations.fields import MetadataField
|
from invokeai.app.invocations.fields import MetadataField
|
||||||
from invokeai.app.services.image_records.image_records_common import (
|
from invokeai.app.services.image_records.image_records_common import (
|
||||||
@ -97,3 +97,32 @@ class ImageRecordStorageBase(ABC):
|
|||||||
def get_most_recent_image_for_board(self, board_id: str) -> Optional[ImageRecord]:
|
def get_most_recent_image_for_board(self, board_id: str) -> Optional[ImageRecord]:
|
||||||
"""Gets the most recent image for a board."""
|
"""Gets the most recent image for a board."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def get_image_names(
|
||||||
|
self,
|
||||||
|
board_id: str | None,
|
||||||
|
category: Literal["images", "assets"],
|
||||||
|
starred_first: bool = True,
|
||||||
|
order_dir: SQLiteDirection = SQLiteDirection.Descending,
|
||||||
|
search_term: Optional[str] = None,
|
||||||
|
) -> list[str]:
|
||||||
|
"""Gets image names."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def get_images_by_name(self, image_names: list[str]) -> list[ImageRecord]:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def get_images(
|
||||||
|
self,
|
||||||
|
board_id: str | None = None,
|
||||||
|
category: Literal["images", "assets"] = "images",
|
||||||
|
starred_first: bool = True,
|
||||||
|
order_dir: SQLiteDirection = SQLiteDirection.Descending,
|
||||||
|
search_term: str | None = None,
|
||||||
|
from_image_name: str | None = None, # omit for first page
|
||||||
|
count: int = 10,
|
||||||
|
) -> list[ImageRecord]:
|
||||||
|
pass
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
import threading
|
import threading
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Optional, Union, cast
|
from typing import Literal, Optional, Union, cast
|
||||||
|
|
||||||
from invokeai.app.invocations.fields import MetadataField, MetadataFieldValidator
|
from invokeai.app.invocations.fields import MetadataField, MetadataFieldValidator
|
||||||
from invokeai.app.services.image_records.image_records_base import ImageRecordStorageBase
|
from invokeai.app.services.image_records.image_records_base import ImageRecordStorageBase
|
||||||
@ -140,6 +140,264 @@ class SqliteImageRecordStorage(ImageRecordStorageBase):
|
|||||||
finally:
|
finally:
|
||||||
self._lock.release()
|
self._lock.release()
|
||||||
|
|
||||||
|
# def get_image_names(
|
||||||
|
# self,
|
||||||
|
# board_id: str | None = None,
|
||||||
|
# category: Literal["images", "assets"] = "images",
|
||||||
|
# starred_first: bool = True,
|
||||||
|
# order_dir: SQLiteDirection = SQLiteDirection.Descending,
|
||||||
|
# search_term: Optional[str] = None,
|
||||||
|
# ) -> list[str]:
|
||||||
|
# try:
|
||||||
|
# self._lock.acquire()
|
||||||
|
|
||||||
|
# query = """
|
||||||
|
# SELECT images.image_name
|
||||||
|
# FROM images
|
||||||
|
# LEFT JOIN board_images ON board_images.image_name = images.image_name
|
||||||
|
# WHERE images.is_intermediate = FALSE
|
||||||
|
# """
|
||||||
|
# params: list[int | str | bool] = []
|
||||||
|
|
||||||
|
# if board_id:
|
||||||
|
# query += """
|
||||||
|
# AND board_images.board_id = ?
|
||||||
|
# """
|
||||||
|
# params.append(board_id)
|
||||||
|
# else:
|
||||||
|
# query += """
|
||||||
|
# AND board_images.board_id IS NULL
|
||||||
|
# """
|
||||||
|
|
||||||
|
# if category == "images":
|
||||||
|
# query += """
|
||||||
|
# AND images.image_category = 'general'
|
||||||
|
# """
|
||||||
|
# elif category == "assets":
|
||||||
|
# query += """
|
||||||
|
# AND images.image_category IN ('control', 'mask', 'user', 'other')
|
||||||
|
# """
|
||||||
|
# else:
|
||||||
|
# raise ValueError(f"Invalid category: {category}")
|
||||||
|
|
||||||
|
# if search_term:
|
||||||
|
# query += """
|
||||||
|
# AND images.metadata LIKE ?
|
||||||
|
# """
|
||||||
|
# params.append(f"%{search_term.lower()}%")
|
||||||
|
|
||||||
|
# if starred_first:
|
||||||
|
# query += f"""
|
||||||
|
# ORDER BY images.starred DESC, images.created_at {order_dir.value} -- cannot use parameter substitution here
|
||||||
|
# """
|
||||||
|
# else:
|
||||||
|
# query += f"""
|
||||||
|
# ORDER BY images.created_at {order_dir.value} -- cannot use parameter substitution here
|
||||||
|
# """
|
||||||
|
|
||||||
|
# query += ";"
|
||||||
|
# params_tuple = tuple(params)
|
||||||
|
|
||||||
|
# self._cursor.execute(query, params_tuple)
|
||||||
|
# result = cast(list[sqlite3.Row], self._cursor.fetchall())
|
||||||
|
# image_names = [str(r[0]) for r in result]
|
||||||
|
# except Exception:
|
||||||
|
# raise
|
||||||
|
# finally:
|
||||||
|
# self._lock.release()
|
||||||
|
|
||||||
|
# return image_names
|
||||||
|
|
||||||
|
def get_image_names(
|
||||||
|
self,
|
||||||
|
board_id: str | None = None,
|
||||||
|
category: Literal["images", "assets"] = "images",
|
||||||
|
starred_first: bool = True,
|
||||||
|
order_dir: SQLiteDirection = SQLiteDirection.Descending,
|
||||||
|
search_term: str | None = None,
|
||||||
|
) -> list[str]:
|
||||||
|
try:
|
||||||
|
self._lock.acquire()
|
||||||
|
|
||||||
|
base_query = """
|
||||||
|
SELECT images.image_name
|
||||||
|
FROM images
|
||||||
|
LEFT JOIN board_images ON board_images.image_name = images.image_name
|
||||||
|
WHERE images.is_intermediate = FALSE
|
||||||
|
"""
|
||||||
|
params: list[int | str | bool] = []
|
||||||
|
|
||||||
|
if board_id:
|
||||||
|
base_query += """
|
||||||
|
AND board_images.board_id = ?
|
||||||
|
"""
|
||||||
|
params.append(board_id)
|
||||||
|
else:
|
||||||
|
base_query += """
|
||||||
|
AND board_images.board_id IS NULL
|
||||||
|
"""
|
||||||
|
|
||||||
|
if category == "images":
|
||||||
|
base_query += """
|
||||||
|
AND images.image_category = 'general'
|
||||||
|
"""
|
||||||
|
elif category == "assets":
|
||||||
|
base_query += """
|
||||||
|
AND images.image_category IN ('control', 'mask', 'user', 'other')
|
||||||
|
"""
|
||||||
|
else:
|
||||||
|
raise ValueError(f"Invalid category: {category}")
|
||||||
|
|
||||||
|
if search_term:
|
||||||
|
base_query += """
|
||||||
|
AND images.metadata LIKE ?
|
||||||
|
"""
|
||||||
|
params.append(f"%{search_term.lower()}%")
|
||||||
|
|
||||||
|
if starred_first:
|
||||||
|
base_query += f"""
|
||||||
|
ORDER BY images.starred DESC, images.created_at {order_dir.value}, images.image_name {order_dir.value}
|
||||||
|
"""
|
||||||
|
else:
|
||||||
|
base_query += f"""
|
||||||
|
ORDER BY images.created_at {order_dir.value}, images.image_name {order_dir.value}
|
||||||
|
"""
|
||||||
|
|
||||||
|
final_query = f"{base_query};"
|
||||||
|
|
||||||
|
self._cursor.execute(final_query, tuple(params))
|
||||||
|
result = cast(list[sqlite3.Row], self._cursor.fetchall())
|
||||||
|
images = [str(r[0]) for r in result]
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
raise
|
||||||
|
finally:
|
||||||
|
self._lock.release()
|
||||||
|
|
||||||
|
return images
|
||||||
|
|
||||||
|
def get_images_by_name(self, image_names: list[str]) -> list[ImageRecord]:
|
||||||
|
try:
|
||||||
|
self._lock.acquire()
|
||||||
|
|
||||||
|
query = f"""
|
||||||
|
SELECT {IMAGE_DTO_COLS}
|
||||||
|
FROM images
|
||||||
|
WHERE images.image_name in ({",".join("?" for _ in image_names)});
|
||||||
|
"""
|
||||||
|
params = tuple(image_names)
|
||||||
|
|
||||||
|
self._cursor.execute(query, tuple(params))
|
||||||
|
result = cast(list[sqlite3.Row], self._cursor.fetchall())
|
||||||
|
images = [deserialize_image_record(dict(r)) for r in result]
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
raise
|
||||||
|
finally:
|
||||||
|
self._lock.release()
|
||||||
|
|
||||||
|
return images
|
||||||
|
|
||||||
|
def get_images(
|
||||||
|
self,
|
||||||
|
board_id: str | None = None,
|
||||||
|
category: Literal["images", "assets"] = "images",
|
||||||
|
starred_first: bool = True,
|
||||||
|
order_dir: SQLiteDirection = SQLiteDirection.Descending,
|
||||||
|
search_term: str | None = None,
|
||||||
|
from_image_name: str | None = None, # omit for first page
|
||||||
|
count: int = 10,
|
||||||
|
) -> list[ImageRecord]:
|
||||||
|
try:
|
||||||
|
self._lock.acquire()
|
||||||
|
|
||||||
|
base_query = f"""
|
||||||
|
SELECT {IMAGE_DTO_COLS}
|
||||||
|
FROM images
|
||||||
|
LEFT JOIN board_images ON board_images.image_name = images.image_name
|
||||||
|
WHERE images.is_intermediate = FALSE
|
||||||
|
"""
|
||||||
|
params: list[int | str | bool] = []
|
||||||
|
|
||||||
|
if board_id:
|
||||||
|
base_query += """
|
||||||
|
AND board_images.board_id = ?
|
||||||
|
"""
|
||||||
|
params.append(board_id)
|
||||||
|
else:
|
||||||
|
base_query += """
|
||||||
|
AND board_images.board_id IS NULL
|
||||||
|
"""
|
||||||
|
|
||||||
|
if category == "images":
|
||||||
|
base_query += """
|
||||||
|
AND images.image_category = 'general'
|
||||||
|
"""
|
||||||
|
elif category == "assets":
|
||||||
|
base_query += """
|
||||||
|
AND images.image_category IN ('control', 'mask', 'user', 'other')
|
||||||
|
"""
|
||||||
|
else:
|
||||||
|
raise ValueError(f"Invalid category: {category}")
|
||||||
|
|
||||||
|
if search_term:
|
||||||
|
base_query += """
|
||||||
|
AND images.metadata LIKE ?
|
||||||
|
"""
|
||||||
|
params.append(f"%{search_term.lower()}%")
|
||||||
|
|
||||||
|
if from_image_name:
|
||||||
|
# Use keyset pagination to get the next page of results
|
||||||
|
|
||||||
|
keyset_query = f"""
|
||||||
|
WITH image_keyset AS (
|
||||||
|
SELECT created_at,
|
||||||
|
image_name
|
||||||
|
FROM images
|
||||||
|
WHERE image_name = ?
|
||||||
|
)
|
||||||
|
{base_query}
|
||||||
|
AND (images.created_at, images.image_name) < (
|
||||||
|
(
|
||||||
|
SELECT created_at
|
||||||
|
FROM image_keyset
|
||||||
|
),
|
||||||
|
(
|
||||||
|
SELECT image_name
|
||||||
|
FROM image_keyset
|
||||||
|
)
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
base_query = keyset_query
|
||||||
|
params.append(from_image_name)
|
||||||
|
|
||||||
|
if starred_first:
|
||||||
|
order_by_clause = f"""
|
||||||
|
ORDER BY images.starred DESC, images.created_at {order_dir.value}, images.image_name {order_dir.value}
|
||||||
|
"""
|
||||||
|
else:
|
||||||
|
order_by_clause = f"""
|
||||||
|
ORDER BY images.created_at {order_dir.value}, images.image_name {order_dir.value}
|
||||||
|
"""
|
||||||
|
|
||||||
|
final_query = f"""
|
||||||
|
{base_query}
|
||||||
|
{order_by_clause}
|
||||||
|
LIMIT ?;
|
||||||
|
"""
|
||||||
|
params.append(count)
|
||||||
|
|
||||||
|
self._cursor.execute(final_query, tuple(params))
|
||||||
|
result = cast(list[sqlite3.Row], self._cursor.fetchall())
|
||||||
|
images = [deserialize_image_record(dict(r)) for r in result]
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
raise
|
||||||
|
finally:
|
||||||
|
self._lock.release()
|
||||||
|
|
||||||
|
return images
|
||||||
|
|
||||||
def get_many(
|
def get_many(
|
||||||
self,
|
self,
|
||||||
offset: int = 0,
|
offset: int = 0,
|
||||||
|
59
invokeai/app/services/image_records/pagination notes.md
Normal file
59
invokeai/app/services/image_records/pagination notes.md
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
these ideas are trying to figure out the macOS photos UX where you use scroll position instead of page number to go to a specific range of images.
|
||||||
|
|
||||||
|
### Brute Force
|
||||||
|
|
||||||
|
Two new methods/endpoints:
|
||||||
|
|
||||||
|
- `get_image_names`: gets a list of ordered image names for the query params (e.g. board, starred_first)
|
||||||
|
- `get_images_by_name`: gets the dtos for a list of image names
|
||||||
|
|
||||||
|
Broad strokes of client handling:
|
||||||
|
|
||||||
|
- Fetch a list of all image names for a board.
|
||||||
|
- Render a big scroll area, large enough to hold all images. The list of image names is passed to `react-virtuoso` (virtualized list lib).
|
||||||
|
- As you scroll, we use the rangeChanged callback from `react-virtuoso`, which provides the indices of the currently-visible images in the list of all images. These indices map back to the list of image names from which we can derive the list of image names we need to fetch
|
||||||
|
- Debounce the rnageChanged callback
|
||||||
|
- Call the `get_images_by_name` endpoint with hte image names to fetch, use the result to update the `getImageDTO` query cache. De-duplicate the image_names against existing cache before fetching so we aren't requesting the smae data over and over
|
||||||
|
- Each item/image in the virtualized list fetches its image DTO from the cache _without initiating a network request_. it just kinda waits until the image is in the cache and then displays it
|
||||||
|
|
||||||
|
this is roughed out in this branch
|
||||||
|
|
||||||
|
#### FATAL FLAW
|
||||||
|
|
||||||
|
Once you generate an image, you want to do an optimistic update and insert its name into the big ol' image_names list right? well, where do you insert it? depends on the query parms that can affect the sort order and which images are shown... we only have the image names at this point so we can't easily figure out where to insert
|
||||||
|
|
||||||
|
workarounds (?):
|
||||||
|
|
||||||
|
- along with the image names, we retrieve `starred_first` and `created_at`. then from the query params we can easily figure out where to insert the new image into the list to match the sort that he backend will be doing. eh
|
||||||
|
- fetch `starred_first` images separately? so we don't have to worry about inserting the image into the right spot?
|
||||||
|
|
||||||
|
ahh but also metadata search... we won't know when to insert the image into the list if the user has a search term...
|
||||||
|
|
||||||
|
#### Sub-idea
|
||||||
|
|
||||||
|
Ok let's still use pagination but use virtuoso to tell us which page we are on.
|
||||||
|
|
||||||
|
virtuoso has an alternate mode where you just tell it how many items you have and it renders each item, passing only an index to it. Maybe we can derive the limit and offset from this information. here's an untested idea:
|
||||||
|
|
||||||
|
- pass virtuoso the board count
|
||||||
|
- Instead of rendering individual images in the list, we render pages (ranges) of images. The list library’s rangeChanged indices now refer to pages or ranges. To the user, it still looks like a bunch of individual images, but internally we group it into pages/ranges of whatever size.
|
||||||
|
- The page/range size is calculated via DOM, or we can rely on virtuoso to tell us how many items are to be rendered. only thing is it the number can different depending on scroll position, so we'd probably want to like take `endIndex - startIndex` as the limit, add 20% buffer to each end of the limit and round it to the nearest multiple of 5 or 10. that would give us a consistent limit
|
||||||
|
- then we can derive offset from that value
|
||||||
|
|
||||||
|
still has the issue where we aren't sure if we should trigger a image list cache invalidation...
|
||||||
|
|
||||||
|
### More Efficient Pagination
|
||||||
|
|
||||||
|
sql OFFSET requires a scan thru the whole table upt othe offset. that means the higher the offset, the slower the query. unsure of the practical impact of this, probably negligible for us right now.
|
||||||
|
|
||||||
|
I did some quick experiments with cursor/keyset pagination, using an image name as the cursor. this doesn't have the perf issue w/ offset.
|
||||||
|
|
||||||
|
Also! This kind of pagination is unaffected by insertions and deletions, which is a problem for limit/offset pagination. When you insert or delete an image, it doesn't shift images at higher pages down. I think this pagination strategy suits our gallery better than limit/offset, given how volatile it is with adding and removing images regularly.
|
||||||
|
|
||||||
|
see the `test_keyset` notebook for implementation (also some scattered methods in services as I was fiddling withh it)
|
||||||
|
|
||||||
|
may be some way to use this pagination strat in combination with the above ideas to more elegantly handle inserting and deleting images...
|
||||||
|
|
||||||
|
### Alternative approach to the whole "how do we know when to insert new images in the list (or invalidate the list cache)" issue
|
||||||
|
|
||||||
|
What if we _always_ invalidate the cache when youa re at the top of the list ,but never invalidate it when you have scrolled down?
|
210
invokeai/app/services/image_records/test_keyset.ipynb
Normal file
210
invokeai/app/services/image_records/test_keyset.ipynb
Normal file
@ -0,0 +1,210 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 8,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"first query\n",
|
||||||
|
"36e62fec-5c3a-4b28-867b-9029fb6d2319.png False\n",
|
||||||
|
"c7f4f4b8-7ce6-4594-abf6-3f5e13fb7fe9.png False\n",
|
||||||
|
"d8f57fda-5084-4d87-8668-06fb300282e4.png False\n",
|
||||||
|
"a2fd7b8b-bbe5-4629-9d46-000f99b64931.png False\n",
|
||||||
|
"c0880bc1-5f7a-452b-acea-53a261f4c0c4.png False\n",
|
||||||
|
"0ad957df-c341-48e3-b384-f656985c2722.png False\n",
|
||||||
|
"8c788d82-c81c-4ffe-bf6b-bdad601c5add.png False\n",
|
||||||
|
"9b1179a0-09a0-4430-918d-60b618ff040c.png False\n",
|
||||||
|
"c8ad6a32-75db-4d8b-a865-066365fa1563.png False\n",
|
||||||
|
"e5eb1c19-8c69-4d29-a447-fbc2d649334a.png False\n",
|
||||||
|
"\n",
|
||||||
|
"next query, starting from the second image\n",
|
||||||
|
"36e62fec-5c3a-4b28-867b-9029fb6d2319.png False\n",
|
||||||
|
"c7f4f4b8-7ce6-4594-abf6-3f5e13fb7fe9.png False\n",
|
||||||
|
"d8f57fda-5084-4d87-8668-06fb300282e4.png False\n",
|
||||||
|
"a2fd7b8b-bbe5-4629-9d46-000f99b64931.png False\n",
|
||||||
|
"c0880bc1-5f7a-452b-acea-53a261f4c0c4.png False\n",
|
||||||
|
"0ad957df-c341-48e3-b384-f656985c2722.png False\n",
|
||||||
|
"8c788d82-c81c-4ffe-bf6b-bdad601c5add.png False\n",
|
||||||
|
"9b1179a0-09a0-4430-918d-60b618ff040c.png False\n",
|
||||||
|
"c8ad6a32-75db-4d8b-a865-066365fa1563.png False\n",
|
||||||
|
"e5eb1c19-8c69-4d29-a447-fbc2d649334a.png False\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import sqlite3\n",
|
||||||
|
"from typing import Literal, cast\n",
|
||||||
|
"from invokeai.app.services.image_records.image_records_common import (\n",
|
||||||
|
" IMAGE_DTO_COLS,\n",
|
||||||
|
" ImageRecord,\n",
|
||||||
|
" deserialize_image_record,\n",
|
||||||
|
")\n",
|
||||||
|
"from invokeai.app.services.shared.sqlite.sqlite_common import SQLiteDirection\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"def get_images(\n",
|
||||||
|
" from_image_name: str | None = None, # omit for first page\n",
|
||||||
|
" count: int = 10,\n",
|
||||||
|
" board_id: str | None = None,\n",
|
||||||
|
" category: Literal[\"images\", \"assets\"] = \"images\",\n",
|
||||||
|
" starred_first: bool = False,\n",
|
||||||
|
" order_dir: SQLiteDirection = SQLiteDirection.Descending,\n",
|
||||||
|
" search_term: str | None = None,\n",
|
||||||
|
") -> list[ImageRecord]:\n",
|
||||||
|
" conn = sqlite3.connect(\"/home/bat/invokeai-4.0.0/databases/invokeai.db\")\n",
|
||||||
|
" conn.row_factory = sqlite3.Row\n",
|
||||||
|
" cursor = conn.cursor()\n",
|
||||||
|
"\n",
|
||||||
|
" base_query = f\"\"\"\n",
|
||||||
|
" SELECT {IMAGE_DTO_COLS}\n",
|
||||||
|
" FROM images\n",
|
||||||
|
" LEFT JOIN board_images ON board_images.image_name = images.image_name\n",
|
||||||
|
" WHERE images.is_intermediate = FALSE\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" params: list[int | str | bool] = []\n",
|
||||||
|
"\n",
|
||||||
|
" if board_id:\n",
|
||||||
|
" base_query += \"\"\"\n",
|
||||||
|
" AND board_images.board_id = ?\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" params.append(board_id)\n",
|
||||||
|
" else:\n",
|
||||||
|
" base_query += \"\"\"\n",
|
||||||
|
" AND board_images.board_id IS NULL\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
"\n",
|
||||||
|
" if category == \"images\":\n",
|
||||||
|
" base_query += \"\"\"\n",
|
||||||
|
" AND images.image_category = 'general'\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" elif category == \"assets\":\n",
|
||||||
|
" base_query += \"\"\"\n",
|
||||||
|
" AND images.image_category IN ('control', 'mask', 'user', 'other')\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" else:\n",
|
||||||
|
" raise ValueError(f\"Invalid category: {category}\")\n",
|
||||||
|
"\n",
|
||||||
|
" if search_term:\n",
|
||||||
|
" base_query += \"\"\"\n",
|
||||||
|
" AND images.metadata LIKE ?\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" params.append(f\"%{search_term.lower()}%\")\n",
|
||||||
|
"\n",
|
||||||
|
" if from_image_name:\n",
|
||||||
|
" # Use keyset pagination to get the next page of results\n",
|
||||||
|
"\n",
|
||||||
|
" # This uses `<` so that the cursor image is NOT included in the results - only images after it\n",
|
||||||
|
" if starred_first:\n",
|
||||||
|
" keyset_query = f\"\"\"\n",
|
||||||
|
" WITH image_keyset AS (\n",
|
||||||
|
" SELECT created_at,\n",
|
||||||
|
" image_name,\n",
|
||||||
|
" starred\n",
|
||||||
|
" FROM images\n",
|
||||||
|
" WHERE image_name = ?\n",
|
||||||
|
" )\n",
|
||||||
|
" {base_query}\n",
|
||||||
|
" AND (images.starred, images.created_at, images.image_name) < ((SELECT starred FROM image_keyset), (SELECT created_at FROM image_keyset), (SELECT image_name FROM image_keyset))\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" else:\n",
|
||||||
|
" keyset_query = f\"\"\"\n",
|
||||||
|
" WITH image_keyset AS (\n",
|
||||||
|
" SELECT created_at,\n",
|
||||||
|
" image_name\n",
|
||||||
|
" FROM images\n",
|
||||||
|
" WHERE image_name = ?\n",
|
||||||
|
" )\n",
|
||||||
|
" {base_query}\n",
|
||||||
|
" AND (images.created_at, images.image_name) < ((SELECT created_at FROM image_keyset), (SELECT image_name FROM image_keyset))\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
"\n",
|
||||||
|
" # This uses `<=` so that the cursor image IS included in the results\n",
|
||||||
|
" # if starred_first:\n",
|
||||||
|
" # keyset_query = f\"\"\"\n",
|
||||||
|
" # WITH image_keyset AS (\n",
|
||||||
|
" # SELECT created_at,\n",
|
||||||
|
" # image_name,\n",
|
||||||
|
" # starred\n",
|
||||||
|
" # FROM images\n",
|
||||||
|
" # WHERE image_name = ?\n",
|
||||||
|
" # )\n",
|
||||||
|
" # {base_query}\n",
|
||||||
|
" # AND (images.starred, images.created_at, images.image_name) <= ((SELECT starred FROM image_keyset), (SELECT created_at FROM image_keyset), (SELECT image_name FROM image_keyset))\n",
|
||||||
|
" # \"\"\"\n",
|
||||||
|
" # else:\n",
|
||||||
|
" # keyset_query = f\"\"\"\n",
|
||||||
|
" # WITH image_keyset AS (\n",
|
||||||
|
" # SELECT created_at,\n",
|
||||||
|
" # image_name\n",
|
||||||
|
" # FROM images\n",
|
||||||
|
" # WHERE image_name = ?\n",
|
||||||
|
" # )\n",
|
||||||
|
" # {base_query}\n",
|
||||||
|
" # AND (images.created_at, images.image_name) <= ((SELECT created_at FROM image_keyset), (SELECT image_name FROM image_keyset))\n",
|
||||||
|
" # \"\"\"\n",
|
||||||
|
" base_query = keyset_query\n",
|
||||||
|
" params.append(from_image_name)\n",
|
||||||
|
"\n",
|
||||||
|
" if starred_first:\n",
|
||||||
|
" order_by_clause = f\"\"\"\n",
|
||||||
|
" ORDER BY images.starred DESC, images.created_at {order_dir.value}, images.image_name {order_dir.value}\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" else:\n",
|
||||||
|
" order_by_clause = f\"\"\"\n",
|
||||||
|
" ORDER BY images.created_at {order_dir.value}, images.image_name {order_dir.value}\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
"\n",
|
||||||
|
" final_query = f\"\"\"\n",
|
||||||
|
" {base_query}\n",
|
||||||
|
" {order_by_clause}\n",
|
||||||
|
" LIMIT ?;\n",
|
||||||
|
" \"\"\"\n",
|
||||||
|
" params.append(count)\n",
|
||||||
|
"\n",
|
||||||
|
" cursor.execute(final_query, tuple(params))\n",
|
||||||
|
" result = cast(list[sqlite3.Row], cursor.fetchall())\n",
|
||||||
|
" images = [deserialize_image_record(dict(r)) for r in result]\n",
|
||||||
|
"\n",
|
||||||
|
" return images\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"kwargs = {\"starred_first\": False}\n",
|
||||||
|
"\n",
|
||||||
|
"images = get_images(**kwargs)\n",
|
||||||
|
"print(\"first query\")\n",
|
||||||
|
"for image in images:\n",
|
||||||
|
" print(image.image_name, image.starred)\n",
|
||||||
|
"\n",
|
||||||
|
"print(\"\\nnext query, starting from the second image\")\n",
|
||||||
|
"images_2 = get_images(from_image_name=images[0].image_name, **kwargs)\n",
|
||||||
|
"for image in images_2:\n",
|
||||||
|
" print(image.image_name, image.starred)"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": ".venv",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.10.12"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 2
|
||||||
|
}
|
@ -51,6 +51,16 @@ export const addInvocationCompleteEventListener = (startAppListening: AppStartLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!imageDTO.is_intermediate) {
|
if (!imageDTO.is_intermediate) {
|
||||||
|
console.log('maybe updating getImageNames');
|
||||||
|
dispatch(
|
||||||
|
imagesApi.util.updateQueryData('getImageNames', { starred_first: false }, (draft) => {
|
||||||
|
if (!draft.find((name) => name === imageDTO.image_name)) {
|
||||||
|
console.log('image not found, adding');
|
||||||
|
draft.unshift(imageDTO.image_name);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
dispatch(
|
dispatch(
|
||||||
imagesApi.util.invalidateTags([
|
imagesApi.util.invalidateTags([
|
||||||
{ type: 'Board', id: imageDTO.board_id ?? 'none' },
|
{ type: 'Board', id: imageDTO.board_id ?? 'none' },
|
||||||
|
@ -13,6 +13,7 @@ import {
|
|||||||
} from '@invoke-ai/ui-library';
|
} from '@invoke-ai/ui-library';
|
||||||
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
||||||
import { GalleryHeader } from 'features/gallery/components/GalleryHeader';
|
import { GalleryHeader } from 'features/gallery/components/GalleryHeader';
|
||||||
|
import { GalleryImageListExperiment } from 'features/gallery/components/ImageGrid/GalleryImageListExperiment';
|
||||||
import { galleryViewChanged } from 'features/gallery/store/gallerySlice';
|
import { galleryViewChanged } from 'features/gallery/store/gallerySlice';
|
||||||
import ResizeHandle from 'features/ui/components/tabs/ResizeHandle';
|
import ResizeHandle from 'features/ui/components/tabs/ResizeHandle';
|
||||||
import { usePanel, type UsePanelOptions } from 'features/ui/hooks/usePanel';
|
import { usePanel, type UsePanelOptions } from 'features/ui/hooks/usePanel';
|
||||||
@ -26,7 +27,6 @@ import { Panel, PanelGroup } from 'react-resizable-panels';
|
|||||||
import BoardsList from './Boards/BoardsList/BoardsList';
|
import BoardsList from './Boards/BoardsList/BoardsList';
|
||||||
import BoardsSearch from './Boards/BoardsList/BoardsSearch';
|
import BoardsSearch from './Boards/BoardsList/BoardsSearch';
|
||||||
import GallerySettingsPopover from './GallerySettingsPopover/GallerySettingsPopover';
|
import GallerySettingsPopover from './GallerySettingsPopover/GallerySettingsPopover';
|
||||||
import GalleryImageGrid from './ImageGrid/GalleryImageGrid';
|
|
||||||
import { GalleryPagination } from './ImageGrid/GalleryPagination';
|
import { GalleryPagination } from './ImageGrid/GalleryPagination';
|
||||||
import { GallerySearch } from './ImageGrid/GallerySearch';
|
import { GallerySearch } from './ImageGrid/GallerySearch';
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ const ImageGalleryContent = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
</Collapse>
|
</Collapse>
|
||||||
</Box>
|
</Box>
|
||||||
<GalleryImageGrid />
|
<GalleryImageListExperiment />
|
||||||
<GalleryPagination />
|
<GalleryPagination />
|
||||||
</Flex>
|
</Flex>
|
||||||
</Panel>
|
</Panel>
|
||||||
|
@ -0,0 +1,122 @@
|
|||||||
|
import { Box, Flex, Image, Skeleton, Text } from '@invoke-ai/ui-library';
|
||||||
|
import { useAppStore } from 'app/store/storeHooks';
|
||||||
|
import { overlayScrollbarsParams } from 'common/components/OverlayScrollbars/constants';
|
||||||
|
import { debounce } from 'lodash-es';
|
||||||
|
import { useOverlayScrollbars } from 'overlayscrollbars-react';
|
||||||
|
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
|
import type { ListRange } from 'react-virtuoso';
|
||||||
|
import { Virtuoso } from 'react-virtuoso';
|
||||||
|
import { imagesApi, useGetImageNamesQuery, useLazyGetImagesByNameQuery } from 'services/api/endpoints/images';
|
||||||
|
import type { ImageDTO } from 'services/api/types';
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
type TableVirtuosoScrollerRef = (ref: HTMLElement | Window | null) => any;
|
||||||
|
|
||||||
|
export const GalleryImageListExperiment = memo(() => {
|
||||||
|
const store = useAppStore();
|
||||||
|
const { data } = useGetImageNamesQuery({ starred_first: false });
|
||||||
|
const [getImagesByName] = useLazyGetImagesByNameQuery();
|
||||||
|
|
||||||
|
const itemContent = useCallback((index: number, data: string) => {
|
||||||
|
return <ListItem index={index} data={data} />;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const onRangeChanged = useCallback(
|
||||||
|
({ startIndex, endIndex }: ListRange) => {
|
||||||
|
// user has scrolled to a new range, fetch images that are not already in the store
|
||||||
|
console.log('rangeChanged', startIndex, endIndex);
|
||||||
|
|
||||||
|
// get the list of image names represented by this range
|
||||||
|
// endIndex must be +1 bc else we miss the last image
|
||||||
|
const imageNames = data?.slice(startIndex, endIndex + 1);
|
||||||
|
|
||||||
|
if (imageNames) {
|
||||||
|
// optimisation: we may have already loaded some of these images, so filter out the ones we already have
|
||||||
|
const imageNamesToFetch: string[] = [];
|
||||||
|
for (const name of imageNames) {
|
||||||
|
// check if we have this image cached already
|
||||||
|
const { data } = imagesApi.endpoints.getImageDTO.select(name)(store.getState());
|
||||||
|
if (!data) {
|
||||||
|
// nope, we need to fetch it
|
||||||
|
imageNamesToFetch.push(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log('imageNamesToFetch', imageNamesToFetch);
|
||||||
|
getImagesByName({ image_names: imageNamesToFetch });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[data, getImagesByName, store]
|
||||||
|
);
|
||||||
|
|
||||||
|
// debounce the onRangeChanged callback to avoid fetching images too frequently
|
||||||
|
const debouncedOnRangeChanged = useMemo(() => debounce(onRangeChanged, 300), [onRangeChanged]);
|
||||||
|
|
||||||
|
const rootRef = useRef<HTMLDivElement>(null);
|
||||||
|
const [scroller, setScroller] = useState<HTMLElement | null>(null);
|
||||||
|
const [initialize, osInstance] = useOverlayScrollbars(overlayScrollbarsParams);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const { current: root } = rootRef;
|
||||||
|
if (scroller && root) {
|
||||||
|
initialize({
|
||||||
|
target: root,
|
||||||
|
elements: {
|
||||||
|
viewport: scroller,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return () => osInstance()?.destroy();
|
||||||
|
}, [scroller, initialize, osInstance]);
|
||||||
|
|
||||||
|
if (!data) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box ref={rootRef} position="relative" w="full" h="full" mt={2}>
|
||||||
|
<Virtuoso
|
||||||
|
data={data}
|
||||||
|
itemContent={itemContent}
|
||||||
|
rangeChanged={debouncedOnRangeChanged}
|
||||||
|
// increases teh virual viewport by 200px in each direction, so we fetch a few more images than required
|
||||||
|
increaseViewportBy={200}
|
||||||
|
scrollerRef={setScroller as TableVirtuosoScrollerRef}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
GalleryImageListExperiment.displayName = 'GalleryImageListExperiment';
|
||||||
|
|
||||||
|
const useGetImageDTOCache = (imageName: string): ImageDTO | undefined => {
|
||||||
|
// get the image data for this image - useQueryState does not trigger a fetch
|
||||||
|
const { data, isUninitialized } = imagesApi.endpoints.getImageDTO.useQueryState(imageName);
|
||||||
|
// but we want this component to be a subscriber of the cache! that way, when this component unmounts, the query cache is automatically cleared
|
||||||
|
// useQuerySubscription allows us to subscribe, but by default it fetches the data immediately. using skip we can prevent that
|
||||||
|
// the result is we never fetch data for this image from this component, it only subscribes to the cache
|
||||||
|
// unfortunately this subcribe-to-cache-but-don't-fetch functionality is not built in to RTKQ.
|
||||||
|
imagesApi.endpoints.getImageDTO.useQuerySubscription(imageName, { skip: isUninitialized });
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
// the skeleton and real component need to be the same size else virtuoso will need to call rangeChanged multiples times to fill
|
||||||
|
const HEIGHT = 24;
|
||||||
|
|
||||||
|
const ListItem = ({ index, data }: { index: number; data: string }) => {
|
||||||
|
const imageDTO = useGetImageDTOCache(data);
|
||||||
|
|
||||||
|
if (!imageDTO) {
|
||||||
|
return <Skeleton w="full" h={HEIGHT} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Flex h={HEIGHT}>
|
||||||
|
<Image src={imageDTO.thumbnail_url} h="full" aspectRatio="1/1" />
|
||||||
|
<Flex flexDir="column">
|
||||||
|
<Text>{index}</Text>
|
||||||
|
<Text>{imageDTO.image_name}</Text>
|
||||||
|
</Flex>
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
|
};
|
@ -498,6 +498,33 @@ export const imagesApi = api.injectEndpoints({
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
getImageNames: build.query<
|
||||||
|
paths['/api/v1/images/image_names']['get']['responses']['200']['content']['application/json'],
|
||||||
|
paths['/api/v1/images/image_names']['get']['parameters']['query']
|
||||||
|
>({
|
||||||
|
query: (params) => ({
|
||||||
|
url: buildImagesUrl('image_names'),
|
||||||
|
method: 'GET',
|
||||||
|
params,
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
getImagesByName: build.query<
|
||||||
|
paths['/api/v1/images/images/by_name']['post']['responses']['200']['content']['application/json'],
|
||||||
|
paths['/api/v1/images/images/by_name']['post']['requestBody']['content']['application/json']
|
||||||
|
>({
|
||||||
|
query: (body) => ({
|
||||||
|
url: buildImagesUrl('images/by_name'),
|
||||||
|
method: 'POST',
|
||||||
|
body,
|
||||||
|
}),
|
||||||
|
onQueryStarted: (_, { dispatch, queryFulfilled }) => {
|
||||||
|
queryFulfilled.then(({ data }) => {
|
||||||
|
for (const imageDTO of data) {
|
||||||
|
dispatch(imagesApi.util.upsertQueryData('getImageDTO', imageDTO.image_name, imageDTO));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -519,6 +546,9 @@ export const {
|
|||||||
useStarImagesMutation,
|
useStarImagesMutation,
|
||||||
useUnstarImagesMutation,
|
useUnstarImagesMutation,
|
||||||
useBulkDownloadImagesMutation,
|
useBulkDownloadImagesMutation,
|
||||||
|
useGetImageNamesQuery,
|
||||||
|
useLazyGetImagesByNameQuery,
|
||||||
|
useLazyGetImageDTOQuery,
|
||||||
} = imagesApi;
|
} = imagesApi;
|
||||||
|
|
||||||
export const useGetImageDTOQuery = (...args: Parameters<typeof imagesApi.useGetImageDTOQuery>) => {
|
export const useGetImageDTOQuery = (...args: Parameters<typeof imagesApi.useGetImageDTOQuery>) => {
|
||||||
|
@ -297,6 +297,27 @@ export type paths = {
|
|||||||
*/
|
*/
|
||||||
get: operations["get_bulk_download_item"];
|
get: operations["get_bulk_download_item"];
|
||||||
};
|
};
|
||||||
|
"/api/v1/images/image_names": {
|
||||||
|
/**
|
||||||
|
* List Image Names
|
||||||
|
* @description Gets a list of image names
|
||||||
|
*/
|
||||||
|
get: operations["list_image_names"];
|
||||||
|
};
|
||||||
|
"/api/v1/images/images": {
|
||||||
|
/**
|
||||||
|
* Images
|
||||||
|
* @description Gets a list of image names
|
||||||
|
*/
|
||||||
|
get: operations["list_images"];
|
||||||
|
};
|
||||||
|
"/api/v1/images/images/by_name": {
|
||||||
|
/**
|
||||||
|
* Get Images By Name
|
||||||
|
* @description Gets a list of image names
|
||||||
|
*/
|
||||||
|
post: operations["get_images_by_name"];
|
||||||
|
};
|
||||||
"/api/v1/boards/": {
|
"/api/v1/boards/": {
|
||||||
/**
|
/**
|
||||||
* List Boards
|
* List Boards
|
||||||
@ -340,6 +361,13 @@ export type paths = {
|
|||||||
*/
|
*/
|
||||||
get: operations["get_uncategorized_image_counts"];
|
get: operations["get_uncategorized_image_counts"];
|
||||||
};
|
};
|
||||||
|
"/api/v1/boards/uncategorized/names": {
|
||||||
|
/**
|
||||||
|
* Get Uncategorized Image Names
|
||||||
|
* @description Gets count of images and assets for uncategorized images (images with no board assocation)
|
||||||
|
*/
|
||||||
|
get: operations["get_uncategorized_image_names"];
|
||||||
|
};
|
||||||
"/api/v1/board_images/": {
|
"/api/v1/board_images/": {
|
||||||
/**
|
/**
|
||||||
* Add Image To Board
|
* Add Image To Board
|
||||||
@ -1188,6 +1216,11 @@ export type components = {
|
|||||||
*/
|
*/
|
||||||
prepend?: boolean;
|
prepend?: boolean;
|
||||||
};
|
};
|
||||||
|
/** Body_get_images_by_name */
|
||||||
|
Body_get_images_by_name: {
|
||||||
|
/** Image Names */
|
||||||
|
image_names: string[];
|
||||||
|
};
|
||||||
/** Body_parse_dynamicprompts */
|
/** Body_parse_dynamicprompts */
|
||||||
Body_parse_dynamicprompts: {
|
Body_parse_dynamicprompts: {
|
||||||
/**
|
/**
|
||||||
@ -6388,6 +6421,71 @@ export type components = {
|
|||||||
*/
|
*/
|
||||||
type: "img_paste";
|
type: "img_paste";
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* ImageRecord
|
||||||
|
* @description Deserialized image record without metadata.
|
||||||
|
*/
|
||||||
|
ImageRecord: {
|
||||||
|
/**
|
||||||
|
* Image Name
|
||||||
|
* @description The unique name of the image.
|
||||||
|
*/
|
||||||
|
image_name: string;
|
||||||
|
/** @description The type of the image. */
|
||||||
|
image_origin: components["schemas"]["ResourceOrigin"];
|
||||||
|
/** @description The category of the image. */
|
||||||
|
image_category: components["schemas"]["ImageCategory"];
|
||||||
|
/**
|
||||||
|
* Width
|
||||||
|
* @description The width of the image in px.
|
||||||
|
*/
|
||||||
|
width: number;
|
||||||
|
/**
|
||||||
|
* Height
|
||||||
|
* @description The height of the image in px.
|
||||||
|
*/
|
||||||
|
height: number;
|
||||||
|
/**
|
||||||
|
* Created At
|
||||||
|
* @description The created timestamp of the image.
|
||||||
|
*/
|
||||||
|
created_at: string;
|
||||||
|
/**
|
||||||
|
* Updated At
|
||||||
|
* @description The updated timestamp of the image.
|
||||||
|
*/
|
||||||
|
updated_at: string;
|
||||||
|
/**
|
||||||
|
* Deleted At
|
||||||
|
* @description The deleted timestamp of the image.
|
||||||
|
*/
|
||||||
|
deleted_at?: string | null;
|
||||||
|
/**
|
||||||
|
* Is Intermediate
|
||||||
|
* @description Whether this is an intermediate image.
|
||||||
|
*/
|
||||||
|
is_intermediate: boolean;
|
||||||
|
/**
|
||||||
|
* Session Id
|
||||||
|
* @description The session ID that generated this image, if it is a generated image.
|
||||||
|
*/
|
||||||
|
session_id?: string | null;
|
||||||
|
/**
|
||||||
|
* Node Id
|
||||||
|
* @description The node ID that generated this image, if it is a generated image.
|
||||||
|
*/
|
||||||
|
node_id?: string | null;
|
||||||
|
/**
|
||||||
|
* Starred
|
||||||
|
* @description Whether this image is starred.
|
||||||
|
*/
|
||||||
|
starred: boolean;
|
||||||
|
/**
|
||||||
|
* Has Workflow
|
||||||
|
* @description Whether this image has a workflow.
|
||||||
|
*/
|
||||||
|
has_workflow: boolean;
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* ImageRecordChanges
|
* ImageRecordChanges
|
||||||
* @description A set of changes to apply to an image record.
|
* @description A set of changes to apply to an image record.
|
||||||
@ -6580,7 +6678,7 @@ export type components = {
|
|||||||
tiled?: boolean;
|
tiled?: boolean;
|
||||||
/**
|
/**
|
||||||
* Tile Size
|
* Tile Size
|
||||||
* @description The tile size for VAE tiling in pixels (image space). If set to 0, the default tile size for the
|
* @description The tile size for VAE tiling in pixels (image space). If set to 0, the default tile size for the model will be used. Larger tile sizes generally produce better results at the cost of higher memory usage.
|
||||||
* @default 0
|
* @default 0
|
||||||
*/
|
*/
|
||||||
tile_size?: number;
|
tile_size?: number;
|
||||||
@ -7316,145 +7414,145 @@ export type components = {
|
|||||||
project_id: string | null;
|
project_id: string | null;
|
||||||
};
|
};
|
||||||
InvocationOutputMap: {
|
InvocationOutputMap: {
|
||||||
img_channel_offset: components["schemas"]["ImageOutput"];
|
|
||||||
metadata: components["schemas"]["MetadataOutput"];
|
|
||||||
clip_skip: components["schemas"]["CLIPSkipInvocationOutput"];
|
|
||||||
canvas_paste_back: components["schemas"]["ImageOutput"];
|
|
||||||
seamless: components["schemas"]["SeamlessModeOutput"];
|
|
||||||
blank_image: components["schemas"]["ImageOutput"];
|
|
||||||
dynamic_prompt: components["schemas"]["StringCollectionOutput"];
|
|
||||||
step_param_easing: components["schemas"]["FloatCollectionOutput"];
|
|
||||||
latents_collection: components["schemas"]["LatentsCollectionOutput"];
|
|
||||||
normalbae_image_processor: components["schemas"]["ImageOutput"];
|
|
||||||
rand_float: components["schemas"]["FloatOutput"];
|
rand_float: components["schemas"]["FloatOutput"];
|
||||||
lora_loader: components["schemas"]["LoRALoaderOutput"];
|
latents: components["schemas"]["LatentsOutput"];
|
||||||
collect: components["schemas"]["CollectInvocationOutput"];
|
|
||||||
infill_rgba: components["schemas"]["ImageOutput"];
|
|
||||||
img_lerp: components["schemas"]["ImageOutput"];
|
|
||||||
integer_math: components["schemas"]["IntegerOutput"];
|
|
||||||
conditioning_collection: components["schemas"]["ConditioningCollectionOutput"];
|
|
||||||
mask_from_id: components["schemas"]["ImageOutput"];
|
|
||||||
mlsd_image_processor: components["schemas"]["ImageOutput"];
|
|
||||||
zoe_depth_image_processor: components["schemas"]["ImageOutput"];
|
|
||||||
ideal_size: components["schemas"]["IdealSizeOutput"];
|
|
||||||
conditioning: components["schemas"]["ConditioningOutput"];
|
|
||||||
img_resize: components["schemas"]["ImageOutput"];
|
|
||||||
integer_collection: components["schemas"]["IntegerCollectionOutput"];
|
|
||||||
float_range: components["schemas"]["FloatCollectionOutput"];
|
|
||||||
tile_to_properties: components["schemas"]["TileToPropertiesOutput"];
|
|
||||||
alpha_mask_to_tensor: components["schemas"]["MaskOutput"];
|
|
||||||
img_watermark: components["schemas"]["ImageOutput"];
|
|
||||||
merge_tiles_to_image: components["schemas"]["ImageOutput"];
|
|
||||||
merge_metadata: components["schemas"]["MetadataOutput"];
|
|
||||||
round_float: components["schemas"]["FloatOutput"];
|
|
||||||
denoise_latents: components["schemas"]["LatentsOutput"];
|
|
||||||
string_join_three: components["schemas"]["StringOutput"];
|
|
||||||
img_blur: components["schemas"]["ImageOutput"];
|
|
||||||
color_map_image_processor: components["schemas"]["ImageOutput"];
|
|
||||||
img_scale: components["schemas"]["ImageOutput"];
|
|
||||||
infill_tile: components["schemas"]["ImageOutput"];
|
|
||||||
add: components["schemas"]["IntegerOutput"];
|
|
||||||
img_paste: components["schemas"]["ImageOutput"];
|
|
||||||
img_crop: components["schemas"]["ImageOutput"];
|
|
||||||
cv_inpaint: components["schemas"]["ImageOutput"];
|
|
||||||
image_collection: components["schemas"]["ImageCollectionOutput"];
|
|
||||||
img_pad_crop: components["schemas"]["ImageOutput"];
|
|
||||||
canny_image_processor: components["schemas"]["ImageOutput"];
|
|
||||||
model_identifier: components["schemas"]["ModelIdentifierOutput"];
|
|
||||||
i2l: components["schemas"]["LatentsOutput"];
|
|
||||||
face_mask_detection: components["schemas"]["FaceMaskOutput"];
|
|
||||||
img_channel_multiply: components["schemas"]["ImageOutput"];
|
|
||||||
sdxl_model_loader: components["schemas"]["SDXLModelLoaderOutput"];
|
|
||||||
img_mul: components["schemas"]["ImageOutput"];
|
|
||||||
tomask: components["schemas"]["ImageOutput"];
|
|
||||||
image_mask_to_tensor: components["schemas"]["MaskOutput"];
|
|
||||||
face_identifier: components["schemas"]["ImageOutput"];
|
face_identifier: components["schemas"]["ImageOutput"];
|
||||||
noise: components["schemas"]["NoiseOutput"];
|
lscale: components["schemas"]["LatentsOutput"];
|
||||||
|
canny_image_processor: components["schemas"]["ImageOutput"];
|
||||||
|
dynamic_prompt: components["schemas"]["StringCollectionOutput"];
|
||||||
|
integer_math: components["schemas"]["IntegerOutput"];
|
||||||
|
esrgan: components["schemas"]["ImageOutput"];
|
||||||
|
lblend: components["schemas"]["LatentsOutput"];
|
||||||
|
t2i_adapter: components["schemas"]["T2IAdapterOutput"];
|
||||||
|
infill_tile: components["schemas"]["ImageOutput"];
|
||||||
|
img_resize: components["schemas"]["ImageOutput"];
|
||||||
|
string: components["schemas"]["StringOutput"];
|
||||||
|
img_channel_multiply: components["schemas"]["ImageOutput"];
|
||||||
|
ip_adapter: components["schemas"]["IPAdapterOutput"];
|
||||||
|
image: components["schemas"]["ImageOutput"];
|
||||||
|
alpha_mask_to_tensor: components["schemas"]["MaskOutput"];
|
||||||
|
round_float: components["schemas"]["FloatOutput"];
|
||||||
|
img_blur: components["schemas"]["ImageOutput"];
|
||||||
|
controlnet: components["schemas"]["ControlOutput"];
|
||||||
|
ideal_size: components["schemas"]["IdealSizeOutput"];
|
||||||
|
collect: components["schemas"]["CollectInvocationOutput"];
|
||||||
|
lora_selector: components["schemas"]["LoRASelectorOutput"];
|
||||||
l2i: components["schemas"]["ImageOutput"];
|
l2i: components["schemas"]["ImageOutput"];
|
||||||
|
tile_image_processor: components["schemas"]["ImageOutput"];
|
||||||
|
merge_metadata: components["schemas"]["MetadataOutput"];
|
||||||
|
img_scale: components["schemas"]["ImageOutput"];
|
||||||
|
dw_openpose_image_processor: components["schemas"]["ImageOutput"];
|
||||||
|
img_mul: components["schemas"]["ImageOutput"];
|
||||||
|
img_paste: components["schemas"]["ImageOutput"];
|
||||||
|
string_join_three: components["schemas"]["StringOutput"];
|
||||||
|
img_crop: components["schemas"]["ImageOutput"];
|
||||||
|
img_pad_crop: components["schemas"]["ImageOutput"];
|
||||||
|
lora_collection_loader: components["schemas"]["LoRALoaderOutput"];
|
||||||
|
vae_loader: components["schemas"]["VAEOutput"];
|
||||||
|
lineart_anime_image_processor: components["schemas"]["ImageOutput"];
|
||||||
|
tomask: components["schemas"]["ImageOutput"];
|
||||||
|
add: components["schemas"]["IntegerOutput"];
|
||||||
|
freeu: components["schemas"]["UNetOutput"];
|
||||||
|
pidi_image_processor: components["schemas"]["ImageOutput"];
|
||||||
|
color: components["schemas"]["ColorOutput"];
|
||||||
|
content_shuffle_image_processor: components["schemas"]["ImageOutput"];
|
||||||
|
heuristic_resize: components["schemas"]["ImageOutput"];
|
||||||
|
mediapipe_face_processor: components["schemas"]["ImageOutput"];
|
||||||
|
string_collection: components["schemas"]["StringCollectionOutput"];
|
||||||
|
image_mask_to_tensor: components["schemas"]["MaskOutput"];
|
||||||
|
show_image: components["schemas"]["ImageOutput"];
|
||||||
|
pair_tile_image: components["schemas"]["PairTileImageOutput"];
|
||||||
mul: components["schemas"]["IntegerOutput"];
|
mul: components["schemas"]["IntegerOutput"];
|
||||||
sub: components["schemas"]["IntegerOutput"];
|
sub: components["schemas"]["IntegerOutput"];
|
||||||
main_model_loader: components["schemas"]["ModelLoaderOutput"];
|
create_denoise_mask: components["schemas"]["DenoiseMaskOutput"];
|
||||||
controlnet: components["schemas"]["ControlOutput"];
|
create_gradient_mask: components["schemas"]["GradientMaskOutput"];
|
||||||
ip_adapter: components["schemas"]["IPAdapterOutput"];
|
|
||||||
lscale: components["schemas"]["LatentsOutput"];
|
|
||||||
sdxl_lora_collection_loader: components["schemas"]["SDXLLoRALoaderOutput"];
|
|
||||||
latents: components["schemas"]["LatentsOutput"];
|
|
||||||
string_split: components["schemas"]["String2Output"];
|
|
||||||
sdxl_refiner_compel_prompt: components["schemas"]["ConditioningOutput"];
|
|
||||||
esrgan: components["schemas"]["ImageOutput"];
|
|
||||||
dw_openpose_image_processor: components["schemas"]["ImageOutput"];
|
|
||||||
compel: components["schemas"]["ConditioningOutput"];
|
|
||||||
sdxl_lora_loader: components["schemas"]["SDXLLoRALoaderOutput"];
|
|
||||||
sdxl_compel_prompt: components["schemas"]["ConditioningOutput"];
|
|
||||||
tile_image_processor: components["schemas"]["ImageOutput"];
|
|
||||||
mediapipe_face_processor: components["schemas"]["ImageOutput"];
|
|
||||||
metadata_item: components["schemas"]["MetadataItemOutput"];
|
|
||||||
float_math: components["schemas"]["FloatOutput"];
|
|
||||||
prompt_from_file: components["schemas"]["StringCollectionOutput"];
|
|
||||||
pidi_image_processor: components["schemas"]["ImageOutput"];
|
|
||||||
content_shuffle_image_processor: components["schemas"]["ImageOutput"];
|
|
||||||
lineart_anime_image_processor: components["schemas"]["ImageOutput"];
|
|
||||||
t2i_adapter: components["schemas"]["T2IAdapterOutput"];
|
|
||||||
integer: components["schemas"]["IntegerOutput"];
|
|
||||||
unsharp_mask: components["schemas"]["ImageOutput"];
|
|
||||||
range: components["schemas"]["IntegerCollectionOutput"];
|
|
||||||
string: components["schemas"]["StringOutput"];
|
|
||||||
show_image: components["schemas"]["ImageOutput"];
|
|
||||||
image: components["schemas"]["ImageOutput"];
|
|
||||||
heuristic_resize: components["schemas"]["ImageOutput"];
|
|
||||||
div: components["schemas"]["IntegerOutput"];
|
|
||||||
rand_int: components["schemas"]["IntegerOutput"];
|
|
||||||
float: components["schemas"]["FloatOutput"];
|
|
||||||
img_conv: components["schemas"]["ImageOutput"];
|
|
||||||
mask_combine: components["schemas"]["ImageOutput"];
|
|
||||||
random_range: components["schemas"]["IntegerCollectionOutput"];
|
|
||||||
boolean_collection: components["schemas"]["BooleanCollectionOutput"];
|
|
||||||
pair_tile_image: components["schemas"]["PairTileImageOutput"];
|
|
||||||
save_image: components["schemas"]["ImageOutput"];
|
|
||||||
lora_selector: components["schemas"]["LoRASelectorOutput"];
|
|
||||||
boolean: components["schemas"]["BooleanOutput"];
|
|
||||||
tiled_multi_diffusion_denoise_latents: components["schemas"]["LatentsOutput"];
|
|
||||||
rectangle_mask: components["schemas"]["MaskOutput"];
|
|
||||||
lineart_image_processor: components["schemas"]["ImageOutput"];
|
lineart_image_processor: components["schemas"]["ImageOutput"];
|
||||||
midas_depth_image_processor: components["schemas"]["ImageOutput"];
|
midas_depth_image_processor: components["schemas"]["ImageOutput"];
|
||||||
|
integer_collection: components["schemas"]["IntegerCollectionOutput"];
|
||||||
|
depth_anything_image_processor: components["schemas"]["ImageOutput"];
|
||||||
|
float_collection: components["schemas"]["FloatCollectionOutput"];
|
||||||
|
mask_combine: components["schemas"]["ImageOutput"];
|
||||||
|
sdxl_compel_prompt: components["schemas"]["ConditioningOutput"];
|
||||||
|
sdxl_refiner_compel_prompt: components["schemas"]["ConditioningOutput"];
|
||||||
|
sdxl_refiner_model_loader: components["schemas"]["SDXLRefinerModelLoaderOutput"];
|
||||||
|
save_image: components["schemas"]["ImageOutput"];
|
||||||
|
string_split: components["schemas"]["String2Output"];
|
||||||
|
float_math: components["schemas"]["FloatOutput"];
|
||||||
|
unsharp_mask: components["schemas"]["ImageOutput"];
|
||||||
|
seamless: components["schemas"]["SeamlessModeOutput"];
|
||||||
|
compel: components["schemas"]["ConditioningOutput"];
|
||||||
|
calculate_image_tiles_min_overlap: components["schemas"]["CalculateImageTilesOutput"];
|
||||||
|
scheduler: components["schemas"]["SchedulerOutput"];
|
||||||
|
calculate_image_tiles_even_split: components["schemas"]["CalculateImageTilesOutput"];
|
||||||
|
leres_image_processor: components["schemas"]["ImageOutput"];
|
||||||
|
img_conv: components["schemas"]["ImageOutput"];
|
||||||
|
metadata_item: components["schemas"]["MetadataItemOutput"];
|
||||||
|
hed_image_processor: components["schemas"]["ImageOutput"];
|
||||||
|
calculate_image_tiles: components["schemas"]["CalculateImageTilesOutput"];
|
||||||
img_nsfw: components["schemas"]["ImageOutput"];
|
img_nsfw: components["schemas"]["ImageOutput"];
|
||||||
|
face_off: components["schemas"]["FaceOffOutput"];
|
||||||
|
div: components["schemas"]["IntegerOutput"];
|
||||||
|
range: components["schemas"]["IntegerCollectionOutput"];
|
||||||
infill_patchmatch: components["schemas"]["ImageOutput"];
|
infill_patchmatch: components["schemas"]["ImageOutput"];
|
||||||
infill_lama: components["schemas"]["ImageOutput"];
|
infill_lama: components["schemas"]["ImageOutput"];
|
||||||
infill_cv2: components["schemas"]["ImageOutput"];
|
infill_cv2: components["schemas"]["ImageOutput"];
|
||||||
float_to_int: components["schemas"]["IntegerOutput"];
|
latents_collection: components["schemas"]["LatentsCollectionOutput"];
|
||||||
color: components["schemas"]["ColorOutput"];
|
rand_int: components["schemas"]["IntegerOutput"];
|
||||||
lora_collection_loader: components["schemas"]["LoRALoaderOutput"];
|
noise: components["schemas"]["NoiseOutput"];
|
||||||
vae_loader: components["schemas"]["VAEOutput"];
|
|
||||||
string_split_neg: components["schemas"]["StringPosNegOutput"];
|
|
||||||
lresize: components["schemas"]["LatentsOutput"];
|
|
||||||
string_collection: components["schemas"]["StringCollectionOutput"];
|
|
||||||
invert_tensor_mask: components["schemas"]["MaskOutput"];
|
|
||||||
depth_anything_image_processor: components["schemas"]["ImageOutput"];
|
|
||||||
hed_image_processor: components["schemas"]["ImageOutput"];
|
|
||||||
leres_image_processor: components["schemas"]["ImageOutput"];
|
|
||||||
img_ilerp: components["schemas"]["ImageOutput"];
|
|
||||||
freeu: components["schemas"]["UNetOutput"];
|
|
||||||
mask_edge: components["schemas"]["ImageOutput"];
|
mask_edge: components["schemas"]["ImageOutput"];
|
||||||
string_join: components["schemas"]["StringOutput"];
|
|
||||||
img_hue_adjust: components["schemas"]["ImageOutput"];
|
|
||||||
color_correct: components["schemas"]["ImageOutput"];
|
color_correct: components["schemas"]["ImageOutput"];
|
||||||
calculate_image_tiles_min_overlap: components["schemas"]["CalculateImageTilesOutput"];
|
img_hue_adjust: components["schemas"]["ImageOutput"];
|
||||||
img_chan: components["schemas"]["ImageOutput"];
|
|
||||||
calculate_image_tiles_even_split: components["schemas"]["CalculateImageTilesOutput"];
|
|
||||||
create_denoise_mask: components["schemas"]["DenoiseMaskOutput"];
|
|
||||||
lblend: components["schemas"]["LatentsOutput"];
|
|
||||||
crop_latents: components["schemas"]["LatentsOutput"];
|
crop_latents: components["schemas"]["LatentsOutput"];
|
||||||
|
segment_anything_processor: components["schemas"]["ImageOutput"];
|
||||||
|
img_ilerp: components["schemas"]["ImageOutput"];
|
||||||
|
conditioning_collection: components["schemas"]["ConditioningCollectionOutput"];
|
||||||
|
lresize: components["schemas"]["LatentsOutput"];
|
||||||
|
random_range: components["schemas"]["IntegerCollectionOutput"];
|
||||||
|
conditioning: components["schemas"]["ConditioningOutput"];
|
||||||
|
rectangle_mask: components["schemas"]["MaskOutput"];
|
||||||
|
img_chan: components["schemas"]["ImageOutput"];
|
||||||
|
prompt_from_file: components["schemas"]["StringCollectionOutput"];
|
||||||
|
float_range: components["schemas"]["FloatCollectionOutput"];
|
||||||
|
float_to_int: components["schemas"]["IntegerOutput"];
|
||||||
|
invert_tensor_mask: components["schemas"]["MaskOutput"];
|
||||||
|
img_channel_offset: components["schemas"]["ImageOutput"];
|
||||||
|
string_split_neg: components["schemas"]["StringPosNegOutput"];
|
||||||
|
normalbae_image_processor: components["schemas"]["ImageOutput"];
|
||||||
|
image_collection: components["schemas"]["ImageCollectionOutput"];
|
||||||
|
blank_image: components["schemas"]["ImageOutput"];
|
||||||
|
string_join: components["schemas"]["StringOutput"];
|
||||||
|
model_identifier: components["schemas"]["ModelIdentifierOutput"];
|
||||||
|
canvas_paste_back: components["schemas"]["ImageOutput"];
|
||||||
|
i2l: components["schemas"]["LatentsOutput"];
|
||||||
|
tile_to_properties: components["schemas"]["TileToPropertiesOutput"];
|
||||||
|
denoise_latents: components["schemas"]["LatentsOutput"];
|
||||||
|
lora_loader: components["schemas"]["LoRALoaderOutput"];
|
||||||
|
merge_tiles_to_image: components["schemas"]["ImageOutput"];
|
||||||
|
mlsd_image_processor: components["schemas"]["ImageOutput"];
|
||||||
|
integer: components["schemas"]["IntegerOutput"];
|
||||||
|
cv_inpaint: components["schemas"]["ImageOutput"];
|
||||||
string_replace: components["schemas"]["StringOutput"];
|
string_replace: components["schemas"]["StringOutput"];
|
||||||
range_of_size: components["schemas"]["IntegerCollectionOutput"];
|
range_of_size: components["schemas"]["IntegerCollectionOutput"];
|
||||||
calculate_image_tiles: components["schemas"]["CalculateImageTilesOutput"];
|
zoe_depth_image_processor: components["schemas"]["ImageOutput"];
|
||||||
iterate: components["schemas"]["IterateInvocationOutput"];
|
sdxl_model_loader: components["schemas"]["SDXLModelLoaderOutput"];
|
||||||
create_gradient_mask: components["schemas"]["GradientMaskOutput"];
|
color_map_image_processor: components["schemas"]["ImageOutput"];
|
||||||
face_off: components["schemas"]["FaceOffOutput"];
|
mask_from_id: components["schemas"]["ImageOutput"];
|
||||||
sdxl_refiner_model_loader: components["schemas"]["SDXLRefinerModelLoaderOutput"];
|
infill_rgba: components["schemas"]["ImageOutput"];
|
||||||
scheduler: components["schemas"]["SchedulerOutput"];
|
main_model_loader: components["schemas"]["ModelLoaderOutput"];
|
||||||
float_collection: components["schemas"]["FloatCollectionOutput"];
|
float: components["schemas"]["FloatOutput"];
|
||||||
|
tiled_multi_diffusion_denoise_latents: components["schemas"]["LatentsOutput"];
|
||||||
core_metadata: components["schemas"]["MetadataOutput"];
|
core_metadata: components["schemas"]["MetadataOutput"];
|
||||||
segment_anything_processor: components["schemas"]["ImageOutput"];
|
boolean_collection: components["schemas"]["BooleanCollectionOutput"];
|
||||||
|
iterate: components["schemas"]["IterateInvocationOutput"];
|
||||||
|
sdxl_lora_collection_loader: components["schemas"]["SDXLLoRALoaderOutput"];
|
||||||
|
step_param_easing: components["schemas"]["FloatCollectionOutput"];
|
||||||
|
img_lerp: components["schemas"]["ImageOutput"];
|
||||||
|
clip_skip: components["schemas"]["CLIPSkipInvocationOutput"];
|
||||||
|
boolean: components["schemas"]["BooleanOutput"];
|
||||||
|
img_watermark: components["schemas"]["ImageOutput"];
|
||||||
|
sdxl_lora_loader: components["schemas"]["SDXLLoRALoaderOutput"];
|
||||||
|
face_mask_detection: components["schemas"]["FaceMaskOutput"];
|
||||||
|
metadata: components["schemas"]["MetadataOutput"];
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* InvocationStartedEvent
|
* InvocationStartedEvent
|
||||||
@ -7794,7 +7892,7 @@ export type components = {
|
|||||||
tiled?: boolean;
|
tiled?: boolean;
|
||||||
/**
|
/**
|
||||||
* Tile Size
|
* Tile Size
|
||||||
* @description The tile size for VAE tiling in pixels (image space). If set to 0, the default tile size for the
|
* @description The tile size for VAE tiling in pixels (image space). If set to 0, the default tile size for the model will be used. Larger tile sizes generally produce better results at the cost of higher memory usage.
|
||||||
* @default 0
|
* @default 0
|
||||||
*/
|
*/
|
||||||
tile_size?: number;
|
tile_size?: number;
|
||||||
@ -15015,6 +15113,91 @@ export type operations = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* List Image Names
|
||||||
|
* @description Gets a list of image names
|
||||||
|
*/
|
||||||
|
list_image_names: {
|
||||||
|
parameters: {
|
||||||
|
query?: {
|
||||||
|
board_id?: string | null;
|
||||||
|
category?: "images" | "assets";
|
||||||
|
starred_first?: boolean;
|
||||||
|
order_dir?: components["schemas"]["SQLiteDirection"];
|
||||||
|
search_term?: string | null;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
responses: {
|
||||||
|
/** @description Successful Response */
|
||||||
|
200: {
|
||||||
|
content: {
|
||||||
|
"application/json": string[];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/** @description Validation Error */
|
||||||
|
422: {
|
||||||
|
content: {
|
||||||
|
"application/json": components["schemas"]["HTTPValidationError"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Images
|
||||||
|
* @description Gets a list of image names
|
||||||
|
*/
|
||||||
|
list_images: {
|
||||||
|
parameters: {
|
||||||
|
query?: {
|
||||||
|
board_id?: string | null;
|
||||||
|
category?: "images" | "assets";
|
||||||
|
starred_first?: boolean;
|
||||||
|
order_dir?: components["schemas"]["SQLiteDirection"];
|
||||||
|
search_term?: string | null;
|
||||||
|
from_image_name?: string | null;
|
||||||
|
count?: number;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
responses: {
|
||||||
|
/** @description Successful Response */
|
||||||
|
200: {
|
||||||
|
content: {
|
||||||
|
"application/json": components["schemas"]["ImageRecord"][];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/** @description Validation Error */
|
||||||
|
422: {
|
||||||
|
content: {
|
||||||
|
"application/json": components["schemas"]["HTTPValidationError"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Get Images By Name
|
||||||
|
* @description Gets a list of image names
|
||||||
|
*/
|
||||||
|
get_images_by_name: {
|
||||||
|
requestBody: {
|
||||||
|
content: {
|
||||||
|
"application/json": components["schemas"]["Body_get_images_by_name"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
responses: {
|
||||||
|
/** @description Successful Response */
|
||||||
|
200: {
|
||||||
|
content: {
|
||||||
|
"application/json": components["schemas"]["ImageDTO"][];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/** @description Validation Error */
|
||||||
|
422: {
|
||||||
|
content: {
|
||||||
|
"application/json": components["schemas"]["HTTPValidationError"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* List Boards
|
* List Boards
|
||||||
* @description Gets a list of boards
|
* @description Gets a list of boards
|
||||||
@ -15202,6 +15385,20 @@ export type operations = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* Get Uncategorized Image Names
|
||||||
|
* @description Gets count of images and assets for uncategorized images (images with no board assocation)
|
||||||
|
*/
|
||||||
|
get_uncategorized_image_names: {
|
||||||
|
responses: {
|
||||||
|
/** @description Successful Response */
|
||||||
|
200: {
|
||||||
|
content: {
|
||||||
|
"application/json": string[];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* Add Image To Board
|
* Add Image To Board
|
||||||
* @description Creates a board_image
|
* @description Creates a board_image
|
||||||
|
Loading…
Reference in New Issue
Block a user