Spaces:
Runtime error
Runtime error
title: Prompt Search Engine | |
emoji: ๐ | |
colorFrom: pink | |
colorTo: purple | |
sdk: docker | |
pinned: false | |
short_description: Improve image quality with better prompts! | |
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 | |
1. **Clone the repository** | |
```bash | |
git clone <repository-url> | |
cd <repository-directory> | |
``` | |
2. **Create a virtual environment (optional)** | |
```bash | |
python -m venv venv | |
source venv/bin/activate | |
``` | |
3. **Install dependencies** | |
```bash | |
pip install -r requirements.txt | |
``` | |
## Running the `run.py` script | |
The `run.py` script allows you to run the prompt search engine from the command line. | |
### Usage | |
```bash | |
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` | |