ChatGPT:自動化產生吸睛新聞封面

Find AI Tools
No difficulty
No complicated process
Find ai tools

ChatGPT:自動化產生吸睛新聞封面

Table of Contents:

  1. Introduction
  2. Setting Up Midjourney
  3. Creating a Discord Server
  4. Adding MidJourney Bot to the Server
  5. Writing a Basic Discord Bot Program
  6. Downloading Images Automatically
  7. Generating Prompts with OpenAI
  8. Sending Prompts to MidJourney
  9. Automating the Image Generation Process
  10. Conclusion

Article

Introduction

In our previous article, we explored how to generate midjourney incantations by feeding headlines to ChatGPT and using web scraping to send these incantations to a Discord server for MidJourney to produce images. However, we still have one step missing in our automation process: automatically downloading these images from MidJourney. How can we accomplish this? In this article, we will walk through the steps of setting up our own server within MidJourney, adding application and bot features, and automating the download process.

Setting Up MidJourney

To begin automating the image download process in MidJourney, we need to Create our own server and add our applications and bots to it. First, we need to sign up for an account with MidJourney. Once You have subscribed to MidJourney as an advanced user, you can proceed with the following steps. If you have not yet subscribed, you can do so by typing 'Subscribe' in the MidJourney Channel. Once subscribed, you can choose to 'Subscribe to MidJourney' and upgrade to an advanced account. After successfully upgrading, you can enter your information by typing 'info' and pressing 'Enter' to generate your basic profile. Your subscription will be set to 'Basic' mode.

Creating a Discord Server

To automate the download process, we first need to create our own Discord server. Under Discord, click on the "+" symbol and select 'Create a Server'. Choose a server name, add an image if desired, and create the server. Now, we can start setting up our automation process within this server.

Adding MidJourney Bot to the Server

To enable interactions with the MidJourney bot, we need to add it to our server. Go to your direct messages, search for 'midjourney bot', right-click on the profile, and select 'Add to Server'. Choose your server, in this case 'midjourney downloader', click 'Continue', grant all permissions, and authorize the bot. You will be asked to confirm that you are human. Once confirmed, we can go back to the 'midjourney downloader' server.

Writing a Basic Discord Bot Program

In order to automate the download process, we need to write a basic program that interacts with the MidJourney bot and the Discord server. Install the 'discord.py' library and copy the code that initializes the bot. We also need to update the program to include the necessary intents for the bot to interact with Discord. Set the bot's event to 'on_ready' to login and print a message. Now, we can run the bot by passing the token.

Downloading Images Automatically

To automate the image download, we need to modify the previously Mentioned Discord program. Remove the bot command and replace it with the 'on_message' event. Within this event, we will check if the message contains any image attachments with file extensions such as '.jpg' or '.png'. If an image attachment is found, we will download it using a web scraping technique and save it to the local file system. Finally, print a message notifying that the image has been downloaded.

Generating Prompts with OpenAI

To generate prompts for MidJourney, we need to set up our OpenAI environment and token. We also need to configure the Prompt Generator for generating midjourney incantations. We will utilize the 'GP3.5-Turbo' for generating prompts and using the 'Image Prompt' key provided by the Generator.

Sending Prompts to MidJourney

Next, we will send the prompts to MidJourney using a POST request. Set up the payload with the necessary values, including the generated midjourney prompt. Configure the headers with the Authorization token, as seen in the browser's developer tools. Finally, use the requests library to send the POST request.

Automating the Image Generation Process

Once the previous steps are complete, we can combine the scraping, discord bot, and prompt generation processes to fully automate the image generation and download process. By feeding the headline to the prompt generator, sending the generated prompt to MidJourney, and automating the download using web scraping, we can generate and download the desired image.

Conclusion

In this article, we have discussed the process of automating image downloads from MidJourney using a Discord bot and web scraping techniques. By following the steps outlined in this article, you can set up your own server, add bots and applications, and automate the image generation and download process. With these tools in place, you can easily generate and download images from MidJourney to enhance your automation workflow. Remember to refer to the code snippets provided and adapt them to your own requirements.

Are you spending too much time looking for ai tools?
App rating
4.9
AI Tools
100k+
Trusted Users
5000+
WHY YOU SHOULD CHOOSE TOOLIFY

TOOLIFY is the best ai tool source.