Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions roboflow/core/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
from roboflow.models.vlm import VLMModel
from roboflow.util.annotations import amend_data_yaml
from roboflow.util.general import extract_zip, write_line
from roboflow.util.model_processor import process, validate_model_type_for_project
from roboflow.util.versions import get_model_format, get_wrong_dependencies_versions, normalize_yolo_model_type
from roboflow.util.model_processor import package_custom_weights_interactive, validate_model_type_for_project
from roboflow.util.versions import get_model_format, get_wrong_dependencies_versions

if TYPE_CHECKING:
import numpy as np
Expand Down Expand Up @@ -497,14 +497,10 @@ def deploy(self, model_type: str, model_path: str, filename: str = "weights/best
model_path (str): File path to the model weights to be uploaded.
filename (str, optional): The name of the weights file. Defaults to "weights/best.pt".
"""
model_type = normalize_yolo_model_type(model_type)
zip_file_name, model_type = process(model_type, model_path, filename)
bundle = package_custom_weights_interactive(model_type, model_path, filename, build_dir=model_path)

if zip_file_name is None:
raise RuntimeError("Failed to process model")

self._validate_against_project_type(model_type)
self._upload_zip(model_type, model_path, zip_file_name)
self._validate_against_project_type(bundle.model_type)
self._upload_zip(bundle.model_type, model_path, bundle.archive_path.name)

def _validate_against_project_type(self, model_type: str) -> None:
validate_model_type_for_project(model_type, self.type, self.project)
Expand Down
16 changes: 7 additions & 9 deletions roboflow/core/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,8 +787,10 @@ def deploy_model(
filename (str, optional): The name of the weights file. Defaults to "weights/best.pt".
"""

from roboflow.util.model_processor import process, validate_model_type_for_project
from roboflow.util.versions import normalize_yolo_model_type
from roboflow.util.model_processor import (
package_custom_weights_interactive,
validate_model_type_for_project,
)

if not project_ids:
raise ValueError("At least one project ID must be provided")
Expand All @@ -800,16 +802,12 @@ def deploy_model(
if project_id not in projects_by_id:
raise ValueError(f"Project {project_id} is not accessible in this workspace")

model_type = normalize_yolo_model_type(model_type)
zip_file_name, model_type = process(model_type, model_path, filename)

if zip_file_name is None:
raise RuntimeError("Failed to process model")
bundle = package_custom_weights_interactive(model_type, model_path, filename, build_dir=model_path)

for project_id in project_ids:
validate_model_type_for_project(model_type, projects_by_id[project_id].get("type", ""), project_id)
validate_model_type_for_project(bundle.model_type, projects_by_id[project_id].get("type", ""), project_id)

self._upload_zip(model_type, model_path, project_ids, model_name, zip_file_name)
self._upload_zip(bundle.model_type, model_path, project_ids, model_name, bundle.archive_path.name)

def _upload_zip(
self,
Expand Down
Loading
Loading