Skip to content
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

Closed
wants to merge 5 commits into from

Conversation

outtanames
Copy link
Contributor

To start the server: ./nos/experimental/discord/nos_bot.py

To run image generation: $generate prompt

To kick off a training job:

  1. Upload images as attachments to a message (do not send yet)
  2. Include message $train
    A thread will be created including the training image directory.

Checks

  • make lint: I've run make lint to lint the changes in this PR.
  • make test: I've made sure the tests (make test-cpu or make test) are passing.
  • Additional tests:
    • Benchmark tests (when contributing new models)
    • GPU/HW tests

Checks

  • make lint: I've run make lint to lint the changes in this PR.
  • make test: I've made sure the tests (make test-cpu or make test) are passing.
  • Additional tests:
    • Benchmark tests (when contributing new models)
    • GPU/HW tests

run bot inside a discord server alongside nos

Kick off a training job on saved images
"name": "sdv21-dreambooth-lora-test-bench",
},
)
assert job_id is not None
Copy link
Contributor

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

# Kick off a nos training run
from nos.server._service import TrainingService

svc = TrainingService()
Copy link
Contributor

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

await thread.send(f"Image {attachment.filename} saved!")

# Kick off a nos training run
from nos.server._service import TrainingService
Copy link
Contributor

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


# save the attachments
for attachment in ctx.message.attachments:
print(f"got attachement: {attachment.filename}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use logger.debug

return

if not ctx.message.attachments:
print("no attachments to train on, returning!")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit logger.debug

dirname = NOS_TRAINING_DIR / thread_name
dirname.mkdir(parents=True, exist_ok=True)

await thread.send("saving at dir: " + str(dirname))
Copy link
Contributor

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}")

# save the attachments
for attachment in ctx.message.attachments:
print(f"got attachement: {attachment.filename}")
await attachment.save(os.path.join(dirname, attachment.filename))
Copy link
Contributor

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

@@ -24,9 +24,13 @@
# Create our bot:
bot = commands.Bot(command_prefix="$", intents=intents)

TRAINING_CHANNEL_NAME = "training"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nos-playground?

@@ -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"
Copy link
Contributor

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
Copy link
Contributor

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

@spillai
Copy link
Contributor

spillai commented Sep 5, 2023

Merged in #314

@spillai spillai closed this Sep 5, 2023
@outtanames outtanames deleted the sloftin/discord-training branch October 25, 2023 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants