fast-stager/auto_pick_mobileclip
๐๏ธ Auto Pick MobileCLIP API
This Hugging Face Space hosts a powerful tool for automatically ranking images. It uses Apple's efficient MobileCLIP2 model to score images against your criteria, making it perfect for auto-picking the best photos for real estate, e-commerce, or any other use case.
The application provides two ways to interact:
- A user-friendly Web UI (built with Gradio) for interactive testing and demonstration.
- A high-performance REST API (built with FastAPI) for programmatic integration.
โจ Web UI (Gradio)
When you visit this Space, you are greeted with an interactive interface where you can:
- Upload an image directly from your computer.
- Customize the prompts to define what makes a "good" or "bad" image for your specific needs.
- Add an "aesthetic" prompt to give bonus points for specific features (e.g., "contains a modern fireplace").
- See the score calculated instantly.
๐ค How It Works
The API calculates a differential score based on how closely an image matches a "good" prompt versus a "bad" prompt.
Score = Similarity(Image, Good Prompt) - Similarity(Image, Bad Prompt)
Users can also provide an optional "aesthetic" prompt, which adds a bonus to the score for desirable features like a fireplace or hardwood floors. This allows for highly customized and nuanced scoring tailored to specific needs.
๐ API Usage
The API exposes a single endpoint for ranking images.
Endpoint: /api/v1/rank_image
- Method:
POST - Content-Type:
multipart/form-data
Parameters
file: The image file you want to analyze (.jpg,.png, etc.).prompts(Optional): A JSON string containing custom prompts. If not provided, default prompts are used.prompt_good(string): Describes an ideal room for staging.prompt_bad(string): Describes a room that is difficult to stage.prompt_aesthetic(string, optional): Describes a desirable feature to add bonus points for.
Example cURL Requests
Once the Space is running, you can test it directly from your terminal. Replace YOUR-SPACE-NAME.hf.space with your Space's URL.
1. Basic Request (Using Default Prompts)
This is the simplest way to use the API. Just upload an image.
curl -X POST "https://YOUR-SPACE-NAME.hf.space/api/v1/rank_image" \
-F "file=@/path/to/your/living_room.jpg"2. Advanced Request (With Custom & Aesthetic Prompts)
This request customizes the scoring logic. It scores the image based on its suitability as a modern office and gives a bonus if it detects "large windows."
curl -X POST "https://YOUR-SPACE-NAME.hf.space/api/v1/rank_image" \
-F "file=@/path/to/your/office_space.jpg" \
-F "prompts={
\"prompt_good\": \"a bright, open-plan office with clean lines and a minimalist feel\",
\"prompt_bad\": \"a cramped, cluttered room with no natural light\",
\"prompt_aesthetic\": \"features large windows with a city view\"
}"Expected Response
The API will return a JSON object with the filename and the calculated score.
{
"filename": "living_room.jpg",
"stageability_score": 1.4587,
"details": "Score calculated based on the provided prompts."
}