Spaces:
Sleeping
Sleeping
File size: 889 Bytes
8a0c27f b652e4e 19b2dc7 8a0c27f b652e4e 8a0c27f b652e4e 8a0c27f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import dill
from core.data.dataset import PromptDataset
from core.search_engine import PromptSearchEngine
def run():
"""
Initialize the PromptSearchEngine with prompts from the specified dataset,
serialize the engine, and save it to a file.
This function performs the following steps:
1. Loads a dataset of prompts using the PromptDataset class.
2. Initializes the PromptSearchEngine with the loaded prompts.
3. Serializes the PromptSearchEngine instance using dill.
4. Saves the serialized engine to a file named 'engine.pickle'.
"""
prompt_dataset = PromptDataset("Gustavosta/Stable-Diffusion-Prompts")
prompt_dataset.load()
prompts = prompt_dataset.get_prompts()
engine = PromptSearchEngine(prompts)
serialized_engine = dill.dumps(engine)
with open("engine.pickle", "wb") as file:
file.write(serialized_engine)
|