gaodrew's picture
Create filter.py
5abdc2c verified
raw
history blame contribute delete
762 Bytes
from datasets import load_dataset
import pandas as pd
dataset = load_dataset("vivym/midjourney-prompts")
df = dataset['train'].to_pandas()
prompt_lengths = df['prompt'].str.len()
p50 = prompt_lengths.quantile(0.90)
p75 = prompt_lengths.quantile(1.0)
filtered_df = df[(prompt_lengths > p50) & (prompt_lengths <= p75) & (df['style'] != 'niji') & (df['is_upscaled'] == True) & (df['version'] >= 5.0) & (df['version'] <= 5.2)]
filtered_df = filtered_df.drop_duplicates(subset=['prompt'])
print(f"Number of prompts after filtering and deduplication: {len(filtered_df)}")
print("First few rows of the filtered dataset:")
print(filtered_df.head())
output_file = 'filtered_midjourney_prompts_80thpercentilelength.csv'
filtered_df.to_csv(output_file, index=False)