Skip to content

Commit 1c36c85

Browse files
committed
CLI Interface Created.
Signed-off-by: anex45 <[email protected]>
1 parent 6f60266 commit 1c36c85

File tree

7 files changed

+586
-3
lines changed

7 files changed

+586
-3
lines changed

CLI-COMMANDS.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,25 @@ $ roboflow --help
88
```
99

1010
```
11-
usage: roboflow [-h] {login,download,upload,import,infer,project,workspace} ...
11+
usage: roboflow [-h] {login,download,upload,import,infer,project,workspace,upload-dataset,list-datasets,list-models} ...
1212
1313
Welcome to the roboflow CLI: computer vision at your fingertips 🪄
1414
1515
options:
1616
-h, --help show this help message and exit
1717
1818
subcommands:
19-
{login,download,upload,import,infer,project,workspace}
19+
{login,download,upload,import,infer,project,workspace,upload-dataset,list-datasets,list-models}
2020
login Log in to Roboflow
2121
download Download a dataset version from your workspace or Roboflow Universe.
2222
upload Upload a single image to a dataset
2323
import Import a dataset from a local folder
2424
infer perform inference on an image
2525
project project related commands. type 'roboflow project' to see detailed command help
2626
workspace workspace related commands. type 'roboflow workspace' to see detailed command help
27+
upload-dataset Upload a dataset from a local folder to a Roboflow project
28+
list-datasets List all datasets in a workspace
29+
list-models List all models in a workspace
2730
```
2831

2932
## Authentication

CLI-COMMANDS.md.new

Lines changed: 344 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,344 @@
1+
# The roboflow-python command line
2+
This has the same capabilities of the [roboflow node cli](https://www.npmjs.com/package/roboflow-cli) so that our users don't need to install two different tools.
3+
4+
## See available commands
5+
6+
```bash
7+
$ roboflow --help
8+
```
9+
10+
```
11+
usage: roboflow [-h] {login,download,upload,import,infer,project,workspace,upload-dataset,list-datasets,list-models} ...
12+
13+
Welcome to the roboflow CLI: computer vision at your fingertips 🪄
14+
15+
options:
16+
-h, --help show this help message and exit
17+
18+
subcommands:
19+
{login,download,upload,import,infer,project,workspace,upload-dataset,list-datasets,list-models}
20+
login Log in to Roboflow
21+
download Download a dataset version from your workspace or Roboflow Universe.
22+
upload Upload a single image to a dataset
23+
import Import a dataset from a local folder
24+
infer perform inference on an image
25+
project project related commands. type 'roboflow project' to see detailed command help
26+
workspace workspace related commands. type 'roboflow workspace' to see detailed command help
27+
upload-dataset Upload a dataset from a local folder to a Roboflow project
28+
list-datasets List all datasets in a workspace
29+
list-models List all models in a workspace
30+
```
31+
32+
## Authentication
33+
34+
You need to authenticate first
35+
36+
```bash
37+
$ roboflow login
38+
```
39+
40+
```
41+
visit https://app.roboflow.com/auth-cli to get your authentication token.
42+
Paste the authentication token here:
43+
```
44+
Open that link on your browser, get the token, paste it on the terminal.
45+
The credentials get saved to `~/.config/roboflow/config.json`
46+
47+
## Display help usage for other commands
48+
49+
"How do I download stuff?"
50+
51+
```bash
52+
$ roboflow download --help
53+
```
54+
```
55+
usage: roboflow download [-h] [-f FORMAT] [-l LOCATION] datasetUrl
56+
57+
positional arguments:
58+
datasetUrl Dataset URL (e.g., `roboflow-100/cells-uyemf/2`)
59+
60+
options:
61+
-h, --help show this help message and exit
62+
-f FORMAT Specify the format to download the version. Available options: [coco, yolov5pytorch, yolov7pytorch, my-yolov6, darknet,
63+
voc, tfrecord, createml, clip, multiclass, coco-segmentation, yolo5-obb, png-mask-semantic, yolov8, yolov9]
64+
-l LOCATION Location to download the dataset
65+
```
66+
67+
"How do I import a dataset into my workspace?"
68+
69+
```bash
70+
$ roboflow import --help
71+
```
72+
73+
```
74+
usage: roboflow import [-h] [-w WORKSPACE] [-p PROJECT] [-c CONCURRENCY] [-f FORMAT] folder
75+
76+
positional arguments:
77+
folder filesystem path to a folder that contains your dataset
78+
79+
options:
80+
-h, --help show this help message and exit
81+
-w WORKSPACE specify a workspace url or id (will use default workspace if not specified)
82+
-p PROJECT project will be created if it does not exist
83+
-c CONCURRENCY how many image uploads to perform concurrently (default: 10)
84+
-n BATCH_NAME name of batch to upload to within project
85+
```
86+
87+
## Example: download dataset
88+
89+
Download [Joseph's chess dataset](https://universe.roboflow.com/joseph-nelson/chess-pieces-new/dataset/25) from Roboflow Universe in VOC format:
90+
91+
```bash
92+
$ roboflow download -f voc -l ~/tmp/chess joseph-nelson/chess-pieces-new/25
93+
```
94+
```
95+
loading Roboflow workspace...
96+
loading Roboflow project...
97+
Downloading Dataset Version Zip in /Users/tony/tmp/chess to voc:: 100%|██████████████████████████| 19178/19178 [00:01<00:00, 10424.62it/s]
98+
99+
Extracting Dataset Version Zip to /Users/tony/tmp/chess in voc:: 100%|██████████████████████████████| 1391/1391 [00:00<00:00, 8992.30it/s]
100+
```
101+
```bash
102+
$ ls -lh ~/tmp/chess
103+
total 16
104+
-rw-r--r--@ 1 tony staff 1.8K Jan 5 10:32 README.dataset.txt
105+
-rw-r--r--@ 1 tony staff 562B Jan 5 10:32 README.roboflow.txt
106+
drwxr-xr-x@ 60 tony staff 1.9K Jan 5 10:32 test
107+
drwxr-xr-x@ 1214 tony staff 38K Jan 5 10:32 train
108+
drwxr-xr-x@ 118 tony staff 3.7K Jan 5 10:32 valid
109+
```
110+
111+
## Example: import a dataset
112+
113+
Upload a dataset from a folder to a project in your workspace
114+
115+
```bash
116+
roboflow import -w my-workspace -p my-chess ~/tmp/chess
117+
```
118+
119+
```
120+
loading Roboflow workspace...
121+
loading Roboflow project...
122+
Uploading to existing project my-workspace/my-chess
123+
[UPLOADED] /home/jonny/tmp/chess/102_jpg.rf.205e2a0cb0fabbbf32b4a936e2d6f1e4.jpg (sFpTfnyLpLA8QcqPwdvf) / annotations = OK
124+
[UPLOADED] /home/jonny/tmp/chess/2_jpg.rf.c1a4ed4e0c3947743b22ede09f7e1212.jpg (wDA2yxnLJWY5YwYwO7dP) / annotations = OK
125+
[UPLOADED] /home/jonny/tmp/chess/221_jpg.rf.e841c9bbb31a135b8f6274643f522686.jpg (UCv7MeuvEqo7PYElatEn) / annotations = OK
126+
[UPLOADED] /home/jonny/tmp/chess/10_jpg.rf.841f3ccdfc4b93ee68566e602025c03f.jpg (HnkCpUcYzxStvQF49VQW) / annotations = OK
127+
[UPLOADED] /home/jonny/tmp/chess/130_jpg.rf.29f756d510d2e488eb5e12769c7707ff.jpg (WxrFIhfaJ9H1JvaXMgfF) / annotations = OK
128+
[UPLOADED] /home/jonny/tmp/chess/112_jpg.rf.1a6e7b87410fa3f787f10e82bd02b54e.jpg (7tWtAn573cKrefeg5pIO) / annotations = OK
129+
```
130+
131+
## Example: list workspaces
132+
List the workspaces you have access to
133+
134+
```bash
135+
$ roboflow workspace list
136+
```
137+
138+
```
139+
tonyprivate
140+
link: https://app.roboflow.com/tonyprivate
141+
id: tonyprivate
142+
143+
wolfodorpythontests
144+
link: https://app.roboflow.com/wolfodorpythontests
145+
id: wolfodorpythontests
146+
147+
test minimize
148+
link: https://app.roboflow.com/test-minimize
149+
id: test-minimize
150+
```
151+
152+
## Example: get workspace details
153+
154+
```bash
155+
$ roboflow workspace get tonyprivate
156+
```
157+
158+
```
159+
{
160+
"workspace": {
161+
"name": "tonyprivate",
162+
"url": "tonyprivate",
163+
"members": 4,
164+
"projects": [
165+
{
166+
"id": "tonyprivate/annotation-upload",
167+
"type": "object-detection",
168+
"name": "annotation-upload",
169+
"created": 1685199749.708,
170+
"updated": 1695910515.48,
171+
"images": 1,
172+
(...)
173+
}
174+
]
175+
}
176+
}
177+
```
178+
179+
## Example: list projects
180+
181+
```bash
182+
roboflow project list -w tonyprivate
183+
```
184+
```
185+
annotation-upload
186+
link: https://app.roboflow.com/tonyprivate/annotation-upload
187+
id: tonyprivate/annotation-upload
188+
type: object-detection
189+
versions: 0
190+
images: 1
191+
classes: dict_keys(['0', 'Rabbits1', 'Rabbits2', 'minion1', 'minion0', '5075E'])
192+
193+
hand-gestures
194+
link: https://app.roboflow.com/tonyprivate/hand-gestures-fsph8
195+
id: tonyprivate/hand-gestures-fsph8
196+
type: object-detection
197+
versions: 5
198+
images: 387
199+
classes: dict_keys(['zero', 'four', 'one', 'two', 'five', 'three', 'Guard'])
200+
```
201+
202+
## Example: get project details
203+
204+
```bash
205+
$ roboflow project get tonyprivate/hand-gestures-fsph8
206+
```
207+
208+
```
209+
{
210+
"project": {
211+
"id": "tonyprivate/hand-gestures-fsph8",
212+
"type": "object-detection",
213+
"name": "hand-gestures-fsph8",
214+
"created": 1685199749.708,
215+
"updated": 1695910515.48,
216+
"images": 387,
217+
"splits": {
218+
"train": 310,
219+
"valid": 39,
220+
"test": 38
221+
},
222+
"classes": {
223+
"zero": 55,
224+
"four": 55,
225+
"one": 55,
226+
"two": 55,
227+
"five": 55,
228+
"three": 55,
229+
"Guard": 57
230+
},
231+
"colors": {
232+
"zero": "#FF625A",
233+
"four": "#FF625A",
234+
"one": "#FF625A",
235+
"two": "#FF625A",
236+
"five": "#FF625A",
237+
"three": "#FF625A",
238+
"Guard": "#FF625A"
239+
},
240+
"annotation": "object-detection",
241+
"public": false,
242+
"versions": 5,
243+
"unannotated": 0
244+
}
245+
}
246+
```
247+
248+
## Example: upload a dataset
249+
250+
Upload a dataset from a folder to a new project in your workspace
251+
252+
```bash
253+
$ roboflow upload-dataset -w my-workspace -p new-project -t object-detection ~/datasets/my-dataset
254+
```
255+
256+
```
257+
loading Roboflow workspace...
258+
Created project my-workspace/new-project
259+
[UPLOADED] /home/user/datasets/my-dataset/image1.jpg (sFpTfnyLpLA8QcqPwdvf) / annotations = OK
260+
[UPLOADED] /home/user/datasets/my-dataset/image2.jpg (wDA2yxnLJWY5YwYwO7dP) / annotations = OK
261+
[UPLOADED] /home/user/datasets/my-dataset/image3.jpg (UCv7MeuvEqo7PYElatEn) / annotations = OK
262+
```
263+
264+
## Example: list datasets
265+
266+
List all datasets in your workspace
267+
268+
```bash
269+
$ roboflow list-datasets -w my-workspace
270+
```
271+
272+
```
273+
Datasets in workspace 'my-workspace':
274+
275+
chess-pieces
276+
ID: my-workspace/chess-pieces
277+
Type: object-detection
278+
Images: 1391
279+
Versions: 3
280+
Latest version: 3
281+
Classes: ['bishop', 'king', 'knight', 'pawn', 'queen', 'rook']
282+
283+
hand-gestures
284+
ID: my-workspace/hand-gestures
285+
Type: object-detection
286+
Images: 387
287+
Versions: 5
288+
Latest version: 5
289+
Classes: ['zero', 'four', 'one', 'two', 'five', 'three', 'Guard']
290+
```
291+
292+
## Example: list models
293+
294+
List all models in your workspace
295+
296+
```bash
297+
$ roboflow list-models -w my-workspace
298+
```
299+
300+
```
301+
Models in workspace 'my-workspace':
302+
303+
chess-pieces
304+
ID: my-workspace/chess-pieces
305+
Type: object-detection
306+
Model version 3:
307+
Created: 1685199749.708
308+
Type: object-detection
309+
ID: my-workspace/chess-pieces/3
310+
311+
hand-gestures
312+
ID: my-workspace/hand-gestures
313+
Type: object-detection
314+
Model version 4:
315+
Created: 1685199749.708
316+
Type: object-detection
317+
ID: my-workspace/hand-gestures/4
318+
Model version 5:
319+
Created: 1685199749.708
320+
Type: object-detection
321+
ID: my-workspace/hand-gestures/5
322+
```
323+
324+
## Example: list models for a specific project
325+
326+
```bash
327+
$ roboflow list-models -w my-workspace -p hand-gestures
328+
```
329+
330+
```
331+
Models in workspace 'my-workspace':
332+
333+
hand-gestures
334+
ID: my-workspace/hand-gestures
335+
Type: object-detection
336+
Model version 4:
337+
Created: 1685199749.708
338+
Type: object-detection
339+
ID: my-workspace/hand-gestures/4
340+
Model version 5:
341+
Created: 1685199749.708
342+
Type: object-detection
343+
ID: my-workspace/hand-gestures/5
344+
```

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,14 @@ pip install "roboflow[desktop]"
6969
<summary>Command line tool</summary>
7070

7171
By installing roboflow python package you can use some of its functionality in the command line (without having to write python code).
72-
See [CLI-COMMANDS.md](CLI-COMMANDS.md)
72+
See [CLI-COMMANDS.md](CLI-COMMANDS.md) for detailed usage instructions.
73+
74+
The CLI provides commands for common tasks including:
75+
- Uploading datasets
76+
- Downloading datasets
77+
- Listing projects and models
78+
- Running inference
79+
- Managing workspaces
7380
</details>
7481

7582

roboflow/cli/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# CLI module for Roboflow Python SDK

0 commit comments

Comments
 (0)