何銘居
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Generative Image Model Evaluation ## Agenda 1. Human evaluation 2. Pixel-based metrics 3. Feature-based metrics i. Inception Score ii. CLIP Score 4. Novelty-based metrics 5. Model Explanation i. CLIP ii. Stable diffusion ## Human Evaluation 1. Ask human judges to rate the images on various criteria, such as **realism, diversity, relevance, and creativity**. 2. Human evaluation can **capture the subjective aspects** of image generation that are hard to quantify by automated metrics. However, human evaluation is also costly, time-consuming, and prone to bias and inconsistency. ## Pixel-based metrics 1. Compare the generated images with the real images from the same domain using pixel-based metrics, such as **mean squared error (MSE)**, peak signal-to-noise ratio (PSNR), or structural similarity index (SSIM). 2. These metrics **measure the pixel-wise similarity** or difference between two images, assuming that the closer the pixels are, the better the image quality is. 3. Pixel-based metrics have some limitations, such as **being sensitive to image transformations**, **ignoring high-level semantic features, and failing to account for diversity and novelty**. ## Feature-based metrics ### Simple Description 1. **Extract high-level features from the images using pre-trained neural networks**, such as convolutional neural networks (CNNs) or generative adversarial networks (GANs). 2. These features **capture the semantic and perceptual aspects** of the images, such as shapes, textures, colors, and styles. 3. Feature-based metrics, such as [inception score (IS)](https://www.techtarget.com/searchenterpriseai/definition/inception-score-IS), Fréchet inception distance (FID), [CLIP Score](https://unimatrixz.com/blog/latent-space-clip-score/), or perceptual path length (PPL), compare the feature distributions of the generated and real images, and assess how well the generative model preserves the diversity and quality of the original domain. ### Inception Score - The score produced by the IS algorithm can **range from zero (worst) to infinity** (best). The inception score algorithm measures two factors: 1. **Quality:** **How good the generated image is.** Generated images should be believable or realistic as if a real person painted a picture or took a photograph. For example, if the AI produces images of cats, each image should include a clearly identifiable cat. If the object is not clearly identifiable as a cat, the corresponding IS will be low. 2. **Diversity:** **How diverse the generated image is.** Generated images should have high randomness (entropy), meaning that the generative AI should produce highly varied images. For example, if the AI produces images of cats, each image should be a different cat breed and perhaps a different cat pose. If the AI is producing images of the same cat breed in the same pose, the diversity and corresponding IS will be low. - **How does Inception Score work** 1. Calculating an inception score starts by using the image classification network to ingest a generated image and **return a probability distribution for the image**. 2. The image classification network is fundamentally a **pre-trained Inception v3** model, which can predict class probabilities. 3. The probability distribution helps to determine whether the generated image **contains one well-defined thing**, or a series of things that are harder (if not impossible) for the image classification network to identify. This is the foundation of the **quality factor.** 4. Next, the inception score process **compares the probability distribution for all the generated images**. There may be as many as 50,000 generated images in a sample. This creates a second factor called **marginal distribution, which indicates the amount of variety** present in the generative AI's images: ![](https://hackmd.io/_uploads/ryNWHozlT.png) 5. The score is calculated using **Kullback-Leibler divergence**, or KL divergence. When **there is high KL divergence, there is a strong probability distribution and an even (flat) marginal distribution** -- each image has a distinct label (such as a cat), but the overall set of images has many different labels. This yields the highest inception score. ### CLIP Score - The goal of CLIP is to enable models to **understand the relationship between visual and textual data** and to use this understanding to perform various tasks, such as image captioning, visible question answering, and image retrieval. - CLIP score returns values **between +1 and -1**. - **What is CLIP** 1. CLIP (Contrastive Language-Image Pretraining) is an OpenAI model that combines computer vision and natural language understanding capabilities, it is considered a **image classification method**. 2. It trains on large images with captions to **learn representations for images and text in a joint embedding space.** Images and their captions are close together in this space, while unrelated images and captions are further apart. 3. CLIP can extract text from images, and the resulting text can be compared with a given text. Converting images to text, means to **extracting an embedding of an image and lookup similar text embeddings in the CLIP AI model.** #### Text-guided image generation - CLIP score measures the compatibility of image-caption pairs. Higher CLIP scores imply higher compatibility - How does CLIP score work? - ![](https://hackmd.io/_uploads/SyRcJ0Vbp.png) - We can follow the line draw by sampling steps and clipscore to determine the parameters. #### Image-conditioned text-to-image generation - **Condition the generation pipeline** with an input image as well as a text prompt. - For example, it takes an **edit instruction** as an input prompt and an **input image to be edited**. - Measure the **consistency of the change** between the two images (in CLIP space) with the change between the two image captions. - This is referred to as the **CLIP directional similarity**: ![](https://hackmd.io/_uploads/SkxbG04ZT.png) - Caption 1 corresponds to the input image (image 1) that is to be edited. - Caption 2 corresponds to the edited image (image 2). It should reflect the edit instruction. ## Task-based metrics 1. **Measure how well the generated images can be used for downstream tasks**, such as classification, segmentation, captioning, or retrieval. 2. Task-based metrics can reflect the usefulness and applicability of the generative model for specific purposes and domains. 3. For example, one can use **classification accuracy, segmentation accuracy, captioning BLEU score, or retrieval precision and recall as task-based metrics**. 4. However, task-based metrics depend on the choice and performance of the downstream models, and **may not capture the general aspects** of image generation. ## Model Explanation ### CLIP (Contrastive Language–Image Pre-training) #### Background - This model learns the **relationship between a whole sentence and the image** it describes. - Given an input sentence it will be able to retrieve the most related images corresponding to that sentence. - It is trained on full sentences **instead of single classes** like car, dog, etc. - By prompt engineering, it can also act as a classifier. - **CLIP is zero shot by design** hence not restricted to number of labels. It does not constrain the model to reduce to one concept or a label. #### Key factors in CLIP - **Large Dataset:** CLIP is trained over WebImage Text(WIT) 400M image-text pair. Diverse dataset crawled from internet. More data is better. - **Contrastive Pre-Training:** ![](https://hackmd.io/_uploads/BJO0b4L-6.png) - In contrastive learning it is trying to maximise diagonal value (I_1,T_1), (I_2,T_2)… I_N,T_N while minimising off diagonal elements. - Most of the learning coming from negative image description. In a batch of 32,768 there is only one positive pair. - CLIP’s learns most by, what this image is not about. - **Core Implementation of CLIP** ![](https://hackmd.io/_uploads/H1xrGE8-p.png) - **Prediction Task (Application):** ![](https://hackmd.io/_uploads/SyVFz4U-T.png) #### Applications - **Zero Shot Image classification:** Using Clip embedding out of the box to do zero shot image classification. - **Fine Tuned Image Classification:** Adding a classification head and fine tune the head for specific fine-grained systematic image classification. - **Semantic Image Retrieval:** Text to image and Reverse Image search both are possible with rich CLIP embeddings. - **Image Ranking :** It’s not just factual representations that are encoded in CLIP’s memory. It also knows about qualitative concepts as well - **Image Captioning:** With the feature vectors from CLIP have been wired into GPT-2 to output an English description for a given image. ### Framework of Stable Diffusion ![](https://hackmd.io/_uploads/SJtImTVWT.png) ### Framework of Stable Diffusion XL ![](https://hackmd.io/_uploads/B1afg8wfa.png) ### Resource [Simple Intro of Image Evaluation](https://www.linkedin.com/advice/1/what-most-effective-ways-evaluate-generative) [HuggingFace Image Evaluation](https://huggingface.co/docs/diffusers/conceptual/evaluation) [FID Score](https://machinelearningmastery.com/how-to-implement-the-frechet-inception-distance-fid-from-scratch/) [CLIP from scratch](https://towardsdatascience.com/simple-implementation-of-openai-clip-model-a-tutorial-ace6ff01d9f2) [Understanding OpenAI CLIP & Its Applications](https://akgeni.medium.com/understanding-openai-clip-its-applications-452bd214e226) [Stable diffusion Easy Explanation](https://stable-diffusion-art.com/how-stable-diffusion-work/) [SD-XL Easy Explanation](https://stable-diffusion-art.com/sdxl-model/)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully