5分钟用ChatGPT制作Midjourney提示词生成器

5分钟用ChatGPT制作Midjourney提示词生成器

今天给大家分享一个非常好用的Midjourney提示词生成器方案。ChatGPT不仅能用来对话聊天,它的潜能其实几乎无上限,你甚至可以将它调校成智能生成Midjourney的提示词(prompt)小能手。

先来看看用ChatGPT做的Midjourney提示词生成器效果图。

image

下面我输入给GPT-4的提示词

i am using VS Code on Windows 11 and have Python 3.9 running in a virtual environment.
Assume I already have streamlit installed. I want to make a streamlit app named "Prompt Generator"
It should have the following buttons in a column under a category titled "Style" This will replace (Style_Type)
-Film Still
-Watercolor Painting
-Baroque Oil Painting
To the right of this is another column under a category "Aspect Ratio" with the following buttons. This will replace far_val}
-16:9
-2:1
-4:3
-1:1
• . .
To the right of this is another column under a category "Chaos" with the following buttons.
This will replace (chaos_val).
-10
-20
-35
-50
…
Replace (neg_prompts} based on the following:
If Film Still is selected as Style, replace with {lens, painting, illustration, cartoon, 3d}
Else replace with {photo}
Beneath these columns of buttons (with some padding) is a text input area under category
"Scene Description". There should be an initial string here that says "Paste scene description here." The text in this input will replace (scene_desc}
Beneath this (with some padding) is a text area with an initial prompt. The values surrounded by curly brackets should be treated as variables that will be replaced by user input.
/imagine prompt: STYLE: {Style_Type} | SCENE: (scene_desc} --ar far_val] --chaos {chaos_val} --no {neg_prompts}
When a button is pressed, replace the appropriate variables with the label of the button or as otherwise instructed. The rest of the text should remain the same.
Beneath this text area should be a 'copy' button which copies the text to the clipboard.
Code only.

GPT-4会给出我们具体的实施方案,我让他用markdown语法输出所有内容

ChatGPT制作Midjourney提示词生成器教程

本教程将指导你如何使用Python和Streamlit创建一个Midjourney提示词生成器。该生成器允许你选择不同的选项,并基于这些选项生成自定义的prompt。

步骤1:安装需要的库

首先,你需要确保你已经安装了以下Python库:

  • Streamlit
  • Pyperclip
  • Python虚拟环境
  • Altair(如果遇到问题,请使用版本4.1.0)

你可以使用以下命令进行安装:

pip install streamlit pyperclip altair==4.1.0

步骤2:创建Streamlit应用

然后,你可以创建一个新的Python文件,例如midjourneyhunt.py,并将以下代码复制到该文件中:

import streamlit as st
import pyperclip

# Variable defaults
style_type = 'Film Still'
ar_val = '16:9'
chaos_val = '10'
neg_prompts = 'lens, painting, illustration, cartoon, 3d'
scene_desc = 'Paste scene description here.'

# Create UI
st.title('Midjourney Prompt 生成器')

with st.sidebar:
    st.header('Style')
    style_options = ['Film Still', 'Watercolor Painting', 'Baroque Oil Painting']
    style_type = st.radio('', style_options, index=style_options.index(style_type))

    st.header('Aspect Ratio')
    ar_options = ['16:9', '2:1', '4:3', '1:1']
    ar_val = st.radio('', ar_options, index=ar_options.index(ar_val))

    st.header('Chaos')
    chaos_options = ['10', '20', '35', '50']
    chaos_val = st.radio('', chaos_options, index=chaos_options.index(chaos_val))


st.header('描述')
scene_desc = st.text_area('', scene_desc)

st.header("Negatives")
neg_prompts = st.text_area('',neg_prompts)

# Show the prompt
st.header('Prompt')
prompt = f"STYLE: {style_type} | SCENE: {scene_desc} --ar {ar_val} --chaos {chaos_val} --no {neg_prompts}"
st.text_area('', prompt, height=200)

if st.button('Copy Prompt to Clipboard'):
    pyperclip.copy(prompt)
    st.success('Prompt copied to clipboard.')

步骤3:运行Streamlit应用

最后,你可以通过在命令行中输入以下命令来运行你的Streamlit应用:

streamlit run midjourneyhunt.py

你应该能够在浏览器中看到你的应用并开始使用它。

注意事项

在使用过程中,如果遇到”ModuleNotFoundError: No module named ‘altair.vegalite.v4′”错误,这可能是因为Streamlit和Altair库版本的不兼容导致的。你应该安装Altair的4.1.0版本来解决这个问题。你可以使用以下命令进行安装:

pip install altair==4.1.0

如果在运行Streamlit应用时遇到”Protocols cannot be instantiated”错误,这可能是因为你的Python版本和Streamlit版本不兼容。你有两种可能的解决方案:

  • 升级你的Python版本,例如,升级到3.10版本。
  • 降级你的Streamlit版本,例如,安装1.0.0版本。

你可以使用以下命令进行操作:

# 更新Python版本
# (你可能需要查找适用于你操作系统的具体指令)

# 降级Streamlit版本
pip install --upgrade streamlit==1.0.0

如果你希望添加更多的选项或修改应用的行为,你可以编辑midjourneyhunt.py文件。例如,你可以添加更多的风格选项,或者添加一个新的输入框来接收更多的用户输入。

希望这个指南能够帮助你在5分钟之内创建你自己的Midjourney提示词生成器。

(1)
上一篇 2023年6月3日 11:23
下一篇 2023年5月17日 16:58

相关推荐

分享本页
返回顶部