Skip to content

Commit

Permalink
add shell plus
Browse files Browse the repository at this point in the history
  • Loading branch information
hylarucoder committed Aug 2, 2023
1 parent a6ddc80 commit 8c78374
Show file tree
Hide file tree
Showing 8 changed files with 279 additions and 9 deletions.
Empty file added tifa/management/__init__.py
Empty file.
Empty file.
28 changes: 28 additions & 0 deletions tifa/management/commands/shell_plus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import importlib
import logging

from django.core.management.base import BaseCommand

logger = logging.getLogger(__name__)


class Command(BaseCommand):
help = "shell plus"

def handle(self, *args, **options):
from IPython import embed
import cProfile
import pdb
import django.apps

models = {model.__name__: model for model in django.apps.apps.get_models()}
main = importlib.import_module("__main__")
ctx = main.__dict__
ctx.update(
{
**models,
"ipdb": pdb,
"cProfile": cProfile,
}
)
embed(user_ns=ctx, banner2="", colors="neutral", using='asyncio')
119 changes: 119 additions & 0 deletions tifa/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Generated by Django 4.2.3 on 2023-08-02 13:14

from django.db import migrations, models


class Migration(migrations.Migration):
initial = True

dependencies = []

operations = [
migrations.CreateModel(
name="SdImage",
fields=[
("id", models.BigAutoField(primary_key=True, serialize=False)),
("sort_num", models.IntegerField(db_index=True, default=999)),
("created_at", models.DateTimeField(auto_now_add=True, db_index=True)),
("updated_at", models.DateTimeField(auto_now=True)),
],
options={
"db_table": "sd_image",
},
),
migrations.CreateModel(
name="SdModelCheckpoint",
fields=[
("id", models.BigAutoField(primary_key=True, serialize=False)),
("name", models.CharField(max_length=100)),
("slug", models.CharField(max_length=100, unique=True)),
("sort_num", models.IntegerField(db_index=True, default=999)),
("created_at", models.DateTimeField(auto_now_add=True, db_index=True)),
("updated_at", models.DateTimeField(auto_now=True)),
],
options={
"db_table": "sd_model_checkpoint",
},
),
migrations.CreateModel(
name="SdModelLora",
fields=[
("id", models.BigAutoField(primary_key=True, serialize=False)),
("name", models.CharField(max_length=100)),
("slug", models.CharField(max_length=100, unique=True)),
("sort_num", models.IntegerField(db_index=True, default=999)),
("created_at", models.DateTimeField(auto_now_add=True, db_index=True)),
("updated_at", models.DateTimeField(auto_now=True)),
],
options={
"db_table": "sd_model_lora",
},
),
migrations.CreateModel(
name="SdModelVae",
fields=[
("id", models.BigAutoField(primary_key=True, serialize=False)),
("name", models.CharField(max_length=100)),
("slug", models.CharField(max_length=100, unique=True)),
("sort_num", models.IntegerField(db_index=True, default=999)),
("created_at", models.DateTimeField(auto_now_add=True, db_index=True)),
("updated_at", models.DateTimeField(auto_now=True)),
],
options={
"db_table": "sd_model_vae",
},
),
migrations.CreateModel(
name="SdPrompt",
fields=[
("id", models.BigAutoField(primary_key=True, serialize=False)),
("checkpoint", models.CharField(max_length=100)),
("prompt", models.TextField()),
("n_prompt", models.TextField()),
("sampler", models.CharField(max_length=50)),
("cfg_scale", models.IntegerField(default=7)),
("steps", models.IntegerField(default=30)),
("seed", models.BigIntegerField(default=-1)),
("sort_num", models.IntegerField(db_index=True, default=999)),
("created_at", models.DateTimeField(auto_now_add=True, db_index=True)),
("updated_at", models.DateTimeField(auto_now=True)),
],
options={
"db_table": "sd_prompt",
},
),
migrations.CreateModel(
name="SdPromptTag",
fields=[
("id", models.BigAutoField(primary_key=True, serialize=False)),
("name", models.CharField(max_length=100)),
("name_zh", models.CharField(max_length=100)),
("slug", models.CharField(max_length=100, unique=True)),
("sort_num", models.IntegerField(db_index=True, default=999)),
("created_at", models.DateTimeField(auto_now_add=True, db_index=True)),
("updated_at", models.DateTimeField(auto_now=True)),
],
options={
"db_table": "sd_prompt_tag",
},
),
migrations.CreateModel(
name="SdSpellTemplate",
fields=[
("id", models.BigAutoField(primary_key=True, serialize=False)),
("checkpoint", models.CharField(max_length=100)),
("prompt", models.TextField()),
("n_prompt", models.TextField()),
("sampler", models.CharField(max_length=50)),
("cfg_scale", models.IntegerField(default=7)),
("steps", models.IntegerField(default=30)),
("seed", models.BigIntegerField(default=-1)),
("sort_num", models.IntegerField(db_index=True, default=999)),
("created_at", models.DateTimeField(auto_now_add=True, db_index=True)),
("updated_at", models.DateTimeField(auto_now=True)),
],
options={
"db_table": "sd_spell_template",
},
),
]
24 changes: 24 additions & 0 deletions tifa/migrations/0002_sdprompt_slug_sdspelltemplate_slug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.2.3 on 2023-08-02 13:18

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("tifa", "0001_initial"),
]

operations = [
migrations.AddField(
model_name="sdprompt",
name="slug",
field=models.CharField(default="", max_length=100),
preserve_default=False,
),
migrations.AddField(
model_name="sdspelltemplate",
name="slug",
field=models.CharField(default="", max_length=100),
preserve_default=False,
),
]
17 changes: 17 additions & 0 deletions tifa/migrations/0003_rename_slug_sdprompt_template_slug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.3 on 2023-08-02 13:18

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("tifa", "0002_sdprompt_slug_sdspelltemplate_slug"),
]

operations = [
migrations.RenameField(
model_name="sdprompt",
old_name="slug",
new_name="template_slug",
),
]
Empty file added tifa/migrations/__init__.py
Empty file.
100 changes: 91 additions & 9 deletions tifa/models/sd.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,108 @@
from tifa.models.base import Model


class SdTopic(Model):
class SdModelCheckpoint(Model):
class Meta:
db_table = "sd_topic"
db_table = "sd_model_checkpoint"

id = models.BigAutoField(primary_key=True)
name = models.CharField(max_length=100)
position = models.IntegerField(db_index=True, default=999)
slug = models.CharField(max_length=100, unique=True)
sort_num = models.IntegerField(db_index=True, default=999)
created_at = models.DateTimeField(auto_now_add=True, db_index=True)
updated_at = models.DateTimeField(auto_now=True)

def __str__(self):
return f"<#{self.id}> - {self.name}"

class SdModelVae(Model):
class Meta:
db_table = "sd_model_vae"

class SdActivity(Model):
id = models.BigAutoField(primary_key=True)
name = models.CharField(max_length=100)
slug = models.CharField(max_length=100, unique=True)
sort_num = models.IntegerField(db_index=True, default=999)
created_at = models.DateTimeField(auto_now_add=True, db_index=True)
updated_at = models.DateTimeField(auto_now=True)


class SdModelLora(Model):
class Meta:
db_table = "sd_activity"
db_table = "sd_model_lora"

id = models.BigAutoField(primary_key=True)
name = models.CharField(max_length=100)
topic = models.ForeignKey(SdTopic, on_delete=models.PROTECT, null=True)
position = models.IntegerField(db_index=True, default=999)
slug = models.CharField(max_length=100, unique=True)
sort_num = models.IntegerField(db_index=True, default=999)
created_at = models.DateTimeField(auto_now_add=True, db_index=True)
updated_at = models.DateTimeField(auto_now=True)


class SdPromptTag(Model):
class Meta:
db_table = "sd_prompt_tag"

id = models.BigAutoField(primary_key=True)
name = models.CharField(max_length=100)
name_zh = models.CharField(max_length=100)
slug = models.CharField(max_length=100, unique=True)
sort_num = models.IntegerField(db_index=True, default=999)
created_at = models.DateTimeField(auto_now_add=True, db_index=True)
updated_at = models.DateTimeField(auto_now=True)

def __str__(self):
return f"<#{self.id}> - {self.name}|{self.name_zh}"


class SdSpellTemplate(Model):
class Meta:
db_table = "sd_spell_template"

id = models.BigAutoField(primary_key=True)
slug = models.CharField(max_length=100)
checkpoint = models.CharField(max_length=100)
prompt = models.TextField()
n_prompt = models.TextField()
sampler = models.CharField(max_length=50)
cfg_scale = models.IntegerField(default=7)
steps = models.IntegerField(default=30)
seed = models.BigIntegerField(default=-1)
sort_num = models.IntegerField(db_index=True, default=999)
created_at = models.DateTimeField(auto_now_add=True, db_index=True)
updated_at = models.DateTimeField(auto_now=True)

def __str__(self):
return f"<#{self.id}> - {self.prompt}"


class SdPrompt(Model):
class Meta:
db_table = "sd_prompt"

id = models.BigAutoField(primary_key=True)
checkpoint = models.CharField(max_length=100)
template_slug = models.CharField(max_length=100)
prompt = models.TextField()
n_prompt = models.TextField()
sampler = models.CharField(max_length=50)
cfg_scale = models.IntegerField(default=7)
steps = models.IntegerField(default=30)
seed = models.BigIntegerField(default=-1)
sort_num = models.IntegerField(db_index=True, default=999)
created_at = models.DateTimeField(auto_now_add=True, db_index=True)
updated_at = models.DateTimeField(auto_now=True)

def __str__(self):
return f"<#{self.id}> - {self.name}"


class SdImage(Model):
class Meta:
db_table = "sd_image"

id = models.BigAutoField(primary_key=True)
sort_num = models.IntegerField(db_index=True, default=999)
created_at = models.DateTimeField(auto_now_add=True, db_index=True)
updated_at = models.DateTimeField(auto_now=True)

def __str__(self):
return f"<#{self.id}> - {self.sort_num}"

0 comments on commit 8c78374

Please sign in to comment.