Spaces:
Runtime error
Runtime error
File size: 1,774 Bytes
3da5ff8 adad4ac |
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
---
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`
|