zsxkib / clip-age-predictor

Age prediction using CLIP - Patched version of `https://replicate.com/andreasjansson/clip-age-predictor` that works with the new version of cog!

replicate.com
Total runs: 189.6K
24-hour runs: 0
7-day runs: 0
30-day runs: 0
Github
Model's Last Updated: June 07 2023

Introduction of clip-age-predictor

Model Details of clip-age-predictor

Readme

CLIP Age Predictor 📸⏳

Welcome to the CLIP Age Predictor ! 👋 This project is a reimagination of a prior implementation of clip-age-predictor by Andreas Jansson . Due to some compatibility issues, we’ve updated it to work ensuring it’s up-to-date with the latest libraries and frameworks. 👩‍💻

We no longer get the error:
“”“
😵 Uh oh! This model can’t be run on Replicate because it was built with a version of Cog that is no longer supported. Consider opening an issue on the model’s GitHub repository to see if it can be updated to use a recent version of Cog. If you need any help, please hop into our Discord channel or email us about it.
“”“

Just upload a picture and hit "Submit" ! 📸

What Does This Code Do? 🧐

In essence, our code uses OpenAI’s CLIP model 🚀 to predict a person’s age based on a provided image, creating a novel and fun AI-powered age guessing game!

Here’s the breakdown:

  1. Setting up Prompts: We first set up ‘prompts’, sentences like "this person is {age} years old" . We have 99 of these, ranging from 1 to 99 years old.

  2. Model Preparation: We load the CLIP model and preprocess these prompts, converting them into a format (a tensor of encoded text) that the model understands.

  3. Image Processing: The input image is also preprocessed to ensure that the model can extract meaningful features from it.

  4. Cosine Similarity Computation: The core of our age prediction lies in computing the cosine similarity between the processed image and each of our age prompts.

Cosine similarity measures the cosine of the angle between two vectors. This value can range from -1 to 1, indicating complete oppositeness and perfect similarity, respectively. We’re exploiting the fact that when vectors are similar (meaning they point in roughly the same direction), their cosine similarity approaches 1.

Applying this to our scenario, we’re comparing the ‘direction’ or ‘meaning’ captured by our image with the ‘directions’ or ‘meanings’ of our age prompts. If the image aligns more closely with the vector for “this person is 22 years old” than any other prompt, we get a high cosine similarity, indicating that the person in the image is likely around 22 years old!

Under the Hood: CLIP and Contrastive Losses 🧠🔧

OpenAI’s CLIP (Contrastive Language–Image Pretraining) is a groundbreaking model that excels at deciphering the interplay between images and text. But what sets it apart from other models is its usage of ‘contrastive losses’ – an innovative strategy that refines the model’s capability to generalize and understand data.

Let’s peel back the layers to understand what contrastive loss really entails.

Contrastive Pretraining

At its core, contrastive losses function like a compass for the model during its training journey. It’s a distinctive loss function that excels in representation and self-supervised learning tasks. The primary aim here is to learn representations that draw similar instances closer (an image and its relevant text) while driving dissimilar instances apart (like an image paired with a random unrelated text).

The above image essentially portrays a similarity matrix, with each cell signifying the degree of similarity or difference between two instances (image and text). These instances are represented as embeddings within a high-dimensional space.

Let’s dive deeper:

  • The Matrix: The square matrix in the image signifies the relationships among diverse instances in our dataset. Every row and column equates to a unique instance in the dataset – images and sentences (alt tags from the internet).

  • Positive Pairs (Diagonal Elements): Diagonal elements of the matrix denote ‘positive pairs’. These are pairs of instances considered similar or related. For instance, in an image-caption dataset, a positive pair could be an image and its accurate caption. The objective is to minimize the distance between these pairs in the embedding space, thereby aligning similar items more closely.

  • Negative Pairs (Non-Diagonal Elements): Non-diagonal elements of the matrix signify the ‘negative pairs’. These pairs consist of instances considered dissimilar or unrelated. In an image-caption scenario, a negative pair could be an image and an unrelated caption. The goal here is to maximize the distance between these pairs in the embedding space, pushing dissimilar items further apart.

During the training phase, the model is fine-tuned to enhance the similarity of positive pairs while expanding the dissimilarity between negative pairs. This simultaneous push-and-pull dynamic, regulated by the contrastive loss function, facilitates the learning of more robust and discriminative representations.

Contrary to traditional ImageNet-style loss functions, which handle each classification problem independently, contrastive losses impart a more holistic understanding of data to the model. Instead of just processing individual images or texts, the model learns to comprehend the underlying relationships within the text-image data constellation. This ability to grasp the context, discern analogies, and understand abstract concepts positions CLIP as an ideal choice for tasks like age prediction!

The Art and Science of Predicting Age 🎨⚗️

Predicting age in this manner might seem a bit ‘hacky’, but it’s a testament to the flexibility of the CLIP model. CLIP is not explicitly trained to guess ages, yet it manages to perform this task by leveraging its understanding of the associations between images and prompts.

Remember, its predictions are educated guesses based on its training and the prompts provided, so the quality of input can influence the accuracy of its predictions. 📈🎯

Building with Cog 🛠️

Before you start, make sure you have Cog installed. Cog streamlines the process of building and deploying models, provided you have a CUDA-enabled GPU compatible with PyTorch > 1.8.

Just run the following command in your terminal:

cog build

This command will start the building process.

Executing a Prediction 🏃‍♀️

Executing a prediction is straightforward. After successfully building with Cog, you can run the predictor with the following command:

cog predict -i [email protected]

For example, with an input image of a person, the script provides an age prediction like so:

Running prediction...
19

I’m actually 22 in the picture, so nice guess!

That’s the model’s best guess at the person’s age in the image. Remember, it’s an estimate, not an absolute fact. Enjoy the magic of artificial intelligence, brought to life by the wonders of CLIP and the ingenious use of contrastive losses!

Pricing of clip-age-predictor replicate.com

Run time and cost

This model costs approximately $0.016 to run on Replicate, or 62 runs per $1, but this varies depending on your inputs. It is also open source and you can run it on your own computer with Docker .

This model runs on Nvidia T4 GPU hardware . Predictions typically complete within 73 seconds. The predict time for this model varies significantly based on the inputs.

Runs of zsxkib clip-age-predictor on replicate.com

189.6K
Total runs
0
24-hour runs
0
3-day runs
0
7-day runs
0
30-day runs

More Information About clip-age-predictor replicate.com Model

clip-age-predictor replicate.com

clip-age-predictor replicate.com is an AI model on replicate.com that provides clip-age-predictor's model effect (Age prediction using CLIP - Patched version of `https://replicate.com/andreasjansson/clip-age-predictor` that works with the new version of cog!), which can be used instantly with this zsxkib clip-age-predictor model. replicate.com supports a free trial of the clip-age-predictor model, and also provides paid use of the clip-age-predictor. Support call clip-age-predictor model through api, including Node.js, Python, http.

clip-age-predictor replicate.com Url

https://replicate.com/zsxkib/clip-age-predictor

zsxkib clip-age-predictor online free

clip-age-predictor replicate.com is an online trial and call api platform, which integrates clip-age-predictor's modeling effects, including api services, and provides a free online trial of clip-age-predictor, you can try clip-age-predictor online for free by clicking the link below.

zsxkib clip-age-predictor online free url in replicate.com:

https://replicate.com/zsxkib/clip-age-predictor

clip-age-predictor install

clip-age-predictor is an open source model from GitHub that offers a free installation service, and any user can find clip-age-predictor on GitHub to install. At the same time, replicate.com provides the effect of clip-age-predictor install, users can directly use clip-age-predictor installed effect in replicate.com for debugging and trial. It also supports api for free installation.

clip-age-predictor install url in replicate.com:

https://replicate.com/zsxkib/clip-age-predictor

clip-age-predictor install url in github:

https://github.com/zsxkib/replicate-clip-age-predictor

Url of clip-age-predictor

clip-age-predictor replicate.com Url

clip-age-predictor Owner Github

Provider of clip-age-predictor replicate.com

Other API from zsxkib

replicate

Blip 3 / XGen-MM, Answers questions about images ({blip3,xgen-mm}-phi3-mini-base-r-v1)

Total runs: 1.2M
Run Growth: 0
Growth Rate: 0.00%
Updated:May 13 2024
replicate

📖 PuLID: Pure and Lightning ID Customization via Contrastive Alignment

Total runs: 1.2M
Run Growth: 0
Growth Rate: 0.00%
Updated:May 16 2024
replicate

Make realistic images of real people instantly

Total runs: 848.9K
Run Growth: 0
Growth Rate: 0.00%
Updated:December 11 2024
replicate

Create song covers with any RVC v2 trained AI voice from audio files.

Total runs: 637.4K
Run Growth: 0
Growth Rate: 0.00%
Updated:November 16 2023
replicate

⚡️FLUX PuLID: FLUX-dev based Pure and Lightning ID Customization via Contrastive Alignment🎭

Total runs: 601.2K
Run Growth: 0
Growth Rate: 0.00%
Updated:September 16 2024
replicate

🎨 Fill in masked parts of images with FLUX.1-dev 🖌️

Total runs: 349.1K
Run Growth: 0
Growth Rate: 0.00%
Updated:August 20 2024
replicate

Add sound to video using the MMAudio V2 model. An advanced AI model that synthesizes high-quality audio from video content, enabling seamless video-to-audio transformation.

Total runs: 283.8K
Run Growth: 0
Growth Rate: 0.00%
Updated:April 02 2025
replicate

✍️✨Prompts to auto-magically relights your images

Total runs: 207.1K
Run Growth: 0
Growth Rate: 0.00%
Updated:May 21 2024
replicate

✨DiffBIR: Towards Blind Image Restoration with Generative Diffusion Prior

Total runs: 132.7K
Run Growth: 0
Growth Rate: 0.00%
Updated:October 12 2023
replicate

allenai/Molmo-7B-D-0924, Answers questions and caption about images

Total runs: 88.8K
Run Growth: 0
Growth Rate: 0.00%
Updated:September 27 2024
replicate

Jina-CLIP v2: 0.9B multimodal embedding model with 89-language multilingual support, 512x512 image resolution, and Matryoshka representations

Total runs: 76.0K
Run Growth: 0
Growth Rate: 0.00%
Updated:November 28 2024
replicate

🎨 AnimateDiff (w/ MotionLoRAs for Panning, Zooming, etc): Animate Your Personalized Text-to-Image Diffusion Models without Specific Tuning

Total runs: 56.6K
Run Growth: 0
Growth Rate: 0.00%
Updated:October 06 2023
replicate

📽️ Increase Framerate 🎬 ST-MFNet: A Spatio-Temporal Multi-Flow Network for Frame Interpolation

Total runs: 51.6K
Run Growth: 0
Growth Rate: 0.00%
Updated:October 09 2023
replicate

Hunyuan-Video LoRA Explorer + Trainer

Total runs: 31.4K
Run Growth: 0
Growth Rate: 0.00%
Updated:January 25 2025
replicate

Monster Labs' Controlnet QR Code Monster v2 For SD-1.5 on top of AnimateDiff Prompt Travel (Motion Module SD 1.5 v2)

Total runs: 10.1K
Run Growth: 0
Growth Rate: 0.00%
Updated:November 01 2023
replicate

🖼️✨Background images + prompts to auto-magically relights your images (+normal maps🗺️)

Total runs: 10.0K
Run Growth: 0
Growth Rate: 0.00%
Updated:May 21 2024
replicate

Real-Time Open-Vocabulary Object Detection

Total runs: 9.1K
Run Growth: 0
Growth Rate: 0.00%
Updated:February 12 2024
replicate

AuraSR v2: Second-gen GAN-based Super-Resolution for real-world applications

Total runs: 9.1K
Run Growth: 0
Growth Rate: 0.00%
Updated:August 01 2024
replicate

Create your own Realistic Voice Cloning (RVC v2) dataset using a YouTube link

Total runs: 8.4K
Run Growth: 0
Growth Rate: 0.00%
Updated:November 21 2023
replicate

Text-to-Video + Image-to-Video: Pyramid Flow Autoregressive Video Generation method based on Flow Matching

Total runs: 8.2K
Run Growth: 0
Growth Rate: 0.00%
Updated:October 11 2024
replicate

🎨 Fill in masked parts of images with FLUX.1-schnell 🖌️

Total runs: 6.2K
Run Growth: 0
Growth Rate: 0.00%
Updated:August 16 2024
replicate

🎨AnimateDiff Prompt Travel🧭 Seamlessly Navigate and Animate Between Text-to-Image Prompts for Dynamic Visual Narratives

Total runs: 5.6K
Run Growth: 0
Growth Rate: 0.00%
Updated:October 19 2023
replicate

FlashFace: Human Image Personalization with High-fidelity Identity Preservation

Total runs: 4.2K
Run Growth: 0
Growth Rate: 0.00%
Updated:April 23 2024
replicate

Make realistic images of real people instantly (w/ ip-adapter-plus-face_sdxl_vit-h)

Total runs: 3.8K
Run Growth: 0
Growth Rate: 0.00%
Updated:July 15 2024
replicate

Upscale videos + images with BSRGAN

Total runs: 2.7K
Run Growth: 0
Growth Rate: 0.00%
Updated:January 29 2025
replicate

Transform your portrait photos into any style or setting while preserving your facial identity

Total runs: 2.4K
Run Growth: 0
Growth Rate: 0.00%
Updated:April 03 2025
replicate

MimicMotion: High-quality human motion video generation with pose-guided control

Total runs: 2.4K
Run Growth: 0
Growth Rate: 0.00%
Updated:July 16 2024
replicate

AuraSR: GAN-based Super-Resolution for real-world

Total runs: 2.2K
Run Growth: 0
Growth Rate: 0.00%
Updated:June 28 2024
replicate

🖼️ Super fast 1.5B Image Captioning/VQA Multimodal LLM (Image-to-Text) 🖋️

Total runs: 2.2K
Run Growth: 0
Growth Rate: 0.00%
Updated:February 02 2024
replicate

Idefics3-8B-Llama3, Answers questions and caption about images

Total runs: 2.1K
Run Growth: 0
Growth Rate: 0.00%
Updated:August 15 2024
replicate

Qwen 2: A 7 billion parameter language model from Alibaba Cloud, fine tuned for chat completions

Total runs: 1.7K
Run Growth: 0
Growth Rate: 0.00%
Updated:June 26 2024
replicate

A state-of-the-art text-to-video generation model capable of creating high-quality videos with realistic motion from text descriptions

Total runs: 1.7K
Run Growth: 0
Growth Rate: 0.00%
Updated:December 11 2024
replicate

Cubiq's ComfyUI InstantID node running `instantid_basic.json` example

Total runs: 1.6K
Run Growth: 0
Growth Rate: 0.00%
Updated:August 20 2024
replicate

🎼FluxMusic Text-to-Music Generation with Rectified Flow Transformer🎶

Total runs: 1.3K
Run Growth: 0
Growth Rate: 0.00%
Updated:September 26 2024
replicate

✨Stable Diffusion 3 w/ ⚡InstantX's Canny, Pose, and Tile ControlNets🖼️

Total runs: 1.2K
Run Growth: 0
Growth Rate: 0.00%
Updated:June 22 2024
replicate

Image tagger fine-tuned on WaifuDiffusion w/ (SwinV2, SwinV2, ConvNext, and ViT)

Total runs: 1000
Run Growth: 0
Growth Rate: 0.00%
Updated:May 22 2024
replicate

🫦 Realistic facial expression manipulation (lip-syncing) using audio or video

Total runs: 1000
Run Growth: 0
Growth Rate: 0.00%
Updated:June 12 2024
replicate

Unofficial Re-Trained AnimateAnyone (Image + DWPose Video → Animated Video of Image)

Total runs: 853
Run Growth: 0
Growth Rate: 0.00%
Updated:January 19 2024
replicate

🎙️Hololive text-to-speech and voice-to-voice (Japanese🇯🇵 + English🇬🇧)

Total runs: 850
Run Growth: 0
Growth Rate: 0.00%
Updated:June 04 2024
replicate

MEMO is a state-of-the-art open-weight model for audio-driven talking video generation.

Total runs: 678
Run Growth: 0
Growth Rate: 0.00%
Updated:December 11 2024
replicate

🐲 DragGAN 🐉 - "Drag Your GAN: Interactive Point-based Manipulation on the Generative Image Manifold"

Total runs: 583
Run Growth: 0
Growth Rate: 0.00%
Updated:July 07 2023
replicate

Easily create video datasets with auto-captioning for Hunyuan-Video LoRA finetuning

Total runs: 532
Run Growth: 0
Growth Rate: 0.00%
Updated:April 02 2025
replicate

Surrealist digital art featuring whimsical, anthropomorphic characters with exaggerated textures and vibrant color blocking

Total runs: 480
Run Growth: 0
Growth Rate: 0.00%
Updated:October 09 2024
replicate

Transform your text into a beautiful two-tone color gradient that represents your emotions.

Total runs: 417
Run Growth: 0
Growth Rate: 0.00%
Updated:June 06 2023
replicate

STAR Video Upscaler: Spatial-Temporal Augmentation with Text-to-Video Models for Real-World Video Super-Resolution

Total runs: 382
Run Growth: 0
Growth Rate: 0.00%
Updated:February 01 2025
replicate

Super High Quality Depth Maps 🗺️: An End-to-End Tile-Based Framework 🏗️ for High-Resolution Monocular Metric Depth Estimation 🔍📏

Total runs: 362
Run Growth: 0
Growth Rate: 0.00%
Updated:December 27 2023
replicate

Qwen 2: A 1.5 billion parameter language model from Alibaba Cloud, fine tuned for chat completions

Total runs: 207
Run Growth: 0
Growth Rate: 0.00%
Updated:June 26 2024
replicate

Qwen 2: A 0.5 billion parameter language model from Alibaba Cloud, fine tuned for chat completions

Total runs: 198
Run Growth: 0
Growth Rate: 0.00%
Updated:June 25 2024
replicate

Generates realistic talking face animations from a portrait image and audio using the CVPR 2025 Sonic model

Total runs: 148
Run Growth: 0
Growth Rate: 0.00%
Updated:April 03 2025
replicate

Powerful text-to-video model that generates high-quality videos up to 6 seconds at 15 FPS and 720p resolution from simple text prompt

Total runs: 128
Run Growth: 0
Growth Rate: 0.00%
Updated:October 23 2024
replicate

Convert speech in audio to text w/ `tiny`, `small`, `base`, and `large-v3` models

Total runs: 126
Run Growth: 0
Growth Rate: 0.00%
Updated:July 02 2024
replicate

SAMURAI: Adapting Segment Anything Model for Zero-Shot Visual Tracking with Motion-Aware Memory

Total runs: 100
Run Growth: 0
Growth Rate: 0.00%
Updated:November 28 2024
replicate

Generate high-quality videos from text prompts using StepVideo

Total runs: 93
Run Growth: 0
Growth Rate: 0.00%
Updated:February 25 2025
replicate

🗣️ TalkNet-ASD: Detect who is speaking in a video

Total runs: 92
Run Growth: 0
Growth Rate: 0.00%
Updated:May 02 2024
replicate

A "Hello World" model for me to get to grips with `cog` and Replicate

Total runs: 44
Run Growth: 0
Growth Rate: 0.00%
Updated:June 06 2023
replicate

Cost-optimized MMAudio V2 (T4 GPU): Add sound to video using this version running on T4 hardware for lower cost. Synthesizes high-quality audio from video content.

Total runs: 21
Run Growth: 0
Growth Rate: 0.00%
Updated:April 02 2025
replicate

SAM 2: Segment Anything v2 (for in Images + Videos)

Total runs: 19
Run Growth: 0
Growth Rate: 0.00%
Updated:July 31 2024
replicate

Hibiki: High-Fidelity Simultaneous Speech-To-Speech Translation

Total runs: 12
Run Growth: 0
Growth Rate: 0.00%
Updated:February 11 2025
replicate

Remove background from images using BRIA-RMBG-2.0

Total runs: 2
Run Growth: 0
Growth Rate: 0.00%
Updated:November 25 2024