Ateeqq commited on
Commit
87ea5f0
·
verified ·
1 Parent(s): cbe1214

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +44 -30
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- license: cc-by-nd-4.0
3
  language:
4
  - en
5
  base_model:
@@ -24,6 +24,49 @@ This model is fine-tuned for **NSFW image classification**. It classifies conten
24
 
25
  ---
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  ## 🧠 Model Details
28
 
29
  * **Base model**: `google/siglip2-base-patch16-224`
@@ -58,35 +101,6 @@ id2label = {0: 'gore_bloodshed_violent', 1: 'nudity_pornography', 2: 'safe_norma
58
  ```
59
  ---
60
 
61
- ## 🚀 Usage Example
62
-
63
- ```python
64
- import torch
65
- from transformers import AutoImageProcessor, SiglipForImageClassification
66
- from PIL import Image
67
- import torch.nn.functional as F
68
-
69
- model_path = "Ateeqq/nsfw-image-detection"
70
- processor = AutoImageProcessor.from_pretrained(model_path)
71
- model = SiglipForImageClassification.from_pretrained(model_path)
72
-
73
- image = Image.open("your_image_path.jpg").convert("RGB")
74
- inputs = processor(images=image, return_tensors="pt")
75
-
76
- with torch.no_grad():
77
- logits = model(**inputs).logits
78
- probs = F.softmax(logits, dim=1)
79
-
80
- predicted_class_id = logits.argmax().item()
81
- predicted_class = model.config.id2label[predicted_class_id]
82
-
83
- print(f"Predicted class: {predicted_class}")
84
- for i, score in enumerate(probs[0]):
85
- print(f"{model.config.id2label[i]}: {score:.8f}")
86
- ```
87
-
88
- ---
89
-
90
  ## 📊 Training Metrics (Epoch 5 Selected ✅)
91
 
92
  | Epoch | Training Loss | Validation Loss | Accuracy |
 
1
  ---
2
+ license: apache-2.0
3
  language:
4
  - en
5
  base_model:
 
24
 
25
  ---
26
 
27
+ ## 🚀 Usage Example
28
+
29
+ ```python
30
+ import torch
31
+ from transformers import AutoImageProcessor, SiglipForImageClassification
32
+ from PIL import Image
33
+ import torch.nn.functional as F
34
+
35
+ model_path = "Ateeqq/nsfw-image-detection"
36
+ processor = AutoImageProcessor.from_pretrained(model_path)
37
+ model = SiglipForImageClassification.from_pretrained(model_path)
38
+
39
+ image_path = r"/content/download.jpg"
40
+ image = Image.open(image_path).convert("RGB")
41
+ inputs = processor(images=image, return_tensors="pt")
42
+
43
+ with torch.no_grad():
44
+ logits = model(**inputs).logits
45
+ probabilities = F.softmax(logits, dim=1)
46
+
47
+ predicted_class_id = logits.argmax().item()
48
+ predicted_class_label = model.config.id2label[predicted_class_id]
49
+ confidence_scores = probabilities[0].tolist()
50
+
51
+ print(f"Predicted class ID: {predicted_class_id}")
52
+ print(f"Predicted class label: {predicted_class_label}\n")
53
+ for i, score in enumerate(confidence_scores):
54
+ label = model.config.id2label[i]
55
+ print(f"Confidence for '{label}': {score:.6f}")
56
+ ```
57
+
58
+ ## Output
59
+ ```
60
+ Predicted class ID: 2
61
+ Predicted class label: safe_normal
62
+
63
+ Confidence for 'gore_bloodshed_violent': 0.000002
64
+ Confidence for 'nudity_pornography': 0.000005
65
+ Confidence for 'safe_normal': 0.999993
66
+ ```
67
+
68
+ ---
69
+
70
  ## 🧠 Model Details
71
 
72
  * **Base model**: `google/siglip2-base-patch16-224`
 
101
  ```
102
  ---
103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  ## 📊 Training Metrics (Epoch 5 Selected ✅)
105
 
106
  | Epoch | Training Loss | Validation Loss | Accuracy |