Upgrading the RS Styles Loader node

This commit is contained in:
Raykosan
2026-07-20 22:45:56 +03:00
parent a713ca10d5
commit 062dc5bb30
6 changed files with 1184 additions and 83 deletions
+194
View File
@@ -24,6 +24,8 @@ logger = logging.getLogger(__name__)
class RaykoStylesCSVLoader:
STYLES_FOLDER = "styles"
FAVORITES_FILE = "favorites.json"
PRESETS_SUBFOLDER = "presets"
@classmethod
def get_node_dir(cls) -> str:
@@ -33,6 +35,14 @@ class RaykoStylesCSVLoader:
def get_styles_folder_path(cls) -> str:
return os.path.join(cls.get_node_dir(), cls.STYLES_FOLDER)
@classmethod
def get_favorites_path(cls) -> str:
return os.path.join(cls.get_styles_folder_path(), cls.FAVORITES_FILE)
@classmethod
def get_presets_folder_path(cls) -> str:
return os.path.join(cls.get_styles_folder_path(), cls.PRESETS_SUBFOLDER)
@classmethod
def get_available_style_files(cls) -> List[str]:
styles_folder = cls.get_styles_folder_path()
@@ -113,6 +123,96 @@ class RaykoStylesCSVLoader:
return ("", "")
@classmethod
def load_favorites(cls) -> Dict[str, List[Dict[str, str]]]:
favorites_path = cls.get_favorites_path()
if not os.path.exists(favorites_path):
return {}
try:
with open(favorites_path, "r", encoding="utf-8") as f:
data = json.load(f)
if isinstance(data, dict):
return data
return {}
except Exception as e:
logger.error(f"Error loading favorites: {str(e)}")
return {}
@classmethod
def save_favorites(cls, favorites: Dict[str, List[Dict[str, str]]]) -> bool:
favorites_path = cls.get_favorites_path()
styles_folder = cls.get_styles_folder_path()
try:
os.makedirs(styles_folder, exist_ok=True)
with open(favorites_path, "w", encoding="utf-8") as f:
json.dump(favorites, f, ensure_ascii=False, indent=2)
return True
except Exception as e:
logger.error(f"Error saving favorites: {str(e)}")
return False
@classmethod
def list_presets(cls) -> List[str]:
presets_folder = cls.get_presets_folder_path()
if not os.path.exists(presets_folder):
return []
try:
presets = [
f[:-5] for f in os.listdir(presets_folder)
if f.endswith('.json')
]
return sorted(presets, key=lambda x: x.lower())
except Exception as e:
logger.error(f"Error listing presets: {str(e)}")
return []
@classmethod
def save_preset(cls, name: str, preset_data: Dict) -> bool:
presets_folder = cls.get_presets_folder_path()
try:
os.makedirs(presets_folder, exist_ok=True)
filepath = os.path.join(presets_folder, f"{name}.json")
with open(filepath, "w", encoding="utf-8") as f:
json.dump(preset_data, f, ensure_ascii=False, indent=2)
return True
except Exception as e:
logger.error(f"Error saving preset: {str(e)}")
return False
@classmethod
def load_preset(cls, name: str) -> Optional[Dict]:
presets_folder = cls.get_presets_folder_path()
filepath = os.path.join(presets_folder, f"{name}.json")
if not os.path.exists(filepath):
return None
try:
with open(filepath, "r", encoding="utf-8") as f:
return json.load(f)
except Exception as e:
logger.error(f"Error loading preset: {str(e)}")
return None
@classmethod
def delete_preset(cls, name: str) -> bool:
presets_folder = cls.get_presets_folder_path()
filepath = os.path.join(presets_folder, f"{name}.json")
if not os.path.exists(filepath):
return False
try:
os.remove(filepath)
return True
except Exception as e:
logger.error(f"Error deleting preset: {str(e)}")
return False
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
return {
@@ -267,6 +367,100 @@ class RaykoServer:
except Exception as e:
logger.error(f"Error loading styles: {e}")
return web.json_response({'error': str(e)}, status=500)
@server.PromptServer.instance.routes.get("/rayko_get_favorites")
async def get_favorites(request):
try:
favorites = RaykoStylesCSVLoader.load_favorites()
return web.json_response(favorites)
except Exception as e:
logger.error(f"Error getting favorites: {e}")
return web.json_response({"error": str(e)}, status=500)
@server.PromptServer.instance.routes.post("/rayko_save_favorites")
async def save_favorites(request):
try:
data = await request.json()
if not isinstance(data, dict):
return web.json_response({'error': 'Invalid data format'}, status=400)
success = RaykoStylesCSVLoader.save_favorites(data)
if success:
return web.json_response({'success': True})
else:
return web.json_response({'error': 'Failed to save favorites'}, status=500)
except Exception as e:
logger.error(f"Error saving favorites: {e}")
return web.json_response({'error': str(e)}, status=500)
@server.PromptServer.instance.routes.get("/rayko_get_presets")
async def get_presets(request):
try:
presets = RaykoStylesCSVLoader.list_presets()
return web.json_response(presets)
except Exception as e:
logger.error(f"Error getting presets: {e}")
return web.json_response({"error": str(e)}, status=500)
@server.PromptServer.instance.routes.post("/rayko_save_preset")
async def save_preset(request):
try:
data = await request.json()
name = data.get("name", "").strip()
if not name:
return web.json_response({'error': 'Name required'}, status=400)
name = "".join(c for c in name if c.isalnum() or c in " _-").strip()
if not name:
return web.json_response({'error': 'Invalid name'}, status=400)
preset_data = {
"csv_file": data.get("csv_file", ""),
"styles": data.get("styles", [])
}
success = RaykoStylesCSVLoader.save_preset(name, preset_data)
if success:
return web.json_response({'success': True})
else:
return web.json_response({'error': 'Failed to save preset'}, status=500)
except Exception as e:
logger.error(f"Error saving preset: {e}")
return web.json_response({'error': str(e)}, status=500)
@server.PromptServer.instance.routes.post("/rayko_load_preset")
async def load_preset(request):
try:
data = await request.json()
name = data.get("name")
if not name:
return web.json_response({'error': 'Name required'}, status=400)
preset = RaykoStylesCSVLoader.load_preset(name)
if preset:
return web.json_response(preset)
else:
return web.json_response({'error': 'Preset not found'}, status=404)
except Exception as e:
logger.error(f"Error loading preset: {e}")
return web.json_response({'error': str(e)}, status=500)
@server.PromptServer.instance.routes.post("/rayko_delete_preset")
async def delete_preset(request):
try:
data = await request.json()
name = data.get("name")
if not name:
return web.json_response({'error': 'Name required'}, status=400)
success = RaykoStylesCSVLoader.delete_preset(name)
if success:
return web.json_response({'success': True})
else:
return web.json_response({'error': 'Preset not found'}, status=404)
except Exception as e:
logger.error(f"Error deleting preset: {e}")
return web.json_response({'error': str(e)}, status=500)
except Exception as e:
logger.error(f"Failed to register server routes: {e}")
+1 -1
View File
@@ -29,7 +29,7 @@ IGNORED_MODULES: Set[str] = {'__init__.py'}
REQUIRED_MODULES: Set[str] = set()
PACKAGE_DISPLAY_NAME = "ComfyUI_RaykoStudio"
__version__ = "0.29.1"
__version__ = "0.30.0"
def load_modules():
print(f"🦊 {PACKAGE_DISPLAY_NAME}: Version: {__version__}")
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "ComfyUI_RaykoStudio",
"version": "0.29.1",
"version": "0.30.0",
"description": "Set of custom nodes for ComfyUI providing additional image processing capabilities",
"author": "Raykosan",
"license": "Apache License 2.0",
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "ComfyUI_RaykoStudio"
description = "Set of custom nodes for ComfyUI providing additional image processing capabilities"
version = "0.29.1"
version = "0.30.0"
license = { file = "LICENSE" }
dependencies = ["torch", "numpy", "Pillow>=10.0.0", "freetype-py>=2.5.1", "pycairo>=1.29.0", "scipy>=1.10.0"]
+3 -3
View File
@@ -18,11 +18,11 @@ No Style,,
"Style | 3D model","professional 3d model {prompt} . octane render, highly detailed, volumetric, dramatic lighting","ugly, deformed, noisy, low poly, blurry, painting",""
"Style | Pixel art","pixel-art {prompt} . low-res, blocky, pixel art style, 8-bit graphics","sloppy, messy, blurry, noisy, highly detailed, ultra textured, photo, realistic",""
"Style | Line close-up texture","texture {prompt} top down close-up","ugly, deformed, noisy, blurry",""
"Style | Fooocus enhanced,{prompt}","(worst quality, low quality, normal quality, lowres, low details, oversaturated, undersaturated, overexposed, underexposed, grayscale, bw, bad photo, bad photography, bad art:1.4), (watermark, signature, text font, username, error, logo, words, letters, digits, autograph, trademark, name:1.2), (blur, blurry, grainy), morbid, ugly, asymmetrical, mutated malformed, mutilated, poorly lit, bad shadow, draft, cropped, out of frame, cut off, censored, jpeg artifacts, out of focus, glitch, duplicate, (airbrushed, cartoon, anime, semi-realistic, cgi, render, blender, digital art, manga, amateur:1.3), (3D ,3D Game, 3D Game Scene, 3D Character:1.1), (bad hands, bad anatomy, bad body, bad face, bad teeth, bad arms, bad legs, deformities:1.3)",""
"Style | Fooocus enhanced","{prompt},(worst quality, low quality, normal quality, lowres, low details, oversaturated, undersaturated, overexposed, underexposed, grayscale, bw, bad photo, bad photography, bad art:1.4), (watermark, signature, text font, username, error, logo, words, letters, digits, autograph, trademark, name:1.2), (blur, blurry, grainy), morbid, ugly, asymmetrical, mutated malformed, mutilated, poorly lit, bad shadow, draft, cropped, out of frame, cut off, censored, jpeg artifacts, out of focus, glitch, duplicate, (airbrushed, cartoon, anime, semi-realistic, cgi, render, blender, digital art, manga, amateur:1.3), (3D ,3D Game, 3D Game Scene, 3D Character:1.1), (bad hands, bad anatomy, bad body, bad face, bad teeth, bad arms, bad legs, deformities:1.3)",""
"Style | Fooocus clear","cinematic still {prompt} . emotional, harmonious, vignette, 4k epic detailed, shot on kodak, 35mm photo, sharp focus, high budget, cinemascope, moody, epic, gorgeous, film grain, grainy","anime, cartoon, graphic, (blur, blurry, bokeh), text, painting, crayon, graphite, abstract, glitch, deformed, mutated, ugly, disfigured",""
"Style | Fooocus masterpiece,(masterpiece), (best quality), (ultra-detailed), {prompt}, illustration, disheveled hair, detailed eyes, perfect composition, moist skin, intricate details, earrings, by wlop","longbody, lowres, bad anatomy, bad hands, missing fingers, pubic hair,extra digit, fewer digits, cropped, worst quality, low quality",""
"Style | Fooocus masterpiece","(masterpiece), (best quality), (ultra-detailed), {prompt}, illustration, disheveled hair, detailed eyes, perfect composition, moist skin, intricate details, earrings, by wlop","longbody, lowres, bad anatomy, bad hands, missing fingers, pubic hair,extra digit, fewer digits, cropped, worst quality, low quality",""
"Style | Fooocus photo","photograph {prompt}, 50mm . cinematic 4k epic detailed 4k epic detailed photograph shot on kodak detailed cinematic hbo dark moody, 35mm photo, grainy, vignette, vintage, Kodachrome, Lomography, stained, highly detailed, found footage","Brad Pitt, bokeh, depth of field, blurry, cropped, regular face, saturated, contrast, deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime, text, cropped, out of frame, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck",""
"Style | Fooocus negative prompt,{prompt}","deformed, bad anatomy, disfigured, poorly drawn face, mutated, extra limb, ugly, poorly drawn hands, missing limb, floating limbs, disconnected limbs, disconnected head, malformed hands, long neck, mutated hands and fingers, bad hands, missing fingers, cropped, worst quality, low quality, mutation, poorly drawn, huge calf, bad hands, fused hand, missing hand, disappearing arms, disappearing thigh, disappearing calf, disappearing legs, missing fingers, fused fingers, abnormal eye proportion, Abnormal hands, abnormal legs, abnormal feet, abnormal fingers, drawing, painting, crayon, sketch, graphite, impressionist, noisy, blurry, soft, deformed, ugly, anime, cartoon, graphic, text, painting, crayon, graphite, abstract, glitch",""
"Style | Fooocus negative prompt","{prompt},deformed, bad anatomy, disfigured, poorly drawn face, mutated, extra limb, ugly, poorly drawn hands, missing limb, floating limbs, disconnected limbs, disconnected head, malformed hands, long neck, mutated hands and fingers, bad hands, missing fingers, cropped, worst quality, low quality, mutation, poorly drawn, huge calf, bad hands, fused hand, missing hand, disappearing arms, disappearing thigh, disappearing calf, disappearing legs, missing fingers, fused fingers, abnormal eye proportion, Abnormal hands, abnormal legs, abnormal feet, abnormal fingers, drawing, painting, crayon, sketch, graphite, impressionist, noisy, blurry, soft, deformed, ugly, anime, cartoon, graphic, text, painting, crayon, graphite, abstract, glitch",""
"Style | Fooocus movie","cinematic still {prompt} . emotional, harmonious, vignette, highly detailed, high budget, bokeh, cinemascope, moody, epic, gorgeous, film grain, grainy","anime, cartoon, graphic, text, painting, crayon, graphite, abstract, glitch, deformed, mutated, ugly, disfigured",""
||| SDXL COMFYUI PORT ,,
"Style | Advertising","Advertising poster style {prompt} . Professional, modern, product-focused, commercial, eye-catching, highly detailed","noisy, blurry, amateurish, sloppy, unattractive",""
1 name prompt negative_prompt
18 Style | 3D model professional 3d model {prompt} . octane render, highly detailed, volumetric, dramatic lighting ugly, deformed, noisy, low poly, blurry, painting
19 Style | Pixel art pixel-art {prompt} . low-res, blocky, pixel art style, 8-bit graphics sloppy, messy, blurry, noisy, highly detailed, ultra textured, photo, realistic
20 Style | Line close-up texture texture {prompt} top down close-up ugly, deformed, noisy, blurry
21 Style | Fooocus enhanced,{prompt} Style | Fooocus enhanced (worst quality, low quality, normal quality, lowres, low details, oversaturated, undersaturated, overexposed, underexposed, grayscale, bw, bad photo, bad photography, bad art:1.4), (watermark, signature, text font, username, error, logo, words, letters, digits, autograph, trademark, name:1.2), (blur, blurry, grainy), morbid, ugly, asymmetrical, mutated malformed, mutilated, poorly lit, bad shadow, draft, cropped, out of frame, cut off, censored, jpeg artifacts, out of focus, glitch, duplicate, (airbrushed, cartoon, anime, semi-realistic, cgi, render, blender, digital art, manga, amateur:1.3), (3D ,3D Game, 3D Game Scene, 3D Character:1.1), (bad hands, bad anatomy, bad body, bad face, bad teeth, bad arms, bad legs, deformities:1.3) {prompt},(worst quality, low quality, normal quality, lowres, low details, oversaturated, undersaturated, overexposed, underexposed, grayscale, bw, bad photo, bad photography, bad art:1.4), (watermark, signature, text font, username, error, logo, words, letters, digits, autograph, trademark, name:1.2), (blur, blurry, grainy), morbid, ugly, asymmetrical, mutated malformed, mutilated, poorly lit, bad shadow, draft, cropped, out of frame, cut off, censored, jpeg artifacts, out of focus, glitch, duplicate, (airbrushed, cartoon, anime, semi-realistic, cgi, render, blender, digital art, manga, amateur:1.3), (3D ,3D Game, 3D Game Scene, 3D Character:1.1), (bad hands, bad anatomy, bad body, bad face, bad teeth, bad arms, bad legs, deformities:1.3)
22 Style | Fooocus clear cinematic still {prompt} . emotional, harmonious, vignette, 4k epic detailed, shot on kodak, 35mm photo, sharp focus, high budget, cinemascope, moody, epic, gorgeous, film grain, grainy anime, cartoon, graphic, (blur, blurry, bokeh), text, painting, crayon, graphite, abstract, glitch, deformed, mutated, ugly, disfigured
23 Style | Fooocus masterpiece,(masterpiece), (best quality), (ultra-detailed), {prompt}, illustration, disheveled hair, detailed eyes, perfect composition, moist skin, intricate details, earrings, by wlop Style | Fooocus masterpiece longbody, lowres, bad anatomy, bad hands, missing fingers, pubic hair,extra digit, fewer digits, cropped, worst quality, low quality (masterpiece), (best quality), (ultra-detailed), {prompt}, illustration, disheveled hair, detailed eyes, perfect composition, moist skin, intricate details, earrings, by wlop longbody, lowres, bad anatomy, bad hands, missing fingers, pubic hair,extra digit, fewer digits, cropped, worst quality, low quality
24 Style | Fooocus photo photograph {prompt}, 50mm . cinematic 4k epic detailed 4k epic detailed photograph shot on kodak detailed cinematic hbo dark moody, 35mm photo, grainy, vignette, vintage, Kodachrome, Lomography, stained, highly detailed, found footage Brad Pitt, bokeh, depth of field, blurry, cropped, regular face, saturated, contrast, deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime, text, cropped, out of frame, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck
25 Style | Fooocus negative prompt,{prompt} Style | Fooocus negative prompt deformed, bad anatomy, disfigured, poorly drawn face, mutated, extra limb, ugly, poorly drawn hands, missing limb, floating limbs, disconnected limbs, disconnected head, malformed hands, long neck, mutated hands and fingers, bad hands, missing fingers, cropped, worst quality, low quality, mutation, poorly drawn, huge calf, bad hands, fused hand, missing hand, disappearing arms, disappearing thigh, disappearing calf, disappearing legs, missing fingers, fused fingers, abnormal eye proportion, Abnormal hands, abnormal legs, abnormal feet, abnormal fingers, drawing, painting, crayon, sketch, graphite, impressionist, noisy, blurry, soft, deformed, ugly, anime, cartoon, graphic, text, painting, crayon, graphite, abstract, glitch {prompt},deformed, bad anatomy, disfigured, poorly drawn face, mutated, extra limb, ugly, poorly drawn hands, missing limb, floating limbs, disconnected limbs, disconnected head, malformed hands, long neck, mutated hands and fingers, bad hands, missing fingers, cropped, worst quality, low quality, mutation, poorly drawn, huge calf, bad hands, fused hand, missing hand, disappearing arms, disappearing thigh, disappearing calf, disappearing legs, missing fingers, fused fingers, abnormal eye proportion, Abnormal hands, abnormal legs, abnormal feet, abnormal fingers, drawing, painting, crayon, sketch, graphite, impressionist, noisy, blurry, soft, deformed, ugly, anime, cartoon, graphic, text, painting, crayon, graphite, abstract, glitch
26 Style | Fooocus movie cinematic still {prompt} . emotional, harmonious, vignette, highly detailed, high budget, bokeh, cinemascope, moody, epic, gorgeous, film grain, grainy anime, cartoon, graphic, text, painting, crayon, graphite, abstract, glitch, deformed, mutated, ugly, disfigured
27 ||| SDXL COMFYUI PORT
28 Style | Advertising Advertising poster style {prompt} . Professional, modern, product-focused, commercial, eye-catching, highly detailed noisy, blurry, amateurish, sloppy, unattractive
+984 -77
View File
File diff suppressed because it is too large Load Diff