prithivMLmods commited on
Commit
7a8de5e
·
verified ·
1 Parent(s): 94b7583

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +101 -1
README.md CHANGED
@@ -2,8 +2,24 @@
2
  license: cc-by-nc-4.0
3
  datasets:
4
  - uoft-cs/cifar10
 
 
 
 
 
 
 
 
 
5
  ---
6
 
 
 
 
 
 
 
 
7
  ```
8
  Classification report:
9
 
@@ -25,4 +41,88 @@ Classification report:
25
  weighted avg 0.9633 0.9631 0.9632 20000
26
  ```
27
 
28
- ![download](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/dr7B2yAcfNEJ6ScY6XNC5.png)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  license: cc-by-nc-4.0
3
  datasets:
4
  - uoft-cs/cifar10
5
+ language:
6
+ - en
7
+ base_model:
8
+ - facebook/metaclip-2-worldwide-s16
9
+ pipeline_tag: image-classification
10
+ library_name: transformers
11
+ tags:
12
+ - text-generation-inference
13
+ - cifar10
14
  ---
15
 
16
+ ![1](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/mZz2vZy1IENHbtmXm1lUe.png)
17
+
18
+ # **MetaCLIP-2-Cifar10**
19
+
20
+ > **MetaCLIP-2-Cifar10** is an image classification vision–language encoder model fine-tuned from **facebook/metaclip-2-worldwide-s16** for a single-label classification task.
21
+ > It is designed to identify and categorize images into the ten CIFAR-10 object classes using the **MetaClip2ForImageClassification** architecture.
22
+
23
  ```
24
  Classification report:
25
 
 
41
  weighted avg 0.9633 0.9631 0.9632 20000
42
  ```
43
 
44
+ ![download](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/dr7B2yAcfNEJ6ScY6XNC5.png)
45
+
46
+ ---
47
+
48
+ The model classifies images into the following categories:
49
+
50
+ * **Class 0:** airplane
51
+ * **Class 1:** automobile
52
+ * **Class 2:** bird
53
+ * **Class 3:** cat
54
+ * **Class 4:** deer
55
+ * **Class 5:** dog
56
+ * **Class 6:** frog
57
+ * **Class 7:** horse
58
+ * **Class 8:** ship
59
+ * **Class 9:** truck
60
+
61
+ # **Run with Transformers**
62
+
63
+ ```python
64
+ !pip install -q transformers torch pillow gradio
65
+ ```
66
+
67
+ ```python
68
+ import gradio as gr
69
+ from transformers import AutoImageProcessor
70
+ from transformers import AutoModelForImageClassification
71
+ from transformers.image_utils import load_image
72
+ from PIL import Image
73
+ import torch
74
+
75
+ # Load model and processor
76
+ model_name = "prithivMLmods/MetaCLIP-2-Cifar10"
77
+ model = AutoModelForImageClassification.from_pretrained(model_name)
78
+ processor = AutoImageProcessor.from_pretrained(model_name)
79
+
80
+ def cifar10_classification(image):
81
+ """Predicts the CIFAR-10 class represented in an image."""
82
+ image = Image.fromarray(image).convert("RGB")
83
+ inputs = processor(images=image, return_tensors="pt")
84
+
85
+ with torch.no_grad():
86
+ outputs = model(**inputs)
87
+ logits = outputs.logits
88
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
89
+
90
+ labels = {
91
+ "0": "airplane",
92
+ "1": "automobile",
93
+ "2": "bird",
94
+ "3": "cat",
95
+ "4": "deer",
96
+ "5": "dog",
97
+ "6": "frog",
98
+ "7": "horse",
99
+ "8": "ship",
100
+ "9": "truck"
101
+ }
102
+ predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
103
+
104
+ return predictions
105
+
106
+ # Create Gradio interface
107
+ iface = gr.Interface(
108
+ fn=cifar10_classification,
109
+ inputs=gr.Image(type="numpy"),
110
+ outputs=gr.Label(label="Prediction Scores"),
111
+ title="CIFAR-10 Classification",
112
+ description="Upload an image to classify it into one of the CIFAR-10 categories."
113
+ )
114
+
115
+ # Launch the app
116
+ if __name__ == "__main__":
117
+ iface.launch()
118
+ ```
119
+
120
+ # **Intended Use:**
121
+
122
+ The **MetaCLIP-2-Cifar10** model is designed for object classification across the ten CIFAR-10 categories.
123
+ Potential use cases include:
124
+
125
+ * **Educational & Research Applications:** Benchmarking experiments, model comparison, and deep learning studies.
126
+ * **Lightweight Vision Systems:** Useful for systems requiring simple object recognition.
127
+ * **Dataset Exploration:** Assisting in data inspection, annotation, and visualization.
128
+ * **Prototype Systems:** Ideal for rapid prototyping in classification pipelines.