Getting started overview
This guide provides a structured approach to initiating development with Roboflow Universe. It focuses on the essential steps required to register for an account, obtain necessary authentication credentials, and execute a foundational API request. Roboflow Universe functions as a repository for pre-trained computer vision models and datasets, facilitating their discovery and use in various applications What is Roboflow Universe. By following these steps, developers can integrate existing models into their projects without extensive prior training.
The process involves:
- Account Creation: Registering for a Roboflow account.
- API Key Retrieval: Locating and securing your personal API key.
- First Request: Performing an inference call against a public model using the Roboflow Inference API Roboflow Inference API reference.
Quick Reference: Getting Started Steps
| Step | Action | Where |
|---|---|---|
| 1. Create Account | Register for a free Roboflow account. | Roboflow Login/Signup page |
| 2. Get API Key | Locate your API key in your account settings. | Roboflow API Keys documentation |
| 3. Select Model | Browse and select a public model from Roboflow Universe. | Roboflow Universe website |
| 4. Make Request | Send an inference request using the chosen model and your API key. | Code editor (e.g., Python, JavaScript) |
Create an account and get keys
To begin using Roboflow Universe, you must first create a Roboflow account. Roboflow offers a free tier that includes up to 1,000 images and 1,000 inferences, suitable for initial exploration and development Roboflow pricing page.
Account Creation
- Navigate to the Roboflow login page.
- Select the option to 'Sign up'. You can register using an email address, or through third-party authentication providers such as Google or GitHub.
- Follow the on-screen prompts to complete your registration. This may include verifying your email address.
API Key Retrieval
After creating and logging into your account, you will need to retrieve your unique API key. This key authenticates your requests to the Roboflow API, including calls to Roboflow Universe models.
- Once logged in, navigate to your account settings or dashboard.
- Look for a section labeled 'API Keys' or 'Settings' that contains your developer credentials. The exact location may vary, but it's typically found under user profile or project settings Roboflow API Keys documentation.
- Your API key will be displayed. It is a long alphanumeric string. Copy this key and store it securely. Treat your API key as sensitive information, similar to a password, to prevent unauthorized access to your account and usage.
Your first request
After obtaining your API key, you can make your first inference request to a model hosted on Roboflow Universe. This example uses Python, as it is one of the primary languages supported by Roboflow SDKs Roboflow SDKs documentation.
1. Select a Public Model
Browse Roboflow Universe to find a public model suitable for your test. For this example, we'll use a widely available object detection model. Note the model's workspace and model_id from its Universe page URL (e.g., universe.roboflow.com/[workspace]/[model_id]).
2. Prepare Your Environment
Install the Roboflow Python package:
pip install roboflow
Alternatively, if you prefer not to use the SDK, you can make direct HTTP requests as described in the Roboflow Inference API reference. For HTTP requests, you would typically use a library like requests in Python or fetch in JavaScript.
3. Write the Code for Inference
This example demonstrates how to perform object detection on an image using a public Roboflow Universe model. Replace YOUR_API_KEY, YOUR_WORKSPACE, YOUR_MODEL_ID, and YOUR_IMAGE_PATH with your specific details.
from roboflow import Roboflow
import os
# Ensure you have your API key set as an environment variable or replace it directly
# For production, using environment variables is recommended for security.
api_key = os.environ.get("ROBOFLOW_API_KEY", "YOUR_API_KEY")
# Initialize Roboflow
rf = Roboflow(api_key=api_key)
# Specify the workspace and model ID from Roboflow Universe
# Example: If the URL is universe.roboflow.com/my-workspace/my-model-id/1
workspace_name = "YOUR_WORKSPACE" # e.g., "hard-hat-detection"
model_id = "YOUR_MODEL_ID" # e.g., "hard-hat-detection-v1"
version = 1 # Use the latest version or a specific one
# Load the model
project = rf.workspace(workspace_name).project(model_id)
model = project.version(version).model
# Example image path (ensure this image exists in your directory)
# You can download a sample image or use one from your local machine.
image_path = "YOUR_IMAGE_PATH" # e.g., "./test_image.jpg"
# Perform inference
try:
# Prediction takes an image path or a NumPy array
predictions = model.predict(image_path, confidence=40, overlap=30).json()
print("Inference successful!")
print(f"Detected {len(predictions['predictions'])} objects.")
for p in predictions['predictions']:
print(f" Class: {p['class']}, Confidence: {p['confidence']:.2f}, Box: ({p['x']:.0f}, {p['y']:.0f}, {p['width']:.0f}, {p['height']:.0f})")
# Optionally, visualize the results (requires OpenCV and Pillow)
# model.predict(image_path, confidence=40, overlap=30).save("prediction.jpg")
# print("Prediction image saved as prediction.jpg")
except Exception as e:
print(f"An error occurred during inference: {e}")
4. Execute the Code
Save the code as a .py file (e.g., first_inference.py) and run it from your terminal:
python first_inference.py
The output will display the detected objects, their classes, confidence scores, and bounding box coordinates. If you uncomment the visualization line, an image with bounding boxes drawn will be saved.
Common next steps
After successfully performing your first inference, several paths can extend your work with Roboflow Universe:
- Explore More Models: Investigate other models on Roboflow Universe. Models cover various computer vision tasks, including classification, segmentation, and pose estimation.
- Integrate into Applications: Embed the inference capabilities into your web, mobile, or edge applications. Roboflow provides SDKs for JavaScript and Flutter, in addition to Python, to facilitate this Roboflow SDKs documentation.
- Custom Model Training: If existing models do not meet specific requirements, consider creating and training your own custom models using the broader Roboflow platform. This involves data annotation with Roboflow Annotate and model training with Roboflow Train.
- Deployment to Edge Devices: Deploy trained models to devices like NVIDIA Jetson, Raspberry Pi, or Google Coral for on-device inference Roboflow Deploy documentation.
- Review API Documentation: For advanced usage, including batch inference, model versioning, and specific API endpoints, refer to the Roboflow Inference API reference. Understanding RESTful API principles can be beneficial for direct HTTP integrations Mozilla Developer Network REST glossary.
Troubleshooting the first call
If your initial inference request encounters issues, consider the following common troubleshooting steps:
- API Key Validity: Double-check that your API key is correct and has not expired. Ensure there are no leading or trailing spaces if copied manually. The key must be passed correctly in your code or API request headers.
- Network Connectivity: Verify that your development environment has an active internet connection and can reach Roboflow's API endpoints. Proxy settings or firewalls might block outgoing requests.
- Model ID and Workspace: Confirm that the
workspace_nameandmodel_idused in your code exactly match those of the public model you selected from Roboflow Universe. These are case-sensitive. - Image Path/Format: Ensure the
image_pathpoints to a valid image file on your local system. Check that the image format (e.g., JPG, PNG) is supported by Roboflow. Corrupted or unsupported image files can cause errors. - Roboflow Package Version: If using the Python SDK, ensure you have the latest version installed (
pip install --upgrade roboflow). Outdated packages might have compatibility issues. - Error Messages: Carefully read any error messages returned by the API or the SDK. They often provide specific clues about what went wrong. Common errors include
401 Unauthorized(API key issue) or404 Not Found(incorrect model/workspace). - Rate Limiting: While unlikely for a first call, be aware that APIs often have rate limits. If you're rapidly sending requests, you might temporarily hit a limit. Consult the Roboflow API rate limits documentation.
- Environment Variables: If you are using environment variables for your API key, ensure they are correctly set and accessible by your script. For example, on Linux/macOS:
export ROBOFLOW_API_KEY="YOUR_API_KEY"before running the script.