Anja97/prompt-search-engine
0
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
Prompt Search Engine
Overview
This project implements a prompt search engine for Stable Diffusion models. The search engine allows users to input a prompt and returns the top n most similar prompts from a corpus of existing prompts. This helps in generating higher quality images by providing more effective prompts.
The search engine consists of two main components:
- Prompt Vectorizer: Converts prompts into numerical vectors using a pre-trained embedding model.
- Similarity Scorer: Measures the similarity between the input prompt and existing prompts using cosine similarity.
Setup Instructions
Requirements
- Python >= 3.9
- pip
Installation
- Clone the repository
git clone <repository-url>
cd <repository-directory>- Create a virtual environment (optional)
python -m venv venv
source venv/bin/activate- Install dependencies
pip install -r requirements.txtRunning the run.py script
The run.py script allows you to run the prompt search engine from the command line.
Usage
python run.py --query "Your query prompt here" --n 5 --model "all-MiniLM-L6-v2"Arguments
--query: The query prompt (required).--n: The number of similar prompts to return (default 5).--model: The name of the SBERT model to use (default "all-MiniLM-L6-v2").
Example
python run.py --query "A cat wearing glasses, sitting at a computer" --n 7
