Sunix2026 commited on
Commit
b452cdf
·
verified ·
1 Parent(s): 8ca7c64

Upload YOLOv11 segmentation model with config

Browse files
Files changed (3) hide show
  1. README.md +113 -12
  2. config.json +13 -0
  3. inference_example.py +27 -0
README.md CHANGED
@@ -6,22 +6,57 @@ tags:
6
  - instance-segmentation
7
  - computer-vision
8
  - deep-learning
 
9
  license: agpl-3.0
10
  ---
11
 
12
- # YOLOv11 Segmentation Model
13
 
14
- This is a custom trained YOLOv11 segmentation model.
15
 
16
  ## Model Details
17
 
18
  - **Model Type**: YOLOv11 Instance Segmentation
19
- - **Framework**: Ultralytics
20
  - **Task**: Instance Segmentation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  ## Usage
23
 
24
- ### Using Ultralytics
25
 
26
  ```python
27
  from ultralytics import YOLO
@@ -30,13 +65,20 @@ from ultralytics import YOLO
30
  model = YOLO('model.pt')
31
 
32
  # Run inference
33
- results = model('image.jpg')
34
 
35
  # Process results
36
  for result in results:
37
  masks = result.masks # Segmentation masks
38
  boxes = result.boxes # Bounding boxes
39
 
 
 
 
 
 
 
 
40
  # Visualize
41
  result.show()
42
  ```
@@ -45,8 +87,9 @@ for result in results:
45
 
46
  ```python
47
  import requests
 
48
 
49
- API_URL = "https://api-inference.huggingface.co/models/Sunix2026/Port-model"
50
  headers = {"Authorization": "Bearer YOUR_HF_TOKEN"}
51
 
52
  def query(filename):
@@ -55,17 +98,75 @@ def query(filename):
55
  response = requests.post(API_URL, headers=headers, data=data)
56
  return response.json()
57
 
 
58
  output = query("image.jpg")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  ```
60
 
61
- ## Training Details
 
 
 
 
 
 
 
 
62
 
63
- Add your training details here:
64
- - Dataset used
65
- - Training epochs
66
- - Hyperparameters
67
- - Performance metrics
 
 
 
 
 
 
68
 
69
  ## License
70
 
71
  AGPL-3.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  - instance-segmentation
7
  - computer-vision
8
  - deep-learning
9
+ - port-detection
10
  license: agpl-3.0
11
  ---
12
 
13
+ # Port Model
14
 
15
+ This is a custom trained YOLOv11 segmentation model for port detection.
16
 
17
  ## Model Details
18
 
19
  - **Model Type**: YOLOv11 Instance Segmentation
20
+ - **Framework**: Ultralytics YOLOv11
21
  - **Task**: Instance Segmentation
22
+ - **Classes**: 2
23
+ - **Input Size**: 1408x1408
24
+ - **Dataset**: Custom Port Dataset
25
+
26
+ ## Classes
27
+
28
+ - Class 0: Port-capped
29
+ - Class 1: Port-Empty
30
+
31
+ ## Model Configuration
32
+
33
+ ```json
34
+ {
35
+ "model_type": "yolov11-seg",
36
+ "task": "image-segmentation",
37
+ "framework": "ultralytics",
38
+ "num_classes": 2,
39
+ "id2label": {
40
+ "0": "Port-capped",
41
+ "1": "Port-Empty"
42
+ },
43
+ "input_size": 1408,
44
+ "confidence_threshold": 0.25,
45
+ "iou_threshold": 0.45
46
+ }
47
+ ```
48
+
49
+ ### Training Configuration
50
+
51
+ - **Epochs**: 100
52
+ - **Batch Size**: 16
53
+ - **Optimizer**: AdamW
54
+ - **Dataset**: Custom Port Dataset
55
+
56
 
57
  ## Usage
58
 
59
+ ### Using Ultralytics (Local Inference)
60
 
61
  ```python
62
  from ultralytics import YOLO
 
65
  model = YOLO('model.pt')
66
 
67
  # Run inference
68
+ results = model('image.jpg', conf=0.25, iou=0.45)
69
 
70
  # Process results
71
  for result in results:
72
  masks = result.masks # Segmentation masks
73
  boxes = result.boxes # Bounding boxes
74
 
75
+ # Get class names
76
+ for box in boxes:
77
+ class_id = int(box.cls)
78
+ class_name = {"0": "Port-capped", "1": "Port-Empty"}[str(class_id)]
79
+ confidence = float(box.conf)
80
+ print(f"Detected: {class_name} ({confidence:.2f})")
81
+
82
  # Visualize
83
  result.show()
84
  ```
 
87
 
88
  ```python
89
  import requests
90
+ import json
91
 
92
+ API_URL = "https://router.huggingface.co/models/Sunix2026/Port-model"
93
  headers = {"Authorization": "Bearer YOUR_HF_TOKEN"}
94
 
95
  def query(filename):
 
98
  response = requests.post(API_URL, headers=headers, data=data)
99
  return response.json()
100
 
101
+ # Run inference
102
  output = query("image.jpg")
103
+ print(json.dumps(output, indent=2))
104
+ ```
105
+
106
+ ### Using the Python Client
107
+
108
+ ```python
109
+ from yolov11_hf_inference import YOLOv11HFInference
110
+
111
+ # Initialize client
112
+ client = YOLOv11HFInference(
113
+ model_url="Sunix2026/Port-model",
114
+ access_token="YOUR_HF_TOKEN"
115
+ )
116
+
117
+ # Run inference
118
+ result = client.predict_from_path("image.jpg")
119
+
120
+ if result["success"]:
121
+ predictions = result["predictions"]
122
+
123
+ # Map class IDs to names
124
+ id2label = {"0": "Port-capped", "1": "Port-Empty"}
125
+
126
+ for pred in predictions:
127
+ class_name = id2label.get(str(pred.get('label', '')), 'Unknown')
128
+ confidence = pred.get('score', 0)
129
+ print(f"Found: {class_name} ({confidence:.2%})")
130
+ else:
131
+ print(f"Error: {result['error']}")
132
  ```
133
 
134
+ ## Performance Metrics
135
+
136
+ | Metric | Value |
137
+ |--------|-------|
138
+ | Confidence Threshold | 0.25 |
139
+ | IoU Threshold | 0.45 |
140
+ | Input Resolution | 1408x1408 |
141
+
142
+ ## Applications
143
 
144
+ This model can be used for:
145
+ - Port detection and classification
146
+ - Automated quality control
147
+ - Manufacturing inspection
148
+ - Inventory management
149
+
150
+ ## Limitations
151
+
152
+ - Model is trained specifically for port detection
153
+ - Performance may vary with different lighting conditions
154
+ - Best results with images similar to training data
155
 
156
  ## License
157
 
158
  AGPL-3.0
159
+
160
+ ## Citation
161
+
162
+ If you use this model, please cite:
163
+
164
+ ```bibtex
165
+ @misc{Port-model,
166
+ author = {Sunix2026},
167
+ title = {Port Model},
168
+ year = {2025},
169
+ publisher = {Hugging Face},
170
+ howpublished = {\url{https://huggingface.co/Sunix2026/Port-model}}
171
+ }
172
+ ```
config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "yolov11-seg",
3
+ "task": "image-segmentation",
4
+ "framework": "ultralytics",
5
+ "num_classes": 2,
6
+ "id2label": {
7
+ "0": "Port-capped",
8
+ "1": "Port-Empty"
9
+ },
10
+ "input_size": 1408,
11
+ "confidence_threshold": 0.25,
12
+ "iou_threshold": 0.45
13
+ }
inference_example.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # Sample inference script
3
+ from ultralytics import YOLO
4
+ import json
5
+
6
+ # Load configuration
7
+ with open('config.json', 'r') as f:
8
+ config = json.load(f)
9
+
10
+ # Load model
11
+ model = YOLO('model.pt')
12
+
13
+ # Run inference with config parameters
14
+ results = model(
15
+ 'your_image.jpg',
16
+ conf=config['confidence_threshold'],
17
+ iou=config['iou_threshold'],
18
+ imgsz=config['input_size']
19
+ )
20
+
21
+ # Process results
22
+ for result in results:
23
+ for box in result.boxes:
24
+ class_id = int(box.cls)
25
+ class_name = config['id2label'][str(class_id)]
26
+ confidence = float(box.conf)
27
+ print(f"Detected: {class_name} ({confidence:.2%})")