CoolFace
Apppublic

fast-stager/auto_pick_mobileclip

sourceHugging Faceupdated 11mo agoView on Hugging Face
0likes
App README

๐Ÿ—๏ธ 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:

  1. 1.A user-friendly Web UI (built with Gradio) for interactive testing and demonstration.
  2. 2.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
  1. 1.file: The image file you want to analyze (.jpg, .png, etc.).
  2. 2.prompts (Optional): A JSON string containing custom prompts. If not provided, default prompts are used.
  3. 3.prompt_good (string): Describes an ideal room for staging.
  4. 4.prompt_bad (string): Describes a room that is difficult to stage.
  5. 5.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.

sh
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."

sh
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.

json
{
  "filename": "living_room.jpg",
  "stageability_score": 1.4587,
  "details": "Score calculated based on the provided prompts."
}