Skip to content

Commit

Permalink
Remove SAG pipeline support because it is fucking shit
Browse files Browse the repository at this point in the history
Signed-off-by: bghira <bghira@users.github.com>
  • Loading branch information
bghira committed Apr 22, 2023
1 parent c515b0c commit 887559d
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 89 deletions.
2 changes: 0 additions & 2 deletions discord_tron_master/classes/app_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@
"strength": 0.5,
"resize": 1,
"guidance_scaling": 7.5,
"sag_scale": 0.75,
"seed": None,
"enable_sag": False,
"model": "theintuitiveye/HARDblend",
"negative_prompt": "(child, teen) (malformed, malignant)",
"positive_prompt": "(beautiful, unreal engine 5, highly detailed, hyperrealistic)",
Expand Down
36 changes: 0 additions & 36 deletions discord_tron_master/cogs/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ async def model_list(self, ctx):
def build_transformer_output(transformer):
cluster = f"{transformer.model_owner}/{transformer.model_id}: {transformer.description}\n" \
f"!model {transformer.model_owner}/{transformer.model_id}\n"
if transformer.sag_capable: \
cluster = cluster + f"SAG capable: {transformer.sag_capable}\n"
return cluster

def split_into_chunks(text_lines: List[str], max_length: int = 2000) -> List[str]:
Expand Down Expand Up @@ -110,40 +108,6 @@ async def model_delete(self, ctx, full_model_name: str):
logging.error(f"Could not delete model: {e}")
await ctx.send(f"Sorry bae, could not delete that model for you. Have you tried using more lube? {e}")

@commands.command(name="model-sag", help="Toggle whether a model is fully compatible with SAG pipeline. Not available to non-admins.")
async def model_sag(self, ctx, full_model_name: str):
# Is the user in the Image Admin role?
app = AppConfig.flask
is_admin = await self.is_admin(ctx)
if not is_admin:
await ctx.send("sory bae, u must be admuin 😭😭😭 u rek me inside in the worst waysz")
return
try:
with app.app_context():
transformers = Transformers()
new_transformer = transformers.toggle_sag_mode_requirement(full_model_name)
await ctx.send(f"The model '{full_model_name}' is now {'compatible' if new_transformer.sag_capable else 'incompatible'} with SAG pipeline.")
except Exception as e:
logging.error(f"Could not toggle model SAG configuration status: {e}")
await ctx.send(f"Could not toggle model SAG configuration status? {e}")

@commands.command(name="model-sag-aspect", help="Set the aspect ratio for a SAG pipeline on a given model. Not available to non-admins.")
async def model_sag_aspect(self, ctx, full_model_name: str, aspect_ratio: str):
# Is the user in the Image Admin role?
app = AppConfig.flask
is_admin = await self.is_admin(ctx)
if not is_admin:
await ctx.send("sory bae, u must be admuin 😭😭😭 u rek me inside in the worst waysz")
return
try:
with app.app_context():
transformers = Transformers()
new_transformer = transformers.set_model_aspect(full_model_name, 'sag', aspect_ratio)
await ctx.send(f"The model '{full_model_name}' is now using aspect ratio '{aspect_ratio}' for SAG pipeline.")
except Exception as e:
logging.error(f"Could not set model aspect ratio for SAG pipeline: {e}")
await ctx.send(f"Could not set model aspect ratio for SAG pipeline? {e}")

@commands.command(name="model-add", help="Add a model to the list for approval.")
async def model_add(self, ctx, full_model_name: str, model_type: str, *, description):
app = AppConfig.flask
Expand Down
25 changes: 1 addition & 24 deletions discord_tron_master/cogs/user/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ async def my_settings(self, ctx, *args):
model_id = user_config.get("model")
steps = self.config.get_user_setting(user_id, "steps")
strength = self.config.get_user_setting(user_id, "strength")
sag_scale = self.config.get_user_setting(user_id, "sag_scale")
guidance_scaling = self.config.get_user_setting(user_id, "guidance_scaling")
enable_sag = self.config.get_user_setting(user_id, "enable_sag")

seed = self.config.get_user_setting(user_id, "seed", None)
if seed == -1:
Expand Down Expand Up @@ -95,9 +93,8 @@ async def my_settings(self, ctx, *args):
f"🟠 **Model ID**: `{model_id}`\n❓ Change using **{self.config.get_command_prefix()}model [model]**, out of the list from **{self.config.get_command_prefix()}model-list**\n"
f"🟠 **Seed**: `{seed}` **Default**: `None`\n❓ When None, it defaults to the current timestamp at the time of image generation. Can be used to reproduce images.\n"
f"🟠 **Steps**: `{steps}` **Default**: `100`\n❓ This represents how many denoising iterations the model will do on your image. Less is more.\n"
f"🟠 **Scaling**: guidance: `{guidance_scaling}` **Default**: `7.5`, **SAG**: {sag_scale} **Default**: `0.75`\n❓ How closely the image follows the prompt. Below 1 = no prompts.\n"
f"🟠 **Scaling**: guidance: `{guidance_scaling}` **Default**: `7.5`\n❓ How closely the image follows the prompt. Below 1 = no prompts apply.\n"
f"🟠 **Strength**: `{strength}` **Default**: `0.5`\n❓ The higher the strength, the more random the img2img becomes. Lower values become more deterministic.\n"
f"🟠 **Self-Assisted Guidance (SAG)**: `{enable_sag}` **Default**: `False`\n❓ Use SAG scaling to make higher quality images. Requires a square aspect ratio on non-SAG models.\n"
f"🟠 **Negative Prompt:**:\n➡️ `{negative_prompt}`\n❓ Images featuring these keywords are less likely to be generated. Set via `{self.config.get_command_prefix()}negative`.\n"
f"🟠 **Positive Prompt:**:\n➡️ `{positive_prompt}`\n❓ Added to the end of every prompt, which has a limit of 77 tokens. This can become truncated. Set via `{self.config.get_command_prefix()}positive`.\n"
f"🟠 **GPT Role:**:\n➡️ `{gpt_role}`\n❓ Defines how this bot will respond to you when chatting. Use `{self.config.get_command_prefix()}settings gpt_role [new role]`.\n"
Expand All @@ -112,26 +109,6 @@ async def my_settings(self, ctx, *args):
await ctx.delete()
await self.send_large_message(ctx, message)

@commands.command(name="sag", help="Enable or disable self-assisted guidance pipeline that uses a self-reference routine to improve image quality. Default is True.")
async def toggle_sag(self, ctx):
user_id = ctx.author.id
enable_sag = config.get_user_setting(user_id, "enable_sag")
try:
if enable_sag:
config.set_user_setting(user_id, "enable_sag", False)
response = await ctx.send(
f"{ctx.author.mention} Self-assisted guidance has been disabled. Did you know {random_fact()}?"
)
else:
config.set_user_setting(user_id, "enable_sag", True)
response = await ctx.send(
f"{ctx.author.mention} Self-assisted guidance has been enabled. You're welcome."
)
await ctx.delete(delay=15)
await response.delete(delay=15)
except Exception as e:
logging.error("Caught error when toggling user SAG property: " + str(e))

@commands.command(name="steps", help="Set the number of steps for the image generation process. Default is 100.")
async def set_steps(self, ctx, steps):
user_id = ctx.author.id
Expand Down
27 changes: 0 additions & 27 deletions discord_tron_master/models/transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ class Transformers(db.Model):
model_owner = db.Column(db.String(255), unique=False, nullable=False)
model_id = db.Column(db.String(255), unique=True, nullable=False)
model_type = db.Column(db.String(16), nullable=False)
preferred_ar = db.Column(db.String(4))
description = db.Column(db.String(255), nullable=True)
recommended_positive = db.Column(db.String(255), nullable=True)
recommended_negative = db.Column(db.String(255), nullable=True)
approved = db.Column(db.Boolean, default=False)
added_by = db.Column(db.String(255), nullable=False)
tags = db.Column(db.String(255), nullable=True)
config_blob = db.Column(db.Text(), nullable=True)
sag_capable = db.Column(db.Boolean, default=False)

@staticmethod
def get_all():
Expand All @@ -35,30 +33,6 @@ def delete_all_unapproved():
db.session.delete(transformer)
db.session.commit()

@staticmethod
def toggle_sag_mode_requirement(model_id):
model_id = model_id.split('/')[1]
existing_definition = Transformers.query.filter_by(model_id=model_id).first()
if existing_definition is not None:
if existing_definition.sag_capable and existing_definition.sag_cable is not None:
existing_definition.sag_capable = False
else:
existing_definition.sag_capable = True
db.session.commit()
return existing_definition

@staticmethod
def set_model_aspect(model_id, type: str = 'enforced', aspect: str = '16:9'):
model_id = model_id.split('/')[1]
existing_definition = Transformers.query.filter_by(model_id=model_id).first()
if existing_definition is not None:
if type == 'enforced':
existing_definition.enforced_ar = aspect
elif type == 'preferred':
existing_definition.preferred_ar = aspect
db.session.commit()
return existing_definition

@staticmethod
def get_all_by_model_type(model_type):
return Transformers.query.filter_by(model_type=model_type).all()
Expand Down Expand Up @@ -112,7 +86,6 @@ def to_dict(self):
'recommended_positive': self.recommended_positive,
'recommended_negative': self.recommended_negative,
'config_blob': self.config_blob,
'sag_capable': self.sag_capable,
'tags': self.tags,
'approved': self.approved,
'added_by': self.added_by
Expand Down

0 comments on commit 887559d

Please sign in to comment.