ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
50.91k stars 16.39k forks source link

Changing YOLOv5 labels to another language #6851

Closed HunarAA closed 2 years ago

HunarAA commented 2 years ago

Search before asking

Question

I'm wondering if it's possible to change the labels on Yolov5 to another language. For example, Arabic. I have tried changing them in the '.yaml' file, but when I test the trained model, all the characters become weird symbols.

Additional

No response

github-actions[bot] commented 2 years ago

👋 Hello @HunarAA, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://ultralytics.com or email support@ultralytics.com.

Requirements

Python>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

glenn-jocher commented 2 years ago

@HunarAA we've tried to implement support for Chinese characters using Arial Unicode, but have not tested arabic characters. Can you upload your yaml here or paste your names array so we can test? Thanks!

HunarAA commented 2 years ago

Of course I will. But the language that I want to try is not Arabic exactly, it's Persian and Arabic like language. This is the array of names: ["ڕوبەڕوو", "چۆنی", "لەبەردەم", "خۆشەویستی"]. I appreciate your help.

glenn-jocher commented 2 years ago

@HunarAA got it, thanks for the sample! I'll try it out.

HunarAA commented 2 years ago

Please find me a way to do it. Thank you.

On Fri, Mar 4, 2022, 2:42 PM Glenn Jocher @.***> wrote:

@HunarAA https://github.com/HunarAA got it, thanks for the sample! I'll try it out.

— Reply to this email directly, view it on GitHub https://github.com/ultralytics/yolov5/issues/6851#issuecomment-1059089530, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJF7DLFEDTACDVTMS4SRVJ3U6HZIZANCNFSM5P4XSMRQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

glenn-jocher commented 2 years ago

@HunarAA what's your problem exactly? Your names operate correctly in my tests:

# Classes
nc: 80  # number of classes
names: ["ڕوبەڕوو", "چۆنی", "لەبەردەم", "خۆشەویستی", 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light',
        'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow',
        'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee',
        'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard',
        'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple',
        'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch',
        'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone',
        'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear',
        'hair drier', 'toothbrush']  # class names

confusion_matrix

val_batch0_labels

HunarAA commented 2 years ago

On my test, the letters become unrecognizable characters but in your tests it's better than mine. Hence, there is a problem with your test which is the whole is split into litters for example "چۆنی" is showed like "چ ۆ ن ی" each as s separate characters not a word. Do you think this can be solved? And how did you done that? because on my tests the laptop webcam showed unrecognizable characters as I said.

glenn-jocher commented 2 years ago

@HunarAA I just updated the coco128.yaml names array in a new Colab notebook and trained normally to get the above results, i.e. no additional action is required on your part to get the above results. https://colab.research.google.com/github/ultralytics/yolov5/blob/master/tutorial.ipynb?hl=en

I don't know about the spacing though, not sure if there's any solution to that. This is just PIL printing text using the YOLOv5 Annotator class: https://github.com/ultralytics/yolov5/blob/8a66ebad44e8ecf90c7d27757c832579398d4baf/utils/plots.py#L65-L81

HunarAA commented 2 years ago

Thank you for your answer. I will try it again and see

github-actions[bot] commented 2 years ago

👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs.

Access additional YOLOv5 🚀 resources:

Access additional Ultralytics ⚡ resources:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐!

ghaithAlMasri commented 2 years ago

@HunarAA Hello, did you figure out a way to solve the separate letters?

HunarAA commented 2 years ago

As I understood, there is no way to solve this problem because they use OpenCV puttext method to add the text to the bounding boxes and OpenCV only supports English languages.

glenn-jocher commented 2 years ago

@Crypro-Coder @HunarAA YOLOv5 will automatically switch to PIL plotting for non-latin typographies, so we support labels in all alphabets, i.e. Chinese, Arabic, Cyrillic etc. https://github.com/ultralytics/yolov5/blob/526e650553819dbff67897b9c752c4072e989823/utils/plots.py#L72-L80

HunarAA commented 2 years ago

Is it new addition? because when I asked the question there wasn't such thing.

glenn-jocher commented 2 years ago

@HunarAA we've had this for a while but made some major improvements a few months ago. Haven't seen any alphabet-related issues raised since then. I think the confusion matrix plots may still not work correctly, but this a matplotlib issue, the image annotations that are done with PIL should be correct.

HunarAA commented 2 years ago

Thanks, since then I didn't try it. I will try it again.

glenn-jocher commented 1 year ago

You're welcome, @HunarAA! Feel free to give it another shot, and let us know if you encounter any issues. Happy to help if you need further assistance.