veela4 commited on
Commit
43cec2d
·
verified ·
1 Parent(s): 0d4ad2d

Delete show_embedding_sample.py

Browse files
Files changed (1) hide show
  1. show_embedding_sample.py +0 -48
show_embedding_sample.py DELETED
@@ -1,48 +0,0 @@
1
- import json
2
- import numpy as np
3
- from PIL import Image
4
- from transformers import CLIPProcessor, CLIPModel
5
-
6
- def show_embedding_sample():
7
- """
8
- Show what an embedding looks like - just numbers, no visual info
9
- """
10
- print("🔍 Creating sample embedding to show what people would see...")
11
-
12
- # Load CLIP model
13
- model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32")
14
- processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")
15
-
16
- # Process master.jpg
17
- image = Image.open("master.jpg").convert('RGB')
18
- inputs = processor(images=image, return_tensors="pt")
19
-
20
- with torch.no_grad():
21
- features = model.get_image_features(**inputs)
22
- embedding = features.squeeze().numpy()
23
-
24
- # Show what the embedding data looks like
25
- print("\n📊 This is what people would see in the embedding file:")
26
- print("=" * 60)
27
- print(f"Embedding shape: {embedding.shape}")
28
- print(f"First 10 values: {embedding[:10]}")
29
- print(f"Data type: {type(embedding[0])}")
30
- print("\nSample JSON structure:")
31
-
32
- sample_data = {
33
- "filename": "sample_image.jpg",
34
- "embedding": embedding[:20].tolist(), # Just first 20 values for demo
35
- "description": "Sample image embedding for demonstration"
36
- }
37
-
38
- print(json.dumps(sample_data, indent=2))
39
- print("\n💡 Key points:")
40
- print("- Just 512 numbers (mathematical representation)")
41
- print("- No visual information about the original image")
42
- print("- Cannot reconstruct the original image from these numbers")
43
- print("- Useful for similarity search and ML tasks")
44
- print("- Completely privacy-safe")
45
-
46
- if __name__ == "__main__":
47
- import torch
48
- show_embedding_sample()