0Pricing
AI Prompt Engineering · บทเรียน

พรอมป์ตสำหรับเปรียบเทียบหลายภาพ

เปรียบเทียบภาพตั้งแต่สองภาพขึ้นไป: ความแตกต่าง ความเหมือน และการเปลี่ยนแปลงตามเวลา

พรอมป์ตสำหรับเปรียบเทียบหลายภาพ เป็นบทเรียน AI Prompt Engineering ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน AI Prompt Engineering และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส AI Prompt Engineering มีบทเรียนทั้งหมด 4 บทเรียน

พรอมต์หลายภาพ

โมเดลด้านการมองเห็นสามารถประมวลผลภาพหลายภาพในการเรียกใช้ครั้งเดียว ซึ่งทำให้สามารถทำงานเปรียบเทียบที่มีประสิทธิภาพได้:

  • การวิเคราะห์ก่อนและหลัง (ภาพถ่ายผลิตภัณฑ์ การปรับปรุงห้อง และภาพทางการแพทย์)
  • การเปรียบเทียบผลิตภัณฑ์ต่างรุ่น (ตัวเลือกสี การเปรียบเทียบขนาด)
  • การเปรียบเทียบคุณภาพ (การเลือกภาพถ่ายที่ดีที่สุดสำหรับรายการสินค้า)
  • การตรวจจับการเปลี่ยนแปลง (เอกสารสองฉบับคนละรุ่น หรือภาพสองภาพที่มีการประทับเวลา)

พรอมต์หลายภาพจำเป็นต้องมีโครงสร้างที่รอบคอบ เพื่อให้โมเดลทราบว่าภาพใดคือภาพใด และต้องวิเคราะห์ความสัมพันธ์แบบใด

การส่งภาพหลายภาพในการเรียกใช้ครั้งเดียว

ส่วนเชื่อมต่อโปรแกรมรองรับภาพหลายภาพในรูปแบบรายการของรายการเนื้อหา ให้กำกับภาพแต่ละภาพอย่างชัดเจน:

import anthropic, base64

client = anthropic.Anthropic(api_key='YOUR_API_KEY')

def compare_images(image_path_1, image_path_2, comparison_prompt):
    def encode(path):
        with open(path, 'rb') as f:
            return base64.standard_b64encode(f.read()).decode('utf-8')

    r = client.messages.create(
        model='claude-opus-4-5', max_tokens=600,
        messages=[{'role': 'user', 'content': [
            {'type': 'text', 'text': 'IMAGE 1:'},
            {'type': 'image', 'source': {'type': 'base64', 'media_type': 'image/jpeg', 'data': encode(image_path_1)}},
            {'type': 'text', 'text': 'IMAGE 2:'},
            {'type': 'image', 'source': {'type': 'base64', 'media_type': 'image/jpeg', 'data': encode(image_path_2)}},
            {'type': 'text', 'text': comparison_prompt}
        ]}]
    )
    return r.content[0].text

print('Multi-image comparison function defined.')

พรอมต์เปรียบเทียบผลิตภัณฑ์สองรายการ

การเปรียบเทียบภาพผลิตภัณฑ์สองภาพสำหรับแอปพลิเคชันที่ผู้บริโภคใช้งาน:

product_comparison_prompt = '''
Compare the two product images above (Image 1 and Image 2).

Analyze each of the following dimensions:

1. SIMILARITIES: What features, design elements, or characteristics do both products share?

2. DIFFERENCES: What are the key visual differences? Focus on:
   - Color and finish
   - Size and proportions (estimate if possible)
   - Design style (minimalist, ornate, modern, traditional)
   - Materials (if discernible)
   - Quality indicators

3. QUALITY ASSESSMENT: Which image appears to show a higher-quality product, and why?
   Rate each product 1-10 for apparent quality.

4. USE CASE: Based on appearance alone, which product seems better suited for:
   a) Professional/office use
   b) Home/casual use

Return your response in this format exactly.
'''

print(product_comparison_prompt)

การเปรียบเทียบก่อนและหลัง

พรอมต์ก่อนและหลังต้องระบุอย่างชัดเจนว่าภาพใดคือภาพก่อนและภาพใดคือภาพหลัง รวมถึงบริบทของการเปลี่ยนแปลงคืออะไร:

before_after_prompt = '''
You are looking at two images: a BEFORE image (Image 1) and an AFTER image (Image 2).

Analyze the transformation:

1. WHAT CHANGED: List all visible changes from Before to After
2. WHAT STAYED THE SAME: List elements that are unchanged
3. QUALITY IMPROVEMENT: Rate the improvement on a scale of 1-10 (1=no improvement, 10=dramatic improvement)
4. REMAINING ISSUES: What could still be improved that the transformation did not address?

Context: This is a [CONTEXT_PLACEHOLDER] before/after comparison.

Return JSON:
{
  "changes": ["string"],
  "unchanged": ["string"],
  "improvement_score": 1-10,
  "remaining_issues": ["string"],
  "summary": "one sentence summary"
}
'''

# Use contexts: room renovation, product refurbishment, skin care treatment, document cleanup
print('Before/after prompt with JSON output defined.')

การเลือกภาพถ่ายตามคุณภาพ

การเลือกภาพถ่ายที่ดีที่สุดจากตัวเลือกหลายรายการ — มีประโยชน์สำหรับกระบวนการทำงานด้านพาณิชย์อิเล็กทรอนิกส์ โซเชียลมีเดีย และการจัดพิมพ์:

import anthropic, base64, json

client = anthropic.Anthropic(api_key='YOUR_API_KEY')

def select_best_photo(image_paths, use_case='e-commerce product listing'):
    def encode(path):
        with open(path, 'rb') as f:
            return base64.standard_b64encode(f.read()).decode('utf-8')

    content = []
    for i, path in enumerate(image_paths):
        content.append({'type': 'text', 'text': f'IMAGE {i+1}:'})
        content.append({'type': 'image', 'source': {'type': 'base64', 'media_type': 'image/jpeg', 'data': encode(path)}})

    prompt = f'''
You have received {len(image_paths)} images. Select the best one for: {use_case}

Evaluate each on: lighting, composition, clarity, and suitability for the use case.
Return JSON: {{"best_image": 1-{len(image_paths)}, "score_breakdown": [{{"image_id": int, "score": 1-10, "reason": str}}]}}
'''
    content.append({'type': 'text', 'text': prompt})

    r = client.messages.create(model='claude-opus-4-5', max_tokens=300, messages=[{'role': 'user', 'content': content}])
    return json.loads(r.content[0].text)

print('Photo selection function defined.')

พรอมต์ตรวจจับการเปลี่ยนแปลง

การตรวจจับการเปลี่ยนแปลงที่เฉพาะเจาะจงระหว่างภาพเดียวกันสองรุ่น — มีประโยชน์สำหรับการจัดการรุ่นของเอกสาร การทบทวนการออกแบบส่วนติดต่อผู้ใช้ และการตรวจติดตาม:

change_detection_prompt = '''
Compare Image 1 (version A) with Image 2 (version B) of the same item.

Identify ALL changes, no matter how small.
For each change:
- Describe what changed
- Where in the image the change occurs (use quadrant: top-left, top-right, bottom-left, bottom-right, center)
- Classify the change: addition, removal, modification, movement

Return JSON:
{
  "total_changes": int,
  "changes": [
    {
      "description": str,
      "location": str,
      "type": "addition|removal|modification|movement"
    }
  ],
  "is_significant_change": true | false
}

If the images appear identical, return: {"total_changes": 0, "changes": [], "is_significant_change": false}
'''

print(change_detection_prompt)

การเปรียบเทียบการออกแบบแบบ A/B

การเปรียบเทียบรูปแบบการออกแบบสองแบบอย่างเป็นกลาง — มีประโยชน์สำหรับการตัดสินใจด้านส่วนติดต่อผู้ใช้และประสบการณ์ผู้ใช้ รวมถึงแนวทางสร้างสรรค์:

design_comparison_prompt = '''
You are an experienced UX designer reviewing two design variants (Image 1 = Design A, Image 2 = Design B).

Evaluate both designs on:

1. VISUAL HIERARCHY: Which design guides the eye more effectively? Why?
2. READABILITY: Which has better text legibility and information density?
3. BRAND CONSISTENCY: Which feels more professional and polished?
4. USABILITY: Which would be easier for a new user to navigate?
5. EMOTIONAL IMPACT: Which creates a stronger positive first impression?

For each dimension, declare a winner (A or B) and explain in one sentence.

Final verdict: Return JSON:
{
  "winner": "A|B|tie",
  "dimension_winners": {"visual_hierarchy": str, "readability": str, "brand": str, "usability": str, "emotional": str},
  "winning_reasons": [str],
  "recommendation": str
}
'''

print('Design comparison prompt defined.')

การให้คะแนนความคล้ายคลึงแบบมีโครงสร้าง

สำหรับกระบวนการทำงานอัตโนมัติ ให้สร้างคะแนนความคล้ายคลึงเชิงตัวเลขระหว่างภาพ:

similarity_prompt = '''
Compare these two images and provide a structured similarity analysis.

Return JSON:
{
  "overall_similarity": 0.0-1.0,
  "dimensions": {
    "subject_match": 0.0-1.0,
    "color_match": 0.0-1.0,
    "composition_match": 0.0-1.0,
    "style_match": 0.0-1.0
  },
  "key_differences": [str],
  "are_same_item": true | false | "cannot_determine"
}

Scoring: 1.0 = identical, 0.0 = completely different.
'''

import json
def similarity_score(image_path_1, image_path_2):
    result_text = compare_images(image_path_1, image_path_2, similarity_prompt)
    return json.loads(result_text)

print('Similarity scoring function defined.')
print('Use case: duplicate detection, product matching, visual search.')

การจัดการภาพมากกว่าสองภาพ

สำหรับภาพสามภาพขึ้นไป ให้จัดโครงสร้างพรอมต์เพื่อรองรับความซับซ้อนที่เพิ่มขึ้น:

def multi_image_prompt(n_images):
    image_labels = ', '.join(f'Image {i+1}' for i in range(n_images))
    return f'''
You have received {n_images} images: {image_labels}.

Rank all {n_images} images from best to worst for use as a product hero image.
For each image, provide:
- Rank (1=best)
- Score 1-10
- Key strengths
- Key weaknesses

Return JSON:
{{
  "ranking": [
    {{"rank": int, "image_id": int, "score": int, "strengths": [str], "weaknesses": [str]}}
  ],
  "recommended_image": int
}}
'''

# Works for 3, 4, or 5 images
print(multi_image_prompt(3)[:300])

ข้อผิดพลาดที่พบบ่อยในพรอมต์หลายภาพ

ข้อผิดพลาดที่พบบ่อยเมื่อทำงานกับภาพหลายภาพและวิธีหลีกเลี่ยง:

  • ไม่มีป้ายกำกับภาพ: โมเดลอาจสับสนว่าภาพใดคือภาพใด — ให้กำกับด้วยข้อความ IMAGE 1: ก่อนภาพแต่ละภาพเสมอ
  • ไม่มีกรอบการเปรียบเทียบ: การขอให้เปรียบเทียบโดยไม่ระบุประเด็นจะทำให้ผลลัพธ์ไม่ตรงจุด — ให้ระบุสิ่งที่ต้องการเปรียบเทียบอย่างชัดเจน
  • ขาดบริบท: พรอมต์ก่อนและหลังจำเป็นต้องมีบริบทของการเปลี่ยนแปลง (การปรับปรุงห้อง ไม่ใช่เพียงภาพห้องสองภาพ)
  • มีภาพมากเกินไป: คุณภาพจะลดลงเมื่อมีภาพตั้งแต่ 6 ภาพขึ้นไป — ให้ประมวลผลเป็นชุด ชุดละ 2–4 ภาพ
  • ลืมขอผลลัพธ์แบบเจสัน: การเปรียบเทียบแบบร้อยแก้วแยกวิเคราะห์ได้ยาก — ให้ขอผลลัพธ์แบบเจสันที่มีโครงสร้างสำหรับกระบวนการทำงานเสมอ

การวิเคราะห์ลำดับภาพตามเวลา

เมื่อภาพแสดงลำดับตามเวลา (การตรวจติดตามรายสัปดาห์ ความคืบหน้าของการก่อสร้าง การติดตามผลทางการแพทย์) พรอมต์เปรียบเทียบควรวิเคราะห์ความคืบหน้าที่เกิดขึ้นตามเวลาอย่างชัดเจน:

temporal_prompt = '''
You are analyzing a sequence of images taken over time.
Image 1 = earliest, Image 2 = most recent.

Analyze the progression:
1. PROGRESS: What improvements or changes occurred from earliest to most recent?
2. REGRESSION: Any deterioration or negative changes?
3. RATE: Is the rate of change faster, slower, or as expected?
4. TRAJECTORY: Based on the trend, what is the likely state in the next period?

Return JSON:
{
  "progress": [str],
  "regression": [str],
  "change_rate": "faster|on_track|slower|stalled",
  "trajectory": str,
  "next_period_prediction": str
}
'''

print("Temporal sequence analysis prompt defined.")
print("Use cases: fitness progress, construction tracking, medical imaging follow-up.")

ตรวจสอบความเข้าใจ

องค์ประกอบเชิงโครงสร้างที่สำคัญที่สุดซึ่งควรใส่ไว้ในพรอมต์เปรียบเทียบหลายภาพคืออะไร

การเปรียบเทียบหลายภาพ — ประเด็นสำคัญ

พรอมต์เปรียบเทียบหลายภาพช่วยเพิ่มขีดความสามารถในการวิเคราะห์ภาพได้อย่างมีประสิทธิภาพ:

  • กำกับภาพอย่างชัดเจนเสมอด้วยข้อความก่อนภาพแต่ละภาพในชุดเนื้อหา
  • ระบุประเด็นที่จะเปรียบเทียบ เช่น ลำดับชั้นทางภาพ คุณภาพ และความคล้ายคลึง แทนการขอให้เปรียบเทียบแบบทั่วไป
  • พรอมต์ก่อนและหลังจำเป็นต้องมีบริบทของการเปลี่ยนแปลง (เกิดการเปลี่ยนแปลงประเภทใด)
  • ใช้ผลลัพธ์แบบเจสันที่มีโครงสร้างสำหรับกระบวนการทำงาน เช่น คะแนนความคล้ายคลึง รายการจัดอันดับ และการตรวจจับการเปลี่ยนแปลง
  • การเปรียบเทียบผลิตภัณฑ์ การเลือกภาพถ่ายตามคุณภาพ และการทบทวนการออกแบบแบบ A/B เป็นกรณีใช้งานที่มีมูลค่าสูง
  • จำกัดแต่ละชุดไว้ที่ภาพ 2–4 ภาพเป็นอย่างมาก — คุณภาพจะลดลงเมื่อมีภาพมากกว่านี้
  • พรอมต์ตรวจจับการเปลี่ยนแปลงควรจัดประเภทการเปลี่ยนแปลงแต่ละรายการตามชนิด ได้แก่ การเพิ่ม การนำออก การแก้ไข และการเคลื่อนย้าย

คำถามที่พบบ่อย

บทเรียน “พรอมป์ตสำหรับเปรียบเทียบหลายภาพ” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “พรอมป์ตสำหรับเปรียบเทียบหลายภาพ” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส AI Prompt Engineering ให้อัปเกรดเป็น CoddyKit PRO คอร์ส AI Prompt Engineering มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “พรอมป์ตสำหรับเปรียบเทียบหลายภาพ”

เปรียบเทียบภาพตั้งแต่สองภาพขึ้นไป: ความแตกต่าง ความเหมือน และการเปลี่ยนแปลงตามเวลา คุณปฏิบัติ AI Prompt Engineering ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน AI Prompt Engineering หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน AI Prompt Engineering บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน

บทเรียน “พรอมป์ตสำหรับเปรียบเทียบหลายภาพ” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน AI Prompt Engineering นี้ได้ไหม

ได้ บทเรียน AI Prompt Engineering ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. พรอมป์ตสำหรับการบรรยายและใส่คำบรรยายภาพ
  2. การตอบคำถามด้วยภาพ
  3. พรอมป์ตสำหรับเปรียบเทียบหลายภาพ
  4. พรอมป์ตสำหรับ OCR และการวิเคราะห์เอกสาร
← กลับไปที่ AI Prompt Engineering