Package: roboflow
notebooks|inference|autodistill|collect|supervisionRoboflow Python PackageRoboflowprovides everything you need to build and deploy computer vision models.roboflow-pythonis the official Roboflow Python package.roboflow-pythonenables you to interact with models, datasets, and projects hosted on Roboflow.With this Python package, you can:Create and manage projects;Upload images, annotations, and datasets to manage in Roboflow;Start training vision models on Roboflow;Run inference on models hosted on Roboflow, or Roboflow models self-hosted viaRoboflow Inference, and more.The Python package is documented on theofficial Roboflow documentation site. If you are developing a feature for this Python package, or need a full Python library reference, refer to thepackage developer documentation.💻 InstallationYou will need to havePython 3.8or higher set up to use the Roboflow Python package.Run the following command to install the Roboflow Python package:pipinstallroboflowInstall from sourceYou can also install the Roboflow Python package from source using the following commands:gitclonehttps://github.com/roboflow-ai/roboflow-python.gitcdroboflow-python
python3-mvenvenvsourceenv/bin/activate
pip3install-rrequirements.txtCommand line toolBy installing roboflow python package you can use some of its functionality in the command line (without having to write python code).
SeeCLI-COMMANDS.md🚀 Getting StartedTo use the Roboflow Python package, you first need to authenticate with your Roboflow account. You can do this by running the following command:importroboflowroboflow.login()Authenticate with an API keyYou can also authenticate with an API key by using the following code:importroboflowrf=roboflow.Roboflow(api_key="")Learn how to retrieve your Roboflow API key.QuickstartBelow are some common methods used with the Roboflow Python package, presented concisely for reference. For a full library reference, refer to theRoboflow API reference documentation.importroboflowroboflow.login()rf=roboflow.Roboflow()# create a projectrf.create_project(project_name="project name",project_type="project-type",license="project-license"# "private" for private projects)workspace=rf.workspace("WORKSPACE_URL")project=workspace.project("PROJECT_URL")version=project.version("VERSION_NUMBER")# upload a datasetproject.upload_dataset(dataset_path="./dataset/",num_workers=10,dataset_format="yolov8",# supports yolov8, yolov5, and Pascal VOCproject_license="MIT",project_type="object-detection")# upload model weightsversion.deploy(model_type="yolov8",model_path=f”{HOME}/runs/detect/train/”)# run inferencemodel=version.modelimg_url="https://media.roboflow.com/quickstart/aerial_drone.jpeg"predictions=model.predict(img_url,hosted=True).json()print(predictions)Library StructureThe Roboflow Python library is structured using the same Workspace, Project, and Version ontology that you will see in the Roboflow application.importroboflowroboflow.login()rf=roboflow.Roboflow()workspace=rf.workspace("WORKSPACE_URL")project=workspace.project("PROJECT_URL")version=project.version("VERSION_NUMBER")The workspace, project, and version parameters are the same that you will find in the URL addresses at app.roboflow.com and universe.roboflow.com.Within the workspace object you can perform actions like making a new project, listing your projects, or performing active learning where you are using predictions from one project's model to upload images to a new project.Within the project object, you can retrieve metadata about the project, list versions, generate a new dataset version with preprocessing and augmentation settings, train a model in your project, and upload images and annotations to your project.Within the version object, you can download the dataset version in any model format, train the version on Roboflow, and deploy your own external model to Roboflow.🏆 ContributingWe would love your input on how we can improve the Roboflow Python package! Please see ourcontributing guideto get started. Thank you 🙏 to all our contributors!