kadalicious22 commited on
Commit
38a3719
Β·
verified Β·
1 Parent(s): e7a36d1

Upload 4 files

Browse files
Files changed (4) hide show
  1. HF_DEPLOYMENT_GUIDE.md +286 -0
  2. README_HF.md +98 -0
  3. app.py +307 -0
  4. requirements_hf.txt +10 -0
HF_DEPLOYMENT_GUIDE.md ADDED
@@ -0,0 +1,286 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # πŸš€ Deploy ke Hugging Face Spaces - Step by Step
2
+
3
+ ## Kenapa Hugging Face Spaces?
4
+
5
+ βœ… **Free hosting** dengan GPU!
6
+ βœ… **Auto deploy** dari Git
7
+ βœ… **Zero DevOps** - tidak perlu setup server
8
+ βœ… **Share via link** - langsung bisa diakses siapa saja
9
+ βœ… **Built-in PyTorch** - sudah support deep learning
10
+
11
+ ---
12
+
13
+ ## πŸ“‹ Prerequisites
14
+
15
+ 1. Akun Hugging Face (gratis)
16
+ - Daftar di: https://huggingface.co/join
17
+
18
+ 2. Git terinstall di komputer
19
+ - Download: https://git-scm.com/downloads
20
+
21
+ ---
22
+
23
+ ## 🎯 Step-by-Step Deployment
24
+
25
+ ### **Step 1: Buat Space Baru**
26
+
27
+ 1. Login ke https://huggingface.co
28
+ 2. Klik avatar Anda (kanan atas) β†’ **New Space**
29
+ 3. Isi form:
30
+ - **Space name:** `carioLabel` (atau nama lain)
31
+ - **License:** MIT
32
+ - **SDK:** Gradio
33
+ - **Space hardware:** CPU basic (gratis) atau T4 small (untuk GPU)
34
+ - **Visibility:** Public atau Private
35
+
36
+ 4. Klik **Create Space**
37
+
38
+ ### **Step 2: Clone Repository ke Komputer**
39
+
40
+ ```bash
41
+ # Clone space repo
42
+ git clone https://huggingface.co/spaces/YOUR_USERNAME/carioLabel
43
+ cd carioLabel
44
+ ```
45
+
46
+ ### **Step 3: Copy File Aplikasi**
47
+
48
+ Copy 3 file ini ke folder `carioLabel`:
49
+
50
+ ```
51
+ carioLabel/
52
+ β”œβ”€β”€ app.py <- File utama (yang saya buat)
53
+ β”œβ”€β”€ requirements.txt <- Dependencies (rename dari requirements_hf.txt)
54
+ └── README.md <- README (rename dari README_HF.md)
55
+ ```
56
+
57
+ ### **Step 4: Push ke Hugging Face**
58
+
59
+ ```bash
60
+ # Add files
61
+ git add .
62
+
63
+ # Commit
64
+ git commit -m "Initial commit - carioLabel web app"
65
+
66
+ # Push
67
+ git push
68
+ ```
69
+
70
+ **Tunggu 2-5 menit**, Space akan auto-deploy!
71
+
72
+ ### **Step 5: Akses Aplikasi**
73
+
74
+ Buka: `https://huggingface.co/spaces/YOUR_USERNAME/carioLabel`
75
+
76
+ **DONE!** Aplikasi langsung live! πŸŽ‰
77
+
78
+ ---
79
+
80
+ ## 🎨 Customization
81
+
82
+ ### **Ubah Tema/Warna**
83
+
84
+ Edit `app.py`:
85
+ ```python
86
+ with gr.Blocks(theme=gr.themes.Soft()) as demo:
87
+ ```
88
+
89
+ Pilihan theme:
90
+ - `gr.themes.Soft()` - Soft & friendly
91
+ - `gr.themes.Monochrome()` - Hitam putih
92
+ - `gr.themes.Glass()` - Modern glassmorphism
93
+
94
+ ### **Tambah Logo/Icon**
95
+
96
+ Di README.md, ubah bagian frontmatter:
97
+ ```yaml
98
+ ---
99
+ title: carioLabel
100
+ emoji: 🎯 <- Ganti emoji ini
101
+ colorFrom: blue <- Warna gradient
102
+ colorTo: green
103
+ ---
104
+ ```
105
+
106
+ ### **Enable GPU** (untuk training lebih cepat)
107
+
108
+ 1. Go to Space settings
109
+ 2. **Space hardware** β†’ Upgrade ke **T4 small** ($0.60/hour saat running)
110
+ 3. Save
111
+
112
+ **Note:** GPU auto-sleep jika tidak dipakai, jadi tidak selalu charged.
113
+
114
+ ---
115
+
116
+ ## πŸ”§ Update Aplikasi
117
+
118
+ Setelah edit kode:
119
+
120
+ ```bash
121
+ git add .
122
+ git commit -m "Update features"
123
+ git push
124
+ ```
125
+
126
+ Space akan auto-rebuild & redeploy!
127
+
128
+ ---
129
+
130
+ ## πŸ“Š Monitoring
131
+
132
+ ### **View Logs**
133
+
134
+ Di Spaces page, klik tab **"Logs"** untuk lihat:
135
+ - Build logs
136
+ - Runtime logs
137
+ - Error messages
138
+
139
+ ### **Analytics**
140
+
141
+ Di Settings, ada basic analytics:
142
+ - Number of visits
143
+ - Usage statistics
144
+
145
+ ---
146
+
147
+ ## πŸ’° Pricing
148
+
149
+ ### **Free Tier:**
150
+ - βœ… CPU basic (2 vCPU, 16GB RAM)
151
+ - βœ… Auto-sleep after inactivity
152
+ - βœ… Unlimited public Spaces
153
+
154
+ ### **Paid (GPU):**
155
+ - T4 small: $0.60/hour (saat running)
156
+ - T4 medium: $1.20/hour
157
+ - A10G small: $3.15/hour
158
+
159
+ **Tip:** Gunakan CPU untuk demo, GPU hanya untuk production/training.
160
+
161
+ ---
162
+
163
+ ## 🎯 Best Practices
164
+
165
+ ### **1. Add Examples**
166
+
167
+ Buat folder `examples/` dengan sample images:
168
+ ```
169
+ examples/
170
+ β”œβ”€β”€ cat.jpg
171
+ β”œβ”€β”€ dog.jpg
172
+ └── person.jpg
173
+ ```
174
+
175
+ Di `app.py`, tambahkan:
176
+ ```python
177
+ demo.launch(examples=[
178
+ ["examples/cat.jpg", "cat"],
179
+ ["examples/dog.jpg", "dog"]
180
+ ])
181
+ ```
182
+
183
+ ### **2. Add Caching**
184
+
185
+ Untuk speed up:
186
+ ```python
187
+ @gr.cache
188
+ def expensive_function():
189
+ # ... slow operation
190
+ ```
191
+
192
+ ### **3. Error Handling**
193
+
194
+ Always wrap risky operations:
195
+ ```python
196
+ try:
197
+ result = train_model()
198
+ except Exception as e:
199
+ return f"Error: {str(e)}"
200
+ ```
201
+
202
+ ---
203
+
204
+ ## πŸ”’ Private Space
205
+
206
+ Jika mau private (hanya Anda yang bisa akses):
207
+
208
+ 1. Space settings
209
+ 2. **Visibility** β†’ Private
210
+ 3. Save
211
+
212
+ Share access via invite di settings.
213
+
214
+ ---
215
+
216
+ ## πŸ“± Embed di Website
217
+
218
+ Space bisa di-embed di website Anda:
219
+
220
+ ```html
221
+ <iframe
222
+ src="https://YOUR_USERNAME-carioLabel.hf.space"
223
+ width="100%"
224
+ height="800px"
225
+ ></iframe>
226
+ ```
227
+
228
+ ---
229
+
230
+ ## πŸš€ Advanced: Custom Domain
231
+
232
+ Jika mau domain sendiri (e.g., `label.careio.my.id`):
233
+
234
+ 1. **Upgrade ke Pro** ($9/month)
235
+ 2. Di Space settings β†’ **Custom domain**
236
+ 3. Follow DNS setup instructions
237
+
238
+ ---
239
+
240
+ ## βœ… Checklist Deployment
241
+
242
+ - [ ] Buat Space di HF
243
+ - [ ] Clone repo
244
+ - [ ] Copy `app.py`, `requirements.txt`, `README.md`
245
+ - [ ] Git push
246
+ - [ ] Tunggu build selesai
247
+ - [ ] Test app di browser
248
+ - [ ] Share link ke users!
249
+
250
+ ---
251
+
252
+ ## πŸŽ‰ Keuntungan vs Desktop Version
253
+
254
+ | Aspect | Desktop (Portable) | Web (HF Spaces) |
255
+ |--------|-------------------|-----------------|
256
+ | **Installation** | Extract ZIP (3GB) | Zero (buka link) |
257
+ | **Updates** | Download ulang | Auto update |
258
+ | **GPU Access** | Butuh NVIDIA GPU | Free T4 GPU! |
259
+ | **Sharing** | Send ZIP file | Send link |
260
+ | **Maintenance** | Manual | Auto |
261
+
262
+ ---
263
+
264
+ ## πŸ’‘ Kesimpulan
265
+
266
+ **Hugging Face Spaces = Solusi TERMUDAH untuk deploy Python app!**
267
+
268
+ - 5 menit setup
269
+ - Free hosting
270
+ - Auto deploy
271
+ - Professional URL
272
+ - Built-in GPU
273
+
274
+ **Perfect untuk MVP dan demo!** 🎯
275
+
276
+ ---
277
+
278
+ ## πŸ“ž Need Help?
279
+
280
+ - HF Docs: https://huggingface.co/docs/hub/spaces
281
+ - Gradio Docs: https://gradio.app/docs/
282
+ - Contact: herdodimas46@gmail.com
283
+
284
+ ---
285
+
286
+ **Ready to deploy?** Copy 3 files, push to HF, done! πŸš€
README_HF.md ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: carioLabel - Image Annotation Tool
3
+ emoji: 🎯
4
+ colorFrom: blue
5
+ colorTo: green
6
+ sdk: gradio
7
+ sdk_version: 4.44.0
8
+ app_file: app.py
9
+ pinned: false
10
+ license: mit
11
+ ---
12
+
13
+ # 🎯 carioLabel - Web Edition
14
+
15
+ **Browser-based Image Annotation Tool with YOLO Training**
16
+
17
+ ## Features
18
+
19
+ - πŸ“¦ **Bounding Box Annotation** - Click to add boxes on images
20
+ - 🏷️ **Label Management** - Organize and categorize annotations
21
+ - πŸ’Ύ **Multi-Format Export** - YOLO, Pascal VOC formats
22
+ - πŸš€ **GPU Training** - Train YOLO models directly in browser
23
+ - 🌐 **Zero Installation** - Works in any modern browser
24
+ - πŸ†“ **Free to Use** - Open source and community-driven
25
+
26
+ ## How to Use
27
+
28
+ ### 1. Annotation
29
+ 1. Upload an image
30
+ 2. Enter a label name (e.g., "cat", "dog", "person")
31
+ 3. Click on the image to add bounding boxes
32
+ 4. Repeat for multiple objects
33
+
34
+ ### 2. Export
35
+ - Choose format: YOLO or Pascal VOC
36
+ - Click "Export Annotations"
37
+ - Copy the output for your dataset
38
+
39
+ ### 3. Training (Optional)
40
+ - Upload your dataset as ZIP
41
+ - Configure epochs and batch size
42
+ - Click "Start Training"
43
+ - Wait for results (uses HF GPU!)
44
+
45
+ ## Tech Stack
46
+
47
+ - **Gradio** - Web UI framework
48
+ - **Ultralytics YOLO** - Object detection
49
+ - **PyTorch** - Deep learning backend
50
+ - **OpenCV** - Image processing
51
+
52
+ ## Local Development
53
+
54
+ ```bash
55
+ # Clone repo
56
+ git clone https://huggingface.co/spaces/YOUR_USERNAME/carioLabel
57
+
58
+ # Install dependencies
59
+ pip install -r requirements.txt
60
+
61
+ # Run locally
62
+ python app.py
63
+ ```
64
+
65
+ ## Deployment
66
+
67
+ This Space is automatically deployed to Hugging Face Spaces.
68
+
69
+ Just push your changes:
70
+ ```bash
71
+ git add .
72
+ git commit -m "Update app"
73
+ git push
74
+ ```
75
+
76
+ ## Limitations
77
+
78
+ - Demo version has simplified box creation (click-based, not drag)
79
+ - Training requires properly formatted dataset
80
+ - Large datasets may hit memory limits
81
+
82
+ For production use with advanced features, see the desktop version.
83
+
84
+ ## Credits
85
+
86
+ **Author:** CareIO AI
87
+ **Contact:** herdodimas46@gmail.com
88
+ **Website:** https://www.careio.my.id
89
+ **Instagram:** @careio.ai
90
+
91
+ ## License
92
+
93
+ MIT License - Free to use for personal and commercial projects
94
+
95
+ ---
96
+
97
+ **Note:** This is a web-based demo. For advanced features and offline use,
98
+ check out the full desktop application.
app.py ADDED
@@ -0,0 +1,307 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ carioLabel - Web Version
3
+ Hugging Face Spaces Implementation with Gradio
4
+ """
5
+
6
+ import gradio as gr
7
+ import cv2
8
+ import numpy as np
9
+ from PIL import Image
10
+ import json
11
+ import os
12
+ from pathlib import Path
13
+
14
+ # Import your libs if needed
15
+ # from libs.yolo_utils import train_yolo
16
+
17
+ # Global state untuk annotations
18
+ annotations = {}
19
+ current_image_id = None
20
+
21
+ def load_image(image):
22
+ """Load image and initialize annotation state"""
23
+ global current_image_id, annotations
24
+
25
+ if image is None:
26
+ return None, "No image loaded"
27
+
28
+ # Generate unique ID for this image
29
+ current_image_id = str(hash(image.tobytes()))
30
+
31
+ if current_image_id not in annotations:
32
+ annotations[current_image_id] = {
33
+ 'boxes': [],
34
+ 'labels': []
35
+ }
36
+
37
+ return image, f"Image loaded. ID: {current_image_id[:8]}..."
38
+
39
+
40
+ def add_annotation(image, label, evt: gr.SelectData):
41
+ """Add bounding box annotation via click"""
42
+ global current_image_id, annotations
43
+
44
+ if image is None or current_image_id is None:
45
+ return image, "Please load an image first"
46
+
47
+ # Get click coordinates
48
+ x, y = evt.index
49
+
50
+ # For simplicity, create a fixed-size box
51
+ # In real app, you'd have drag functionality
52
+ box_size = 100
53
+ x1, y1 = max(0, x - box_size//2), max(0, y - box_size//2)
54
+ x2, y2 = x1 + box_size, y1 + box_size
55
+
56
+ # Add to annotations
57
+ annotations[current_image_id]['boxes'].append([x1, y1, x2, y2])
58
+ annotations[current_image_id]['labels'].append(label)
59
+
60
+ # Draw on image
61
+ img_with_boxes = draw_boxes(image, annotations[current_image_id])
62
+
63
+ num_boxes = len(annotations[current_image_id]['boxes'])
64
+ return img_with_boxes, f"Added box #{num_boxes} with label: {label}"
65
+
66
+
67
+ def draw_boxes(image, annot_data):
68
+ """Draw bounding boxes on image"""
69
+ img = np.array(image.copy())
70
+
71
+ for box, label in zip(annot_data['boxes'], annot_data['labels']):
72
+ x1, y1, x2, y2 = box
73
+ # Draw rectangle
74
+ cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2)
75
+ # Draw label
76
+ cv2.putText(img, label, (x1, y1-10),
77
+ cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
78
+
79
+ return Image.fromarray(img)
80
+
81
+
82
+ def export_annotations(format_type):
83
+ """Export annotations to YOLO/VOC format"""
84
+ global annotations
85
+
86
+ if not annotations:
87
+ return "No annotations to export"
88
+
89
+ output = []
90
+
91
+ for img_id, data in annotations.items():
92
+ if format_type == "YOLO":
93
+ # Convert to YOLO format
94
+ for box, label in zip(data['boxes'], data['labels']):
95
+ x1, y1, x2, y2 = box
96
+ # Normalize coordinates (simplified)
97
+ x_center = (x1 + x2) / 2 / 640 # assuming 640px width
98
+ y_center = (y1 + y2) / 2 / 480 # assuming 480px height
99
+ width = (x2 - x1) / 640
100
+ height = (y2 - y1) / 480
101
+
102
+ # YOLO format: class x_center y_center width height
103
+ output.append(f"0 {x_center} {y_center} {width} {height}")
104
+
105
+ elif format_type == "Pascal VOC":
106
+ # Simplified XML
107
+ output.append(f"<object>")
108
+ output.append(f" <name>{data['labels'][0]}</name>")
109
+ output.append(f" <bndbox>")
110
+ output.append(f" <xmin>{data['boxes'][0][0]}</xmin>")
111
+ output.append(f" <ymin>{data['boxes'][0][1]}</ymin>")
112
+ output.append(f" <xmax>{data['boxes'][0][2]}</xmax>")
113
+ output.append(f" <ymax>{data['boxes'][0][3]}</ymax>")
114
+ output.append(f" </bndbox>")
115
+ output.append(f"</object>")
116
+
117
+ return "\n".join(output)
118
+
119
+
120
+ def train_model_simple(dataset_path, epochs, batch_size):
121
+ """Simplified training function"""
122
+ try:
123
+ from ultralytics import YOLO
124
+
125
+ # This would run on Hugging Face GPU
126
+ model = YOLO('yolov8n.pt')
127
+
128
+ # Note: You'd need to prepare dataset in proper format
129
+ # This is a placeholder
130
+ results = model.train(
131
+ data='dataset.yaml', # You'd generate this from annotations
132
+ epochs=int(epochs),
133
+ batch=int(batch_size),
134
+ imgsz=640
135
+ )
136
+
137
+ return f"Training completed! Best mAP: {results.results_dict['metrics/mAP50(B)']}"
138
+
139
+ except Exception as e:
140
+ return f"Training error: {str(e)}\n\nNote: Make sure dataset is uploaded and formatted correctly"
141
+
142
+
143
+ def clear_annotations():
144
+ """Clear all annotations"""
145
+ global annotations, current_image_id
146
+ if current_image_id and current_image_id in annotations:
147
+ annotations[current_image_id] = {'boxes': [], 'labels': []}
148
+ return None, "Annotations cleared"
149
+
150
+
151
+ # ============================================
152
+ # Gradio Interface
153
+ # ============================================
154
+
155
+ with gr.Blocks(title="carioLabel - Web Edition", theme=gr.themes.Soft()) as demo:
156
+
157
+ gr.Markdown("""
158
+ # 🎯 carioLabel - Image Annotation Tool
159
+
160
+ **Features:**
161
+ - πŸ“¦ Bounding Box Annotation
162
+ - 🏷️ Label Management
163
+ - πŸ’Ύ Export to YOLO/Pascal VOC
164
+ - πŸš€ YOLO Training (on HF GPU)
165
+
166
+ **Instructions:**
167
+ 1. Upload an image
168
+ 2. Enter a label name
169
+ 3. Click on the image to add bounding boxes
170
+ 4. Export or train when ready
171
+ """)
172
+
173
+ with gr.Tab("πŸ“ Annotation"):
174
+ with gr.Row():
175
+ with gr.Column(scale=2):
176
+ input_image = gr.Image(
177
+ label="Upload Image",
178
+ type="pil"
179
+ )
180
+ output_image = gr.Image(
181
+ label="Annotated Image",
182
+ type="pil"
183
+ )
184
+
185
+ with gr.Column(scale=1):
186
+ label_input = gr.Textbox(
187
+ label="Label Name",
188
+ placeholder="e.g., cat, dog, person",
189
+ value="object"
190
+ )
191
+
192
+ status_text = gr.Textbox(
193
+ label="Status",
194
+ interactive=False
195
+ )
196
+
197
+ with gr.Row():
198
+ clear_btn = gr.Button("πŸ—‘οΈ Clear Annotations")
199
+ export_btn = gr.Button("πŸ’Ύ Export Annotations")
200
+
201
+ export_format = gr.Radio(
202
+ choices=["YOLO", "Pascal VOC"],
203
+ value="YOLO",
204
+ label="Export Format"
205
+ )
206
+
207
+ export_output = gr.Textbox(
208
+ label="Exported Annotations",
209
+ lines=10,
210
+ max_lines=20
211
+ )
212
+
213
+ with gr.Tab("πŸš€ YOLO Training"):
214
+ gr.Markdown("""
215
+ ### Train YOLO Model
216
+ Upload your dataset and start training on Hugging Face GPU!
217
+ """)
218
+
219
+ with gr.Row():
220
+ with gr.Column():
221
+ dataset_upload = gr.File(
222
+ label="Upload Dataset (ZIP)",
223
+ file_types=[".zip"]
224
+ )
225
+ epochs_slider = gr.Slider(
226
+ minimum=1,
227
+ maximum=100,
228
+ value=50,
229
+ step=1,
230
+ label="Epochs"
231
+ )
232
+ batch_size = gr.Slider(
233
+ minimum=1,
234
+ maximum=32,
235
+ value=16,
236
+ step=1,
237
+ label="Batch Size"
238
+ )
239
+ train_btn = gr.Button("🎯 Start Training", variant="primary")
240
+
241
+ with gr.Column():
242
+ training_output = gr.Textbox(
243
+ label="Training Log",
244
+ lines=15,
245
+ max_lines=30
246
+ )
247
+
248
+ with gr.Tab("ℹ️ About"):
249
+ gr.Markdown("""
250
+ ## carioLabel - Web Edition
251
+
252
+ **Version:** 1.0.0
253
+ **Author:** CareIO AI
254
+ **Contact:** herdodimas46@gmail.com
255
+ **Website:** https://www.careio.my.id
256
+
257
+ ### Features
258
+ - βœ… Browser-based annotation (no installation!)
259
+ - βœ… Support YOLO & Pascal VOC export
260
+ - βœ… GPU-accelerated training on HF Spaces
261
+ - βœ… Free to use!
262
+
263
+ ### Tech Stack
264
+ - Gradio (UI)
265
+ - Ultralytics YOLO
266
+ - PyTorch
267
+ - OpenCV
268
+
269
+ ---
270
+
271
+ **Note:** This is a demo version. For production use with large datasets,
272
+ consider using the desktop version or contact us for enterprise solutions.
273
+ """)
274
+
275
+ # Event handlers
276
+ input_image.change(
277
+ fn=load_image,
278
+ inputs=[input_image],
279
+ outputs=[output_image, status_text]
280
+ )
281
+
282
+ output_image.select(
283
+ fn=add_annotation,
284
+ inputs=[input_image, label_input],
285
+ outputs=[output_image, status_text]
286
+ )
287
+
288
+ clear_btn.click(
289
+ fn=clear_annotations,
290
+ outputs=[output_image, status_text]
291
+ )
292
+
293
+ export_btn.click(
294
+ fn=export_annotations,
295
+ inputs=[export_format],
296
+ outputs=[export_output]
297
+ )
298
+
299
+ train_btn.click(
300
+ fn=train_model_simple,
301
+ inputs=[dataset_upload, epochs_slider, batch_size],
302
+ outputs=[training_output]
303
+ )
304
+
305
+ # Launch
306
+ if __name__ == "__main__":
307
+ demo.launch()
requirements_hf.txt ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ gradio==4.44.0
2
+ ultralytics==8.3.0
3
+ torch==2.1.0
4
+ torchvision==0.16.0
5
+ opencv-python-headless==4.8.1.78
6
+ numpy==1.24.3
7
+ Pillow==10.1.0
8
+ pyyaml==6.0.1
9
+ tqdm==4.66.1
10
+ scipy==1.11.4