Midjourney Prompt Scraper
Scrapes Midjourney prompts from prompthero.com, extracts subjects with spaCy, and converts the data to JSONL for language model fine-tuning.
What this file does
Scrapes Midjourney prompts from prompthero.com, extracts subjects with spaCy, and converts the data to JSONL for language model fine-tuning.
When to use it
- Building a dataset of image generation prompts for LLM training
- Extracting and cleaning prompt text from a public gallery website
- Adding subject identification to raw prompt collections
- Converting scraped CSV data into Hugging Face compatible JSONL format
Assumes this stack
Midjourney Prompt Scraper
Overview
This project involves the extraction, processing, and transformation of Midjourney prompts obtained from https://prompthero.com/midjourney-prompts. The goal is to create a dataset suitable for training language models, specifically tailored for image generation prompts.
Project Structure
The project consists of four Python scripts:
-
link_extracter.py
- Description: Scrapes prompt links from the Midjourney prompts website using Selenium and BeautifulSoup.
- Dependencies:
csv,BeautifulSoup,selenium
-
text_extracter.py
- Description: Fetches text content from the extracted prompt links, considering rate-limiting and retries.
- Dependencies:
csv,requests,BeautifulSoup,time,HTTPAdapter,Retry
-
addsubject.py
- Description: Identifies main subjects in the prompts using spaCy and NLTK, then replaces placeholders with these subjects.
- Dependencies:
csv,spacy,nltk
-
convert2json.py
- Description: Converts the processed CSV data into a JSON format suitable for training a language model.
- Dependencies:
csv,json
Usage
-
Clone the Repository:
git clone [repository_url] cd Midjourney-Prompts-Project -
Install Dependencies:
pip install -r requirements.txt -
Run the Scripts:
python link_extracter.py python text_extracter.py python addsubject.py python convert2json.py -
Generated Files:
prompt_links.csv: Contains the extracted prompt links.partial_prompt_texts.csv: Contains text extracted from the prompt links.prompts_with_subject.csv: Contains prompts with identified subjects.prompts_with_subject.jsonl: JSON file suitable for language model training.
Hugging Face Dataset Card
Explore the dataset on Hugging Face: Midjourney Art Prompts
Dataset Usage
The generated JSON file is specifically formatted for fine-tuning models using Hugging Face's Transformers library, such as ChatGPT. The CSV files, on the other hand, can be used for training or fine-tuning other Language Model Models (LLMs).
Acknowledgments
- The prompthero.com website for providing the Midjourney prompts.
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
What's inside
4 Python scripts (link extraction, text extraction, subject identification, JSON conversion) plus a Hugging Face dataset link.
Change this for your project
- Replace
https://prompthero.com/midjourney-promptswith your target URL - Replace
mshojaei77/Midjourney-Art-Promptswith your Hugging Face dataset ID - Replace
mshojaei77in repository references with your own GitHub username
Where it goes
Keep it in your repository where the agent or team that needs it will read it.
Worth borrowing
- Rate-limiting and retry logic in text_extracter.py to avoid being blocked
- Using spaCy and NLTK together to identify main subjects from prompt text
Related Documents
50-best-ai-image-prompts
Lists 50 copy-paste-ready AI image prompts across 10 categories for Midjourney, DALL-E, and Stable Diffusion.
Welcome to Stable Diffusion
Introduces a gallery of Stable Diffusion images with prompts, explaining the tool's basics and showcasing example outputs across themes.
圖片提示詞專業技能 (Image Prompt Skill)
Defines a structured Chinese-language prompt format for AI image generation, replacing an older English-only convention.
dall-e
Lists 100+ GPTs for image generation and artistic design, each with a one-line description and link.