Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yolov8 SDK run OK in debug but after convert to exe its run as a loop (create unlimited train section) #12637

Open
1 task done
nghiakthp2401 opened this issue May 13, 2024 · 3 comments
Labels
question Further information is requested

Comments

@nghiakthp2401
Copy link

nghiakthp2401 commented May 13, 2024

Search before asking

Question

When run as exe file it create unlimited train section till ram is full.
image
Full video description about this : [https://drive.google.com/file/d/1639oRAFH8MveZy9p-IygH5DRgpCyGK-G/view?usp=sharing]
But when run in debug mode it works OK
image

Here is my code

`
from ultralytics import YOLO
import configparser
from os import path, getcwd
import cv2 as cv

def ModifyDataYamlFile(filePath, UseTrainAsVal):

StartUpPath = getcwd()
with open(filePath, "r") as file:
    lines = file.readlines()
    lines[0] = "train: " + StartUpPath + "\\Dataset\\train\\images\n"
    if UseTrainAsVal:
        lines[1] = "val: " + StartUpPath + "\\Dataset\\train\\images\n"
    else :
        lines[1] = "val: " + StartUpPath + "\\Dataset\\val\\images\n"
    lines[2] = "test: " + StartUpPath + "\\Dataset\\test\\images\n"
with open(filePath, "w") as file:
    file.writelines(lines)

if name == 'main':

# Load Config Data
if path.exists("Config.cfg"):
    config = configparser.RawConfigParser()  
    config.read("Config.cfg")

    WeightPath = config.get("Config","WeightPath")
    DatasetPath = config.get("Config","DatasetPath")
    Task = config.get("Config","Task")
    Epoch = (int)(config.get("Config","Epoch"))
    Batch = (int)(config.get("Config","Batch"))
    ImageSize = (int)(config.get("Config","ImageSize"))
    Patience = (int)(config.get("Config","Patience"))
    ExportFormat = config.get("Config","ExportFormat")
    TrainDevice = config.get("Config","TrainDevice")
    UseTrainAsVal = (bool)(config.get("Config","UseTrainAsVal"))
    
    ModifyDataYamlFile(DatasetPath, UseTrainAsVal)
    weightPath = path.join(getcwd(), WeightPath)

    if(TrainDevice == "GPU"):
        device = "0"
    
    elif(TrainDevice == "CPU"):
        device = "cpu"
    

    #Tranning Pharse
    model = YOLO(weightPath)

if path.exists("Config.cfg"):
    results = model.train(data=DatasetPath, epochs=Epoch, batch = Batch, 
                    patience= Patience, imgsz = ImageSize,  device=device)
    cv.waitKey(0)
else: print("Not Found Config Folder")

`

Additional

No response

@nghiakthp2401 nghiakthp2401 added the question Further information is requested label May 13, 2024
Copy link

👋 Hello @nghiakthp2401, thank you for your interest in Ultralytics YOLOv8 🚀! We recommend a visit to the Docs for new users where you can find many Python and CLI usage examples and where many of the most common questions may already be answered.

If this is a 🐛 Bug Report, please provide a minimum reproducible example to help us debug it.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.

Join the vibrant Ultralytics Discord 🎧 community for real-time conversations and collaborations. This platform offers a perfect space to inquire, showcase your work, and connect with fellow Ultralytics users.

Install

Pip install the ultralytics package including all requirements in a Python>=3.8 environment with PyTorch>=1.8.

pip install ultralytics

Environments

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

Status

Ultralytics CI

If this badge is green, all Ultralytics CI tests are currently passing. CI tests verify correct operation of all YOLOv8 Modes and Tasks on macOS, Windows, and Ubuntu every 24 hours and on every commit.

@nghiakthp2401
Copy link
Author

nghiakthp2401 commented May 13, 2024

I used Auto-py-to-exe as to convert

@glenn-jocher
Copy link
Member

Hello!

It sounds like you're observing a different behavior between your debug and executable versions, which is not entirely uncommon when using tools like Auto-py-to-exe. A few quick tips that might help:

  1. Ensure all file paths are correctly handled in the executable. Paths managed differently could cause loops if the program continually looks for a file not found in its path.
  2. Check if the environment configurations are consistent between your debug and production setups.
  3. Consider catching and logging detailed errors or exceptions that may only occur in the executable environment. This will help explore whether specific parts of the code cause the loop.

If you still run into issues, feel free to share a snippet where you set up your execution loop or manage configurations, and we might spot something specific that's going off-track!

Good luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants