Ultralytics YOLO27: انضم إلى قائمة الانتظار.
ابدأ


Ultralytics YOLO banner

中文 · 한국어 · 日本語 · Русский · Deutsch · Français · Español · Português · Türkçe · Tiếng Việt · العربية


Ultralytics CI Ultralytics Downloads Ultralytics Discord Ultralytics Forums Ultralytics Reddit
Run Ultralytics on Gradient Open Ultralytics In Colab Open Ultralytics In Kaggle Open Ultralytics In Binder

وثائق Ultralytics YOLO#

Ultralytics YOLO عائلة من النماذج الآنية لـالرؤية الحاسوبية، تشمل كشف الأجسام، وتقسيم المثيلات، والتقسيم الدلالي، وتقدير العمق، والتصنيف، وتقدير الوضعية، ومربعات الإحاطة الموجّهة، والتتبع، وهي متاحة عبر حزمة Python واحدة وواجهة CLI. يستند YOLO26 إلى أحدث أبحاث التعلم العميق، مع استدلال اختياري شامل من دون NMS ونشر مُحسّن على الأجهزة الطرفية. ويتكيف تصميمه المبسّط مع نطاق واسع من التطبيقات والأجهزة، من الأجهزة الطرفية إلى واجهات API السحابية. لأعباء العمل الإنتاجية المستقرة، يُوصى بكل من YOLO26 وYOLO11.

استكشف وثائق Ultralytics، وهي مرجع شامل يغطي حزمة YOLO وواجهة CLI، إلى جانب منصة Ultralytics، التي تضيف تعليقات توضيحية للبيانات والتدريب السحابي والنشر إلى النماذج نفسها. سواء أكنت ممارسًا متمرسًا في التعلم الآلي أم جديدًا في المجال، تساعدك هذه الموارد على تحقيق أقصى استفادة من YOLO في مشاريعك.

اطلب ترخيص Enterprise للاستخدام التجاري عبر ترخيص Ultralytics.

قريبًا: YOLO27

استكشف معاينة YOLO27، بما في ذلك تفاصيل البنية والمعايير الأولية وأمثلة على الاستخدام بعد الإصدار. تخضع النماذج حاليًا للمراحل النهائية من البحث والتطوير استعدادًا لإطلاق متوقع في وقت لاحق من هذا العام؛ وهي غير متاحة بعد، ولم يُحدَّد موعد للإطلاق.

🚀 جديد: تقدير العمق أحادي العين

حوّل صورة واحدة إلى خريطة عمق، بحيث تمثل كل قيمة فيها مسافةً بالأمتار لكل بكسل.

تعرّف على المزيد

ابدأ باستخدام أمرين#

# Install the ultralytics package from PyPI
pip install ultralytics

# Detect objects in an image with a pretrained YOLO26 model
yolo predict model=yolo26n.pt source='https://github.com/ultralytics/assets/releases/download/v0.0.0/bus.jpg'

يُنزَّل وزن النموذج والصورة النموذجية تلقائيًا، وتُحفَظ النتيجة المشروحة في المجلد الذي يطبعه الأمر، runs/detect/predict، عند التشغيل الأول.

اطّلع على دليل البدء السريع لمعرفة جميع طرق التثبيت وتنفيذ أول عملية تنبؤ.

ما الذي تريد فعله؟#

درّب نموذجًا على مجموعة بياناتك

أجرِ ضبطًا دقيقًا لـنموذج YOLO26 مدرّب مسبقًا على مجموعة بياناتك، واضبط زيادة البيانات والمعلمات الفائقة للتدريب باستخدام وحدات GPU متعددة.


درّب نموذجًا مخصصًا

شغّل نموذجًا على صورك أو مقاطع الفيديو لديك

حمّل نموذجًا مدرّبًا مسبقًا واحصل على الصناديق المحيطة أو الأقنعة أو النقاط المفتاحية باستخدام بضعة أسطر من Python أو أمر CLI واحد


نفّذ تنبؤًا على بيانات جديدة

تعقّب الأجسام عبر إطارات الفيديو

تعقّب الأجسام باستخدام معرّفات ثابتة عبر TrackTrack (الافتراضي) أو BoT-SORT أو ByteTrack أو OC-SORT أو Deep OC-SORT أو FastTracker


تعقّب أجسام متعددة

شغّل تطبيقًا جاهزًا للرؤية الحاسوبية

تطبيقات جاهزة للرؤية الحاسوبية لعدّ الأجسام وإنشاء الخرائط الحرارية وإدارة الطوابير وإنذارات الأمن والتمارين الرياضية، من دون الحاجة إلى التدريب


استكشف الحلول

انشر نموذجك

صدّر النماذج المدرّبة إلى ONNX أو TensorRT أو OpenVINO للاستدلال السريع على الأجهزة الطرفية والهواتف المحمولة والخوادم السحابية


التصدير والنشر

اختر النموذج المناسب

قارن YOLO26 وYOLO11 وSAM 3 وRT-DETR وجميع البنى الأخرى المدعومة من حيث السرعة والدقة وحالات الاستخدام


تصفّح جميع النماذج

ابحث في Python API

ابحث عن الفئات والدوال وتواقيع الأساليب في Python API، المُنشأة تلقائيًا من المصدر مع كل إصدار جديد


مرجع API

الجديد: YOLO26

تقدم أحدث عائلة نماذج أصدرتها Ultralytics خيار الاستدلال الشامل من دون NMS وموازنةً محسّنة بين الدقة وزمن الاستجابة مقارنةً بـ YOLO11


تعرّف على YOLO26

كيف نُظّمت هذه الوثائق؟#

تتبع معظم أوامر سير عمل النماذج yolo صيغةً واحدة، هي yolo [TASK] MODE ARGS، حيث تكون Task اختيارية، وقد نُظّمت هذه الوثائق حول الأجزاء الثلاثة نفسها، بالإضافة إلى اختصار واحد:

يدعم كل ما عدا ذلك هذه الصيغة: تسرد النماذج جميع البنى التي يمكنك تمريرها إلى model= — مثل YOLO26 وYOLO11 وSAM 3 وRT-DETR وغيرها — وتوفر مجموعات البيانات ما يلزم لكل مهمة للتدريب عليه، بينما تضم الأدلة مجموعة واسعة من الشروحات التفصيلية حول النشر على الأجهزة وضبط المعلمات الفائقة وتحويل مجموعات البيانات واستعراض المشاريع كاملةً، وتربط عمليات التكامل خط المعالجة بأدوات التدريب والنشر التي تستخدمها بالفعل، ويوثّق قسم المرجع كل فئة ودالة في Python API.

إلى جانب حزمة Python، تعمل واجهتان إضافيتان على النماذج نفسها: منصة Ultralytics للتعليق والتدريب والنشر السحابي، وUltralytics Inference، وهي مكتبة Rust مستقلة وواجهة CLI لتشغيل النماذج المُصدَّرة من دون بيئة تشغيل Python.

تراخيص YOLO: ما نوع الترخيص الذي يخضع له Ultralytics YOLO؟#

Ultralytics Enterprise License banner

تقدم Ultralytics خيارين للترخيص لتلبية حالات الاستخدام المتنوعة:

  • ترخيص AGPL-3.0: هذا الترخيص مفتوح المصدر المعتمد من OSI مثالي للطلاب والهواة، ويعزز التعاون المفتوح وتبادل المعرفة. راجع ملف LICENSE لمزيد من التفاصيل.
  • ترخيص المؤسسات: يتيح هذا الترخيص استخدام برامج Ultralytics ونماذج الذكاء الاصطناعي في التطوير والإنتاج، ودمجها في منتجات وخدمات الأعمال، بما في ذلك الأدوات الداخلية وسير العمل المؤتمت وعمليات النشر الإنتاجية، مع تجاوز متطلبات المصدر المفتوح الخاصة بـ AGPL-3.0. للبدء، يُرجى التواصل معنا عبر ترخيص Ultralytics.

صُممت استراتيجية الترخيص لدينا لضمان إعادة أي تحسينات تُجرى على مشاريعنا مفتوحة المصدر إلى المجتمع. نؤمن بالمصدر المفتوح، وتتمثل مهمتنا في ضمان إمكانية استخدام مساهماتنا وتطويرها بطرق تعود بالنفع على الجميع.

الأسئلة الشائعة#

  • Ultralytics YOLO عائلة من نماذج «انظر مرة واحدة» (YOLO) الآنية لكشف الأجسام وتقسيم الصور. ويستند أحدث نموذج مُصدَر، YOLO26، إلى الإصدارات السابقة، إذ يقدّم استدلالًا شاملًا اختياريًا من دون NMS ونشرًا مُحسّنًا على الأجهزة الطرفية. يدعم YOLO مجموعة متنوعة من مهام الذكاء الاصطناعي البصري، مثل الكشف، وتقسيم المثيلات، والتقسيم الدلالي، وتقدير العمق، والتصنيف، وتقدير الوضعية، ومربعات الإحاطة الموجّهة، كما يمكنه تتبع الأجسام المكتشفة عبر إطارات الفيديو. يوازن تصميمه الفعّال بين السرعة والدقة، ما يجعله مناسبًا لتطبيقات تتراوح من الأجهزة الطرفية إلى واجهات API السحابية.

  • البدء باستخدام YOLO سريع وبسيط. ثبّت حزمة Ultralytics من pip باستخدام pip install ultralytics، ثم نفّذ أول عملية تنبؤ باستخدام yolo predict model=yolo26n.pt — إذ تُنزَّل أوزان النموذج تلقائيًا. للاطلاع على تعليمات شاملة تشمل conda وDocker والتثبيت من المصدر، تفضل بزيارة صفحة البدء السريع.

  • يتضمن تدريب نموذج YOLO مخصص على مجموعة بياناتك ثلاث خطوات:

    1. جهّز مجموعة البيانات المشروحة وصفها في ملف YAML لمجموعة البيانات.
    2. حمّل نموذجًا مدرّبًا مسبقًا، مثل YOLO("yolo26n.pt") في Python.
    3. ابدأ التدريب باستخدام model.train(data="path/to/dataset.yaml", epochs=100, imgsz=640)، أو من سطر الأوامر باستخدام yolo detect train data=path/to/dataset.yaml epochs=100 imgsz=640.

    للاطلاع على شرح تفصيلي خطوة بخطوة، راجع دليل تدريب نموذج، الذي يتضمن أمثلة ونصائح لتحسين عملية التدريب.

  • تقدم Ultralytics خيارين لترخيص YOLO:

    • ترخيص AGPL-3.0: هذا الترخيص مفتوح المصدر مثالي للاستخدام التعليمي وغير التجاري، ويعزز التعاون المفتوح.
    • ترخيص Enterprise: للاستخدام في التطوير والإنتاج، بما في ذلك الأدوات الداخلية وسير العمل المؤتمت وعمليات النشر الإنتاجية، مع تجاوز متطلبات المصدر المفتوح الخاصة بـ AGPL-3.0.

    للمزيد من التفاصيل، تفضل بزيارة صفحة الترخيص.

  • يدعم Ultralytics YOLO تعقّب الأجسام المتعددة بكفاءة وإمكانية التخصيص. استدعِ YOLO("yolo26n.pt").track(source="path/to/video.mp4") في Python، أو شغّل yolo track source=path/to/video.mp4 من سطر الأوامر — فكلاهما يعمل مع ملفات الفيديو والبث المباشر ومدخلات كاميرا الويب. للاطلاع على دليل تفصيلي لإعداد تعقّب الأجسام وتشغيله، راجع وثائق نمط التعقّب، التي تشرح الإعدادات والتطبيقات العملية في السيناريوهات الآنية.


Ultralytics GitHub Ultralytics LinkedIn Ultralytics Twitter Ultralytics YouTube Ultralytics TikTok Ultralytics BiliBili Ultralytics Discord

التعليقات689

اطرح سؤالًا، وشارك نتائجك، أو ساعد شخصًا آخر.

  1. Glenn JocherGlenn JocherUltralytics

    Hi everyone 👋! I created this new comments section in our Docs 📚 so you can provide feedback! Tell us what you like and what you don't like, and we'll do our best to improve the Docs to be more informative and helpful for everyone. Thank you 🙏

    11
    1. Glenn JocherGlenn JocherUltralytics

      nn.SiLU() is the default YOLOv8 activation, but it is not used in output layers, only internally after convolution + BN layers. Externally outputs are either in logits or pass through Sigmoid() activations.

    2. AmeerAlahmadiAmeerAlahmadiGitHub

      can you please explain how to convert yolov8 to edgetpu to be used with coral usb accelerator and raspberry pi 4?

    3. ndneshndneshGitHub

      Has anyone tested the Nvidia A16 against MultiGPU training? I have 1 Nvidia A16 (note that it's a GPU which has 4x A2 cores on each Physical board). And when trying with Multi-GPU training, even with the default models/ code given above, it fails and crashes my server.

    4. Paula DerrengerPaula DerrengerUltralytics

      @ndnesh i'm sorry to hear you're experiencing issues with Multi-GPU training on the Nvidia A16. We haven't received similar reports yet. Could you please open a new issue on the Ultralytics YOLOv8 GitHub repo with the error logs and details about your setup? This will help us diagnose the problem and provide a solution. Make sure to include information such as the command you're running, the output leading up to the crash, and any modifications you've made to the code or environment. 🛠️

    1. Glenn JocherGlenn JocherUltralytics

      Thank you for the kind words about the documentation! However, I'd like to point you to our official documentation at docs.ultralytics.com which is the most up-to-date and comprehensive resource for YOLOv8. We're constantly working to improve it and make it more accessible for users at all levels. Your feedback helps us continue to enhance the experience!

    1. Paula DerrengerPaula DerrengerUltralytics

      您好!😊 如果您想在C#环境中调用YOLOv8模型,建议导出模型到ONNX格式,然后使用比如Microsoft.ML.OnnxRuntime库来加载和使用ONNX模型。

      这里有一个基本步骤示例:

      1. 导出模型到ONNX格式: 使用CLI命令:

        yolo export model=yolov8n.pt format=onnx
      2. 在C#中使用ONNX Runtime加载和使用模型:

        using Microsoft.ML.OnnxRuntime;
        using Microsoft.ML.OnnxRuntime.Tensors;
        
        // 加载模型
        var session = new InferenceSession("path_to_your_model.onnx");
        
        // 创建一个输入张量
        var inputMeta = session.InputMetadata;
        var inputTensor = new DenseTensor<float>(new[] {1, 3, 640, 640}); // 假设输入是1x3x640x640
        
        // 创建一个名字到张量的映射,并进行预测
        var inputs = new List<NamedOnnxValue>
        {
            NamedOnnxValue.CreateFromTensor("input_name", inputTensor)
        };
        
        // 运行模型
        using (var results = session.Run(inputs))
        {
            // 从results中获取您的输出
        }

      请确保将"path_to_your_model.onnx"替换为您的ONNX模型的实际路径,同时根据您的模型输入适当调整输入张量的形状。

      希望这有助于您开始!如果有任何其他问题或需要进一步的帮助,欢迎随时提问。

      -1
    1. RizwanMunawarRizwanMunawarGitHub

      @deepaks11! What I understood from your question is that you want to train ultralytics YOLOv8 for face emotion detection. If this is the case, then yes you can use the YOLOv8 for face emotions detection.

      For more details, you can take a look at ultralytics documentation!

  2. noocapnoocapGitHub

    import cv2 as cv import numpy as np from PIL import ImageGrab from ultralytics import YOLO

    modelo = YOLO('last.pt') def janela(): while (True):
    screen = np.array(ImageGrab.grab()) screen = cv.cvtColor(src=screen, code=cv.COLOR_BGR2RGB)
    modelo.predict(screen, show=True)

    janela()

    Could someone help me in a way to get the wy position of the center of the box?

    I've tried a lot of things but I still haven't been successful.

    1
    1. Glenn JocherGlenn JocherUltralytics(تم التعديل)

      @noocap certainly! To obtain the y-coordinate of the center of the bounding box, you can use the results object returned by the predict() method. The results object contains a Boxes attribute, which holds the bounding box coordinates in various formats, including xyxy (xmin, ymin, xmax, ymax) and xywh (x-center, y-center, width, height).

      Here's how you can modify your janela() function to get the y-coordinate of the center of each detected box:

      import cv2 as cv
      import numpy as np
      from PIL import ImageGrab
      from ultralytics import YOLO
      
      # Load the model
      model = YOLO('last.pt')
      
      def janela():
          while True:
              # Capture the screen
              screen = np.array(ImageGrab.grab())
              # Convert the screen capture to the correct color format
              screen = cv.cvtColor(screen, cv.COLOR_BGR2RGB)
              
              # Run prediction
              results = model.predict(screen)
              
              # Iterate over the detected boxes
              for box in results[0].boxes:
                  # Get the y-coordinate of the center of the box
                  xc, yc, w, h = box.xywh[0]
                  print(f'Center Y-coordinate: {yc}')
                  
                  # If you want to visualize the results
                  annotated_frame = results[0].plot()
                  cv.imshow('YOLOv8 Prediction', annotated_frame)
                  if cv.waitKey(1) == ord('q'):  # Press 'q' to quit
                      break
      
      janela()

      In this code snippet, box.xywh[0] retrieves the bounding box in xywh format for each detection, and yc represents the y-coordinate of the center of the box. The print statement outputs the y-coordinate to the console.

      Remember to handle the window display and breaking out of the loop appropriately if you're showing the predictions with cv.imshow(). The cv.waitKey(1) function is used to capture keyboard input, allowing you to exit the loop by pressing 'q'.

  3. agungmrfagungmrfGitHub

    hello, here I am doing research using Yolov8 to detect the sign language alphabet. but to display output in the form of sound or text to speech it still doesn't work, can anyone help?

    the following is the code

    import torch import cv2 from numpy import ndarray as nd from ultralytics import YOLO

    model = YOLO('models/best.pt')

    Set the camera capture properties

    cap = cv2.VideoCapture(0) cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640) cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)

    Set the desired frame rate

    frame_rate = 30 delay = int(1000 / frame_rate)

    while cap.isOpened(): ret, frame = cap.read()

    results = model(frame)
    
    cv2.imshow('Detection-Bisindo', nd.squeeze(results[0].plot()))
    
    if cv2.waitKey(delay) & 0xFF == ord('q'):
        break

    cap.release() cv2.destroyAllWindows()

    1
    1. Glenn JocherGlenn JocherUltralytics

      @agungmrf hello! It's great to hear that you're using YOLOv8 for sign language detection. To add text-to-speech functionality to your code, you can use Python's gtts library (Google Text-to-Speech) or pyttsx3 for offline text-to-speech conversion. Below is an example of how you can integrate gtts into your existing code:

      First, install the gtts library if you haven't already:

      pip install gtts

      Then, modify your code to include text-to-speech functionality:

      import torch
      import cv2
      from numpy import ndarray as nd
      from ultralytics import YOLO
      from gtts import gTTS
      import os
      
      model = YOLO('models/best.pt')
      
      # Set the camera capture properties
      cap = cv2.VideoCapture(0)
      cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
      cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
      
      # Set the desired frame rate
      frame_rate = 30
      delay = int(1000 / frame_rate)
      
      def speak(text):
          tts = gTTS(text=text, lang='en')
          tts.save('output.mp3')
          os.system('start output.mp3')
      
      while cap.isOpened():
          ret, frame = cap.read()
      
          results = model(frame)
      
          # Assuming your model's results contain the class names of detected signs
          for result in results:
              if result.boxes:
                  labels = result.boxes.cls
                  # Get the class names using the labels
                  class_names = [model.names[i] for i in labels]
                  # Speak out the first detected class name for simplicity
                  if class_names:
                      speak(class_names[0])
                      break  # Only speak the first detected sign per frame
      
          cv2.imshow('Detection-Bisindo', nd.squeeze(results[0].plot()))
      
          if cv2.waitKey(delay) & 0xFF == ord('q'):
              break
      
      cap.release()
      cv2.destroyAllWindows()

      This code snippet uses gtts to convert the detected class name into speech. It saves the speech as an MP3 file and then plays it using the default media player. Note that this is a simple implementation and will speak out the name of the first detected class in each frame. You might want to add additional logic to handle multiple detections or to prevent the same sign from being spoken repeatedly.

      If you prefer an offline solution, you can use pyttsx3 instead, which doesn't require an internet connection. Install it using:

      pip install pyttsx3

      And use the speak function like this:

      import pyttsx3
      
      engine = pyttsx3.init()
      
      def speak(text):
          engine.say(text)
          engine.runAndWait()

      Replace the speak function in the previous code with this one, and you'll have offline text-to-speech functionality.

      I hope this helps! If you have any further questions or need assistance with your project, feel free to ask.

  4. H-TudorH-TudorGitHub

    I have trained a yolov8n model (on 3 classes) and need to run it in the most efficient way. After researching TVM's compilation I was stuck with a numpy array of 1x7x8400. My question is how to interpret this array as to get the bounding boxes/ classes and confidence. Thanks in advance.

    PS: I could use more documentation on the inference process (besides the "Predict" page) and its output, where could i find it?

    1
    1. H-TudorH-TudorGitHub(تم التعديل)

      For anyone with the same issue as i had, I found the answer 6 Months later buried in the examples

      Theory:

      • yolov5 has an output of shape (batchSize, 25200, 85) (Num classes + box[x,y,w,h] + confidence[c])
      • yolov8 has an output of shape (batchSize, 84, 8400) (Num classes + box[x,y,w,h])

      My yolo model has an output of 1x7x8400:

      • 1 = batch size for single image inference
      • 7 = 3 classes + 4 params (x, y, w, h)
      • 8400 = subdivisions I suppose (must be concatenated using NMS)

      C++ decoder can be found at: ultralytics/examples/YOLOv8-CPP-Inference/inference.cpp/Inference::runInference I encourage reading these examples and also some modification of the .cpp and .h is required

    2. Paula DerrengerPaula DerrengerUltralytics(تم التعديل)

      @H-Tudor i'm glad to hear you found the solution to your issue! 🎉 The output shape you've described is indeed the raw predictions from the model, which include the bounding box coordinates and the per-class scores (YOLOv8 has no separate objectness score).

      For interpreting the output array, you typically need to apply a post-processing step, such as Non-Maximum Suppression (NMS), to filter out overlapping boxes and select the most probable detections.

      Regarding additional documentation on the inference process and its output, the best place to look would be the Ultralytics YOLOv8 GitHub repository, specifically within the examples directory, as you've already discovered. The C++ inference example you mentioned is a great resource for understanding how to decode the raw model output.

      If you have further questions or need more assistance, feel free to open an issue in the GitHub repository, and the community will be happy to help. Keep in mind that the repo is continuously updated, so staying tuned for any new documentation or examples is always a good idea.

      Happy coding with YOLOv8! 🚀

      1
    3. complete-dopecomplete-dopeGitHub

      @petergreis Could you please give a detailed output for the 8400 ? like the actual breakdown !!

      I have seen it at lot of places and many are confused ... could you please solve that !!

  5. raniasyedraniasyedGitHub

    Hi, I am making an object detection system with YOLOv8 with a custom dataset, I have a trained model named best.pt The problem is I need to deploy this model on flask to use the webcam. I am unable to do that with yolov8 as it gives a lot of errors. Please help me with it

    1
    1. sam-a-dsam-a-dGitHub

      If you visit model.py in ultralytics, you can see the following line where they defined the resources themselves, the code is

      Define the trainable function with allocated resources

      trainable_with_resources = tune.with_resources(_tune, {'cpu': 8, 'gpu': gpu_per_trial if gpu_per_trial else 0})

      so yo can override the no of cpu in your own going to the main method as this method does not get cpu values as a parameter.

    2. raniasyedraniasyedGitHub

      Hi, the error that I am facing says that: cv2.error: opencv(4.7.0) d:\a\opencv-python\opencv-python\opencv\modules\imgcodecs\src\loadsave.cpp:692: error: (-2:unspecified error) could not find a writer for the specified extension in function 'cv::imwrite_' I have tried updating the opencv version, im using only the jpg format, but i still cant seem to find the error.

    3. raniasyedraniasyedGitHub

      @app.route("/") def index(): return render_template('index.html')

      @app.route("/", methods=["GET", "POST"]) def predict_img(): if request.method == "POST": if 'file' in request.files: f = request.files['file'] basepath = os.path.dirname(file) filepath = os.path.join(basepath, 'uploads', f.filename) print("upload folder is ", filepath) f.save(filepath) global imgpath

              predict_img.imgpath = f.filename
              print("printing predict_img :::::: ", predict_img)
      
              file_extension = f.filename.rsplit('.', 1)[1].lower()
              if file_extension == 'jpg':
                  img = cv2.imread(filepath)
                  frame = cv2.imencode('.jpg', cv2.UMat(img))[1].tobytes()
                  print('Hello')
      
                  image = Image.open(io.BytesIO(frame))
                  yolo = YOLO('best.pt')
                  detections = yolo.predict(image, save=True)
                  #return display(f.filename)
      
      
              elif file_extension == 'mp4':
                  video_path = filepath
                  cap = cv2.VideoCapture(video_path)
      
                  frame_width = int(cap.get(cv2.get(cv2.CAP_PROP_FRAME_WIDTH)))
                  frame_height = int(cap.get(cv2.get(cv2.CAP_PROP_FRAME_HEIGHT)))
      
                  fourcc = cv2.VideoWriter_fourcc(*'mp4v')
                  out = cv2.VideoWriter('output.mp4', fourcc, 30.0, (frame_width, frame_height))
                  model = YOLO('best.pt')
                  while cap.isOpened():
                      ret, frame = cap.read()
                      if not ret:
                          break
                      results = model(frame, save=True)
                      print(results)
                      cv2.waitKey(1)
                      res_plotted = results[0].plot()
                      cv2.imshow('results', res_plotted)
                      out.write(res_plotted)
      
                      if cv2.waitKey(1)==ord('q'):
                          break
      
                  return video_feed()
      
      folder_path = 'runs/detect/train'
      subfolders = [f for f in os.listdir(folder_path) if os.path.isdir(os.path.join(folder_path, f))]
      latest_subfolder = max(subfolders, key=lambda x: os.path.getctime(os.path.join(folder_path,x) ))
      image_path = folder_path + '/' + latest_subfolder + '/' + f.filename
      return render_template('index.html', image_path = image_path)

      @app.route('/path:filename') def display(filename): print('Indisplay') folder_path = 'runs/detect/train' subfolders = [f for f in os.listdir(folder_path) if os.path.isdir(os.path.join(folder_path, f))] latest_subfolder = max(subfolders, key=lambda x: os.path.getctime(os.path.join(folder_path, x))) directory = folder_path+'/'+latest_subfolder print('printing directory', directory) files = os.listdir(directory) #print('HI') if files: latest_file = files[0] print(latest_file) else: print('No files found in directory')

      filename = predict_img.imgpath
      print('After Filename')
      file_extension = filename.rsplit('.', 1)[1].lower()
      
      environ = request.environ
      if file_extension == 'jpg':
          print('infileext')
          if os.path.exists(os.path.join(directory, latest_file)):
              return send_from_directory(directory, latest_file, environ)
          else:
              return 'FILE DOES NOT EXIST'
      else:
          return 'INVALID FILE FORMAT'

      @app.route("/webcam_feed") def webcam_feed(): ip_address = "rtsp://admin:admin123@192.168.1.2:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif" cap = cv2.VideoCapture(ip_address) model = YOLO('runs/detect/train/weights/best.pt') fps = int(cap.get(cv2.CAP_PROP_FPS))

      fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')
      frame_width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
      frame_height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
      
      show_boxes = False
      
      out = cv2.VideoWriter('output.mp4', fourcc, fps, (frame_width, frame_height), True)
      while (cap.isOpened()):
          ret, frame = cap.read()
          if ret == True:
              person_found = False
              results = model(frame, imgsz=640, stream=True, verbose=False)
              for result in results:
                  for box in result.boxes.cpu().numpy():
                      if show_boxes:
                          r = box.xyxy[0].astype(int)
                          cv2.rectangle(frame, r[:2], r[2:], (255, 255, 255), 2)
                      cls = int(box.cls[0])
                      if cls == 0:
                          person_found = True
      return render_template('index.html')
      @app.route('/video_feed')

      def video_feed(): print('Function called') return Response(get_frame(), mimetype='multipart/x-mixed-replace; boundary=frame')

      if name == 'main': app.run(debug=True) parser = argparse.ArgumentParser(description="Flask app exposing yolov8 models") parser.add_argument("--port", default=5000, type=int, help="port number") args = parser.parse_args()

    4. flashzzzflashzzzGitHub

      Then I think the issue lies with the writer plugins. I'll let you know if I find something

    5. Paula DerrengerPaula DerrengerUltralytics

      @kopyl it seems there was a misunderstanding earlier. The error you're encountering is related to OpenCV's imwrite function, which is used to save images to disk. The error message indicates that OpenCV cannot find a writer for the specified file extension, which in your case is .jpg.

      This issue can occur if OpenCV was not installed with the proper image codecs or if there's an issue with the file path or permissions. Here are a few steps you can take to resolve the issue:

      1. Check File Path: Ensure that the path where you're trying to save the image exists and that your application has write permissions to that directory.

      2. Reinstall OpenCV: Uninstall and reinstall OpenCV with all the necessary codecs. If you're using pip, you can do this with:

        pip uninstall opencv-python
        pip install opencv-python
      3. Use Absolute Path: When saving the image, use an absolute path to avoid any relative path issues.

      4. Check Disk Space: Make sure you have enough disk space on the drive you're writing to.

      5. File Extension: Double-check that the file extension is correct and that you're not appending any non-standard characters to it.

      6. Update OpenCV: If you're not using the latest version of OpenCV, consider updating it as there might be fixes in the newer versions.

      If you continue to face issues, please provide the exact line of code that's causing the error, and I'll be happy to help you further debug the problem.

  6. Aminezaghdoudi08Aminezaghdoudi08GitHub

    I am writing my thesis on error detection in Alumnium using YOLOv8 and have not found any documentation on the architecture of the algorithm. Can you please give me more details about it and how it works? so I can present it.

    Kind regards

    1
    1. torkiasalemtorkiasalemGitHub

      @Aminezaghdoudi08 The YOLOv8 architecture consists of two main parts: the backbone and the head. The backbone is a modified version of the CSPDarknet53 architecture. The head consists of multiple convolutional layers followed by a series of fully connected layers, responsible for predicting bounding boxes, objectness scores, and class probabilities for the objects detected in an image . Some other parameters used in YOLOv8 include: Input size: Default input size is 640x640 . Number of layers: Default number of layers is set to 53.

      For BBox loss, YOLOv8 employs the CIoU and DFL loss functions, as well as BCE for cls loss. These losses have been proven to increase object identification performance, especially with tiny objects. I hope this explanation helps clarify your questions. Let us know if you have any further questions or concerns!

      2
  7. daisheng123daisheng123GitHub

    I looked at the parsing function in deepstream-yolo-pose, and it only handles single-class human pose estimation. How should it be parsed for multiple classes?

    1. Glenn JocherGlenn JocherUltralytics

      Ultralytics pose models assume a single keypoint layout (one kpt_shape/skeleton), so you can only do “multi-class pose” with one DeepStream parser if all classes share the same keypoint definition; in that case, parse keypoints exactly the same way and just use each detection’s predicted class id (cls) to tag/group the instance (see the Ultralytics pose task docs). If your classes need different keypoint counts/semantics, you’ll need separate pose models/engines (or run detection first, then a class-specific pose model), since one output tensor shape can’t represent multiple skeletons cleanly.