How to Export Images from the MidJourney Discord Channels
If you create images using MidJourney, you might wonder how you can export them along with the prompts.
One option is to go to your MidJourney online profile, select the images, and download them. However, this method is slow, and not all images are available. Moreover, you can't export the prompts together with the images.
Fortunately, there is a better and more efficient solution, which is explained below. Please note that you will need a basic understanding of how the command-line interface (CLI) works and have Python installed on your machine.
Step 1: Download the Necessary Programs
- Download and install Dotnet
- Download and unzip DiscordChatExporter
- Download and save this Python code locally
Step 2: Prepare the Necessary Data
Step 3: Run the Export
- Using the terminal, navigate to the
DiscordChatExporter
folder that you downloaded previously:cd /path/to/DiscordChatExporter
- Refer to the DiscordChatExporter CLI commands documentation to decide what and in what format you want to export
- For example, to export all Upscaled Images after June 25, 2023, and save them in a CSV format, use the following command:
dotnet DiscordChatExporter.Cli.dll export -c CHANNEL_ID -t DISCORD_TOKEN --filter "has:image Image" --o /path/to/target/folder --f Csv --after "2023-06-25 23:59"
Step 4: Cleanup the exported dta
- If you exported the data into a CSV (which I recommend) you will have a lot of useless details in the CSV. Open the CSV, and remove all but the
Content
and theAttachments
Columns. Save the CSV (or export it as a new CSV) - Optionally, run this CSV through the Python Code shared here. It will clean the prompts from several details you might not want (such as version suffixes, @username, etc). Read the code before doing so, and uncoment the sections you want to take effect, or comment sections you may not want to run.
Step 5: Download the actual images
- In your terminal, run
python /path/to/the/downloaded/python.py
(the Python file you downloaded in step 1, where/path/to/the/python.py
is the path to the Python file) - When prompted, pass the input CSV and output Folder where to store the images
- This will download all images from the discord server, and create a
.txt
file for each of the images (with same name but a .txt extension) holding the prompt
If you download a LOT of images, chances are that MidJourney will block your current IP. You will notice that when the script starts throwing error messages in the terminal (it will say it skpped the image download due to timeout). In this case, use a VPN to switch IPs. and run the script again. It will just proceed where it left off.
HINT: It might be that when this happens, you get all the images it could not download as "empty" image files in the target folder. Thus, before running the script again, please run your folder through this python script, which will delete all the empty files.
After you are done you may want to validate or modify your new dataset (this is a ready to go dataset for SD training btw!) by using some of the tools listed here.