Provided google colab notebook is not working

#2
by PracePartap - opened

getting
yolovv11
ImportError: cannot import name 'YOLOvv11' from 'ultralytics' (/usr/local/lib/python3.12/dist-packages/ultralytics/init.py)

Hi @PracePartap , thank you for the interest in the model! I don't recall having a shared notebook in the project and cannot seem to be able to find it, maybe was an old version committed. You can however either access tha hf space that provides an intuitive interface to interact with the different models, or alternatively use the code below to use the model in the notebook, from the github repository:

from pathlib import Path
from huggingface_hub import hf_hub_download
from ultralytics import YOLO

# Define the local directory to save models
DOWNLOAD_PATH = Path("./models")
DOWNLOAD_PATH.mkdir(exist_ok=True)

# Choose which model to use
# 0: nano, 1: small, 2: medium
model_files = [
    "yolo11n_doc_layout.pt",
    "yolo11s_doc_layout.pt",
    "yolo11m_doc_layout.pt",
]
selected_model_file = model_files[0] # Using the recommended nano model

# Download the model from the Hugging Face Hub
model_path = hf_hub_download(
    repo_id="Armaggheddon/yolo11-document-layout",
    filename=selected_model_file,
    repo_type="model",
    local_dir=DOWNLOAD_PATH,
)

# Initialize the YOLO model
model = YOLO(model_path)

# Run inference on an image
# Replace 'path/to/your/document.jpg' with your file
results = model('path/to/your/document.jpg')

# Save the results
results[0].save(filename="result.jpg")

and edit it as you prefer.

Sign up or log in to comment