diff --git a/.gitignore b/.gitignore index 96a5f151..e4bf7f46 100644 --- a/.gitignore +++ b/.gitignore @@ -142,6 +142,7 @@ cython_debug/ #config stuff tests/config.json +tests/manual/data #dataset download stuff diff --git a/roboflowpy.py b/roboflowpy.py new file mode 100644 index 00000000..d63ff5f2 --- /dev/null +++ b/roboflowpy.py @@ -0,0 +1,54 @@ +import argparse +import roboflow + +def login(args): + roboflow.login() + +def download(args): + rf = roboflow.Roboflow() + w, p, v = args.datasetUrl.split("/") + format, location = args.f, args.l + project = rf.workspace(w).project(p) + project.version(int(v)).download(format, location=location, overwrite=True) + +def upload(args): + rf = roboflow.Roboflow() + f, w, p, folder = args.f, args.w, args.p, args.folder + workspace = rf.workspace(w) + workspace.upload_dataset( + dataset_path=folder, + dataset_format=f, + project_name=p, + ) + +def _argparser(): + parser = argparse.ArgumentParser(description="main description") + subparsers = parser.add_subparsers(title="subcommands") + login_parser = subparsers.add_parser("login", help="Log in to Roboflow") + login_parser.set_defaults(func=login) + download_parser = subparsers.add_parser("download", help="Download a dataset version from your workspace or Roboflow Universe.") + download_parser.add_argument("datasetUrl", help="Dataset URL (e.g., `roboflow-100/cells-uyemf/2`)") + download_parser.add_argument("-f", + choices=["coco", "yolov5pytorch", "yolov7pytorch", "my-yolov6", "darknet", "voc", "tfrecord", + "createml", "clip", "multiclass", "coco-segmentation", "yolo5-obb", "png-mask-semantic", "yolov8"], + help="Specify the format to download the version in (default: interactive prompt)") + download_parser.add_argument("-l", help="Location to download the dataset") + download_parser.set_defaults(func=download) + upload_parser = subparsers.add_parser("upload", help="Upload a dataset") + upload_parser.add_argument("folder", help="filesystem path to a folder that contains your dataset") + upload_parser.add_argument("-w", help="workspace url") + upload_parser.add_argument("-p", help="Project name") + upload_parser.add_argument("-f", choices=["voc", "yolov8", "yolov5"], help="format") + upload_parser.set_defaults(func=upload) + return parser + +def main(): + parser = _argparser() + args = parser.parse_args() + if hasattr(args, 'func'): + args.func(args) + else: + parser.print_help() + +if __name__ == "__main__": + main() diff --git a/tests/manual/debugme.py b/tests/manual/debugme.py new file mode 100644 index 00000000..138686ac --- /dev/null +++ b/tests/manual/debugme.py @@ -0,0 +1,26 @@ +import sys +import os + +thisdir = os.path.dirname(os.path.abspath(__file__)) +rootdir = os.path.abspath(f"{thisdir}/../..") +os.environ["ROBOFLOW_CONFIG_DIR"] = f"{thisdir}/data/.config" +sys.path.append(rootdir) + +from roboflowpy import _argparser + +if __name__ == "__main__": + parser = _argparser() + args = parser.parse_args(["login"]) + # args = parser.parse_args( + # [ + # "upload", + # "./data/cultura-pepino-voc", + # "-w", + # "wolfodorpythontests", + # "-p", + # "cultura-pepino-upload-test-voc", + # "-f", + # "voc", + # ] + # ) + args.func(args) diff --git a/tests/manual/download.sh b/tests/manual/download.sh new file mode 100755 index 00000000..0f577901 --- /dev/null +++ b/tests/manual/download.sh @@ -0,0 +1,15 @@ +export ROBOFLOW_CONFIG_DIR=./data/.config +# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f coco -l ./data/cultura-pepino-coco +# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f yolov5pytorch -l ./data/cultura-pepino-yolov5pytorch +# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f yolov7pytorch -l ./data/cultura-pepino-yolov7pytorch +# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f my-yolov6 -l ./data/cultura-pepino-my-yolov6 +# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f darknet -l ./data/cultura-pepino-darknet +# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f voc -l ./data/cultura-pepino-voc +# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f tfrecord -l ./data/cultura-pepino-tfrecord +# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f createml -l ./data/cultura-pepino-createml +# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f clip -l ./data/cultura-pepino-clip +# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f multiclass -l ./data/cultura-pepino-multiclass +# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f coco-segmentation -l ./data/cultura-pepino-coco-segmentation +# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f yolo5-obb -l ./data/cultura-pepino-yolo5-obb +python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f yolov8 -l ./data/cultura-pepino-yolov8 +# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f png-mask-semantic -l ./data/cultura-pepino-png-mask-semantic diff --git a/tests/manual/login.sh b/tests/manual/login.sh new file mode 100755 index 00000000..94fc0e38 --- /dev/null +++ b/tests/manual/login.sh @@ -0,0 +1,2 @@ +export ROBOFLOW_CONFIG_DIR=./data/.config +python ../../roboflowpy.py login diff --git a/tests/manual/upload.sh b/tests/manual/upload.sh new file mode 100755 index 00000000..7fdfbe55 --- /dev/null +++ b/tests/manual/upload.sh @@ -0,0 +1,4 @@ +export ROBOFLOW_CONFIG_DIR=./data/.config +# python ../../roboflowpy.py upload ./data/cultura-pepino-voc -w wolfodorpythontests -p cultura-pepino-upload-test-voc -f voc +python ../../roboflowpy.py upload ./data/cultura-pepino-yolov8 -w wolfodorpythontests -p cultura-pepino-upload-test-yolov8 -f yolov8 +# python ../../roboflowpy.py upload ./data/cultura-pepino-yolov5pytorch -w wolfodorpythontests -p cultura-pepino-upload-test-yolov5 -f yolov5 diff --git a/tests/manual/useprod b/tests/manual/useprod new file mode 100644 index 00000000..9b326535 --- /dev/null +++ b/tests/manual/useprod @@ -0,0 +1,2 @@ +export API_URL=https://api.roboflow.com +export APP_URL=https://app.roboflow.com diff --git a/tests/manual/usestaging b/tests/manual/usestaging new file mode 100644 index 00000000..d9a06980 --- /dev/null +++ b/tests/manual/usestaging @@ -0,0 +1,2 @@ +export API_URL=https://api.roboflow.one +export APP_URL=https://app.roboflow.one