|
import json |
|
from tqdm.auto import tqdm |
|
|
|
items = list() |
|
|
|
hashs = set() |
|
|
|
with open('../dataset/scrap/civitai-2023-11-14.jsonl') as f: |
|
for i, line in tqdm(enumerate(f)): |
|
item = json.loads(line) |
|
|
|
if item['hash'] in hashs: |
|
continue |
|
hashs.add(item['hash']) |
|
|
|
if item['meta'] is None: |
|
item['meta'] = {} |
|
|
|
prompt = item['meta'].get('prompt') |
|
item['prompt'] = '' if prompt is None else prompt |
|
|
|
item['meta']['prompt'] = '' |
|
del item['meta']['prompt'] |
|
|
|
negativePrompt = item['meta'].get('negativePrompt') |
|
item['negativePrompt'] = '' if negativePrompt is None else negativePrompt |
|
|
|
item['meta']['negativePrompt'] = '' |
|
del item['meta']['negativePrompt'] |
|
|
|
items.append(item) |
|
|
|
print(len(items)) |
|
|
|
items = sorted(items, key=lambda x: x['createdAt']) |
|
|
|
with open('../dataset/scrap/civitai-2023-11-14-sorted.jsonl', 'wt') as f: |
|
for i in tqdm(items): |
|
f.write(json.dumps(i) + '\n') |
|
|
|
|
|
|