diff --git a/invokeai/app/services/style_preset_records/default_style_presets.json b/invokeai/app/services/style_preset_records/default_style_presets.json
new file mode 100644
index 0000000000..f661470c97
--- /dev/null
+++ b/invokeai/app/services/style_preset_records/default_style_presets.json
@@ -0,0 +1,16 @@
+[
+ {
+ "name": "Concept Art (Painterly)",
+ "preset_data": {
+ "positive_prompt": "{prompt} (digital painting)++, (textured 2d media)+++, depth and (painterly artwork)+++, intricate linework and brushwork, brush collection, highlights and shading, detail",
+ "negative_prompt": "photo++++ negative, faded, distorted, sketch, , flat+. anime, smooth+++"
+ }
+ },
+ {
+ "name": "Photography (Black and White)",
+ "preset_data": {
+ "positive_prompt": "(minimalist black and white photo)+++, (strong contrast)++, (clean textures)++, natural light, sharp focus, high detail, stark, dramatic, serene, simple composition, atmospheric, moody, refined, shadow play, 50mm lens, f/4",
+ "negative_prompt": "negative, blurry, faded, distorted, sketch, flat+. anime"
+ }
+ }
+]
diff --git a/invokeai/app/services/style_preset_records/style_preset_records_common.py b/invokeai/app/services/style_preset_records/style_preset_records_common.py
index a8dbcb7495..bed54c3b4b 100644
--- a/invokeai/app/services/style_preset_records/style_preset_records_common.py
+++ b/invokeai/app/services/style_preset_records/style_preset_records_common.py
@@ -23,11 +23,11 @@ class StylePresetChanges(BaseModel, extra="forbid"):
class StylePresetWithoutId(BaseModel):
name: str = Field(description="The name of the style preset.")
preset_data: PresetData = Field(description="The preset data")
+ is_default: Optional[bool] = Field(description="Whether or not the style preset is default", default=False)
class StylePresetRecordDTO(StylePresetWithoutId):
id: str = Field(description="The style preset ID.")
- is_default: bool = Field(description="Whether or not the style preset is default")
@classmethod
def from_dict(cls, data: dict[str, Any]) -> "StylePresetRecordDTO":
diff --git a/invokeai/app/services/style_preset_records/style_preset_records_sqlite.py b/invokeai/app/services/style_preset_records/style_preset_records_sqlite.py
index fbac06dcad..05675a0d6b 100644
--- a/invokeai/app/services/style_preset_records/style_preset_records_sqlite.py
+++ b/invokeai/app/services/style_preset_records/style_preset_records_sqlite.py
@@ -1,3 +1,5 @@
+import json
+from pathlib import Path
from invokeai.app.services.invoker import Invoker
from invokeai.app.services.shared.sqlite.sqlite_database import SqliteDatabase
from invokeai.app.services.style_preset_records.style_preset_records_base import StylePresetRecordsStorageBase
@@ -19,6 +21,7 @@ class SqliteStylePresetRecordsStorage(StylePresetRecordsStorageBase):
def start(self, invoker: Invoker) -> None:
self._invoker = invoker
+ self._sync_default_style_presets()
def get(self, id: str) -> StylePresetRecordDTO:
"""Gets a style preset by ID."""
@@ -51,15 +54,12 @@ class SqliteStylePresetRecordsStorage(StylePresetRecordsStorageBase):
INSERT OR IGNORE INTO style_presets (
id,
name,
- preset_data
+ preset_data,
+ is_default
)
- VALUES (?, ?, ?);
+ VALUES (?, ?, ?, ?);
""",
- (
- id,
- style_preset.name,
- style_preset.preset_data.model_dump_json(),
- ),
+ (id, style_preset.name, style_preset.preset_data.model_dump_json(), style_preset.is_default),
)
self._conn.commit()
except Exception:
@@ -142,3 +142,30 @@ class SqliteStylePresetRecordsStorage(StylePresetRecordsStorageBase):
raise
finally:
self._lock.release()
+
+ def _sync_default_style_presets(self) -> None:
+ """Syncs default style presets to the database. Internal use only."""
+
+ try:
+ self._lock.acquire()
+ self._cursor.execute(
+ """--sql
+ DELETE FROM style_presets
+ WHERE is_default = True;
+ """
+ )
+ try:
+ with open(Path(__file__).parent / Path("default_style_presets.json"), "r") as file:
+ presets: list[StylePresetWithoutId] = json.load(file)
+ for preset in presets:
+ style_preset = StylePresetWithoutId(is_default=True, **preset)
+ self.create(style_preset)
+ except Exception as e:
+ raise Exception()
+
+ self._conn.commit()
+ except Exception:
+ self._conn.rollback()
+ raise
+ finally:
+ self._lock.release()
diff --git a/invokeai/frontend/web/src/features/stylePresets/components/StylePresetListItem.tsx b/invokeai/frontend/web/src/features/stylePresets/components/StylePresetListItem.tsx
index d6baf543b2..d4919644ea 100644
--- a/invokeai/frontend/web/src/features/stylePresets/components/StylePresetListItem.tsx
+++ b/invokeai/frontend/web/src/features/stylePresets/components/StylePresetListItem.tsx
@@ -110,23 +110,25 @@ export const StylePresetListItem = ({ preset }: { preset: StylePresetRecordWithI
)}
-
- }
- />
- }
- />
-
+ {!preset.is_default && (
+
+ }
+ />
+ }
+ />
+
+ )}