ultralytics / yolo-flutter-app

A Flutter plugin for Ultralytics YOLO computer vision models
https://ultralytics.com
GNU Affero General Public License v3.0
111 stars 43 forks source link

Questions about the imgsz parameter #7

Closed x2031 closed 7 months ago

x2031 commented 7 months ago

As far as I've tested there is currently no support for modifying the imgsz parameter, only the 320 input is currently supported

pderrenger commented 7 months ago

Hello! 😊 The imgsz parameter can indeed be modified to support various input sizes, not just 320. You can adjust this parameter in your training or detection scripts. For example, when training, you can set it like so:

python train.py --img 640 --batch 16 --epochs 50 --data dataset.yaml --weights yolov5s.pt

Or for detection:

python detect.py --img 640 --source data/images --weights yolov5s.pt

Just replace 640 with your desired image size. Keep in mind, your image size should be a multiple of 32 for the model to work correctly.

For more detailed information, check our documentation at https://docs.ultralytics.com. Happy coding! 🌟

x2031 commented 7 months ago

Thank you for your reply, I may not have expressed myself clearly, the problem I'm currently experiencing is that ultralytics_yolo only supports models with imgsz=320 when obtaining predictions, and I cannot dynamically modify this parameter @pderrenger

pderrenger commented 7 months ago

Hello again! 😊 My apologies for the misunderstanding. You can dynamically change the imgsz parameter for predictions as well. If you're using the command line for predictions, it should directly accept the --img argument similar to the example below:

python detect.py --img 640 --source data/images --weights yolov5s.pt

If you're working within a script, ensure you adjust the image size in the model's configuration before loading your model or making predictions. Here's a quick example:

model = torch.hub.load('ultralytics/yolov5', 'yolov5s', imgsz=640)

Just replace 640 with your desired size. Remember, it needs to be a multiple of 32. If you encounter any specific errors while doing this, please share them so we can help you better!