gaodrew commited on
Commit
5abdc2c
1 Parent(s): 5b1aeab

Create filter.py

Browse files
Files changed (1) hide show
  1. filter.py +22 -0
filter.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datasets import load_dataset
2
+ import pandas as pd
3
+
4
+ dataset = load_dataset("vivym/midjourney-prompts")
5
+
6
+ df = dataset['train'].to_pandas()
7
+
8
+ prompt_lengths = df['prompt'].str.len()
9
+ p50 = prompt_lengths.quantile(0.90)
10
+ p75 = prompt_lengths.quantile(1.0)
11
+
12
+ filtered_df = df[(prompt_lengths > p50) & (prompt_lengths <= p75) & (df['style'] != 'niji') & (df['is_upscaled'] == True) & (df['version'] >= 5.0) & (df['version'] <= 5.2)]
13
+
14
+ filtered_df = filtered_df.drop_duplicates(subset=['prompt'])
15
+
16
+ print(f"Number of prompts after filtering and deduplication: {len(filtered_df)}")
17
+
18
+ print("First few rows of the filtered dataset:")
19
+ print(filtered_df.head())
20
+
21
+ output_file = 'filtered_midjourney_prompts_80thpercentilelength.csv'
22
+ filtered_df.to_csv(output_file, index=False)