-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set up nos bot to save training images #313
Conversation
run bot inside a discord server alongside nos Kick off a training job on saved images
nos/experimental/discord/nos_bot.py
Outdated
"name": "sdv21-dreambooth-lora-test-bench", | ||
}, | ||
) | ||
assert job_id is not None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise an error so that the discord bot user gets some internal server error
nos/experimental/discord/nos_bot.py
Outdated
# Kick off a nos training run | ||
from nos.server._service import TrainingService | ||
|
||
svc = TrainingService() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to top of file, no need to instantiate it every time we run training
nos/experimental/discord/nos_bot.py
Outdated
await thread.send(f"Image {attachment.filename} saved!") | ||
|
||
# Kick off a nos training run | ||
from nos.server._service import TrainingService |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to top of file
nos/experimental/discord/nos_bot.py
Outdated
|
||
# save the attachments | ||
for attachment in ctx.message.attachments: | ||
print(f"got attachement: {attachment.filename}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use logger.debug
nos/experimental/discord/nos_bot.py
Outdated
return | ||
|
||
if not ctx.message.attachments: | ||
print("no attachments to train on, returning!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit logger.debug
nos/experimental/discord/nos_bot.py
Outdated
dirname = NOS_TRAINING_DIR / thread_name | ||
dirname.mkdir(parents=True, exist_ok=True) | ||
|
||
await thread.send("saving at dir: " + str(dirname)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit Use fstrings as much as possible `send(f"saving at dir: {dirname}")
nos/experimental/discord/nos_bot.py
Outdated
# save the attachments | ||
for attachment in ctx.message.attachments: | ||
print(f"got attachement: {attachment.filename}") | ||
await attachment.save(os.path.join(dirname, attachment.filename)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Pathlib operators instead dirname / attachment.filename
nos/experimental/discord/nos_bot.py
Outdated
@@ -24,9 +24,13 @@ | |||
# Create our bot: | |||
bot = commands.Bot(command_prefix="$", intents=intents) | |||
|
|||
TRAINING_CHANNEL_NAME = "training" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nos-playground
?
nos/experimental/discord/nos_bot.py
Outdated
@@ -24,9 +24,13 @@ | |||
# Create our bot: | |||
bot = commands.Bot(command_prefix="$", intents=intents) | |||
|
|||
TRAINING_CHANNEL_NAME = "training" | |||
NOS_TRAINING_DIR = NOS_TMP_DIR / "train" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOS_TMP_DIR / "discord/{CHANNEL_NAME}/train"
@@ -113,3 +113,6 @@ docker-compose-upd-cpu: docker-build-cpu | |||
|
|||
docker-compose-upd-gpu: docker-build-gpu | |||
docker compose -f docker-compose.gpu.yml up | |||
|
|||
docker-compose-upd-discord-bot: docker-build-gpu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to a standalone Makefile under examples/discord
Merged in #314 |
To start the server:
./nos/experimental/discord/nos_bot.py
To run image generation:
$generate prompt
To kick off a training job:
$train
A thread will be created including the training image directory.
Checks
make lint
: I've runmake lint
to lint the changes in this PR.make test
: I've made sure the tests (make test-cpu
ormake test
) are passing.Checks
make lint
: I've runmake lint
to lint the changes in this PR.make test
: I've made sure the tests (make test-cpu
ormake test
) are passing.