第一次调试
This commit is contained in:
@ -39,13 +39,13 @@ if str(ROOT) not in sys.path:
|
||||
sys.path.append(str(ROOT)) # add ROOT to PATH
|
||||
ROOT = Path(os.path.relpath(ROOT, Path.cwd())) # relative
|
||||
|
||||
from models.common import DetectMultiBackend
|
||||
from utils.augmentations import classify_transforms
|
||||
from utils.dataloaders import IMG_FORMATS, VID_FORMATS, LoadImages, LoadStreams
|
||||
from utils.general import (LOGGER, Profile, check_file, check_img_size, check_imshow, check_requirements, colorstr, cv2,
|
||||
from app.yolov5.models.common import DetectMultiBackend
|
||||
from app.yolov5.utils.augmentations import classify_transforms
|
||||
from app.yolov5.utils.dataloaders import IMG_FORMATS, VID_FORMATS, LoadImages, LoadStreams
|
||||
from app.yolov5.utils.general import (LOGGER, Profile, check_file, check_img_size, check_imshow, check_requirements, colorstr, cv2,
|
||||
increment_path, print_args, strip_optimizer)
|
||||
from utils.plots import Annotator
|
||||
from utils.torch_utils import select_device, smart_inference_mode
|
||||
from app.yolov5.utils.plots import Annotator
|
||||
from app.yolov5.utils.torch_utils import select_device, smart_inference_mode
|
||||
|
||||
|
||||
@smart_inference_mode()
|
||||
|
@ -36,15 +36,15 @@ if str(ROOT) not in sys.path:
|
||||
sys.path.append(str(ROOT)) # add ROOT to PATH
|
||||
ROOT = Path(os.path.relpath(ROOT, Path.cwd())) # relative
|
||||
|
||||
from classify import val as validate
|
||||
from models.experimental import attempt_load
|
||||
from models.yolo import ClassificationModel, DetectionModel
|
||||
from utils.dataloaders import create_classification_dataloader
|
||||
from utils.general import (DATASETS_DIR, LOGGER, WorkingDirectory, check_git_status, check_requirements, colorstr,
|
||||
from app.yolov5.classify import val as validate
|
||||
from app.yolov5.models.experimental import attempt_load
|
||||
from app.yolov5.models.yolo import ClassificationModel, DetectionModel
|
||||
from app.yolov5.utils.dataloaders import create_classification_dataloader
|
||||
from app.yolov5.utils.general import (DATASETS_DIR, LOGGER, WorkingDirectory, check_git_status, check_requirements, colorstr,
|
||||
download, increment_path, init_seeds, print_args, yaml_save)
|
||||
from utils.loggers import GenericLogger
|
||||
from utils.plots import imshow_cls
|
||||
from utils.torch_utils import (ModelEMA, model_info, reshape_classifier_output, select_device, smart_DDP,
|
||||
from app.yolov5.utils.loggers import GenericLogger
|
||||
from app.yolov5.utils.plots import imshow_cls
|
||||
from app.yolov5.utils.torch_utils import (ModelEMA, model_info, reshape_classifier_output, select_device, smart_DDP,
|
||||
smart_optimizer, smartCrossEntropyLoss, torch_distributed_zero_first)
|
||||
|
||||
LOCAL_RANK = int(os.getenv('LOCAL_RANK', -1)) # https://pytorch.org/docs/stable/elastic/run.html
|
||||
|
@ -33,10 +33,10 @@ if str(ROOT) not in sys.path:
|
||||
sys.path.append(str(ROOT)) # add ROOT to PATH
|
||||
ROOT = Path(os.path.relpath(ROOT, Path.cwd())) # relative
|
||||
|
||||
from models.common import DetectMultiBackend
|
||||
from utils.dataloaders import create_classification_dataloader
|
||||
from utils.general import LOGGER, Profile, check_img_size, check_requirements, colorstr, increment_path, print_args
|
||||
from utils.torch_utils import select_device, smart_inference_mode
|
||||
from app.yolov5.models.common import DetectMultiBackend
|
||||
from app.yolov5.utils.dataloaders import create_classification_dataloader
|
||||
from app.yolov5.utils.general import LOGGER, Profile, check_img_size, check_requirements, colorstr, increment_path, print_args
|
||||
from app.yolov5.utils.torch_utils import select_device, smart_inference_mode
|
||||
|
||||
|
||||
@smart_inference_mode()
|
||||
|
@ -64,12 +64,12 @@ if str(ROOT) not in sys.path:
|
||||
if platform.system() != 'Windows':
|
||||
ROOT = Path(os.path.relpath(ROOT, Path.cwd())) # relative
|
||||
|
||||
from models.experimental import attempt_load
|
||||
from models.yolo import ClassificationModel, Detect
|
||||
from utils.dataloaders import LoadImages
|
||||
from utils.general import (LOGGER, Profile, check_dataset, check_img_size, check_requirements, check_version,
|
||||
from app.yolov5.models.experimental import attempt_load
|
||||
from app.yolov5.models.yolo import ClassificationModel, Detect
|
||||
from app.yolov5.utils.dataloaders import LoadImages
|
||||
from app.yolov5.utils.general import (LOGGER, Profile, check_dataset, check_img_size, check_requirements, check_version,
|
||||
check_yaml, colorstr, file_size, get_default_args, print_args, url2file)
|
||||
from utils.torch_utils import select_device, smart_inference_mode
|
||||
from app.yolov5.utils.torch_utils import select_device, smart_inference_mode
|
||||
|
||||
|
||||
def export_formats():
|
||||
@ -309,7 +309,7 @@ def export_saved_model(model,
|
||||
import tensorflow as tf
|
||||
from tensorflow.python.framework.convert_to_constants import convert_variables_to_constants_v2
|
||||
|
||||
from models.tf import TFModel
|
||||
from app.yolov5.models.tf import TFModel
|
||||
|
||||
LOGGER.info(f'\n{prefix} starting export with tensorflow {tf.__version__}...')
|
||||
f = str(file).replace('.pt', '_saved_model')
|
||||
@ -371,7 +371,7 @@ def export_tflite(keras_model, im, file, int8, data, nms, agnostic_nms, prefix=c
|
||||
converter.target_spec.supported_types = [tf.float16]
|
||||
converter.optimizations = [tf.lite.Optimize.DEFAULT]
|
||||
if int8:
|
||||
from models.tf import representative_dataset_gen
|
||||
from app.yolov5.models.tf import representative_dataset_gen
|
||||
dataset = LoadImages(check_dataset(check_yaml(data))['train'], img_size=imgsz, auto=False)
|
||||
converter.representative_dataset = lambda: representative_dataset_gen(dataset, ncalib=100)
|
||||
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]
|
||||
|
@ -28,12 +28,12 @@ def _create(name, pretrained=True, channels=3, classes=80, autoshape=True, verbo
|
||||
"""
|
||||
from pathlib import Path
|
||||
|
||||
from models.common import AutoShape, DetectMultiBackend
|
||||
from models.experimental import attempt_load
|
||||
from models.yolo import ClassificationModel, DetectionModel
|
||||
from utils.downloads import attempt_download
|
||||
from utils.general import LOGGER, check_requirements, intersect_dicts, logging
|
||||
from utils.torch_utils import select_device
|
||||
from app.yolov5.models.common import AutoShape, DetectMultiBackend
|
||||
from app.yolov5.models.experimental import attempt_load
|
||||
from app.yolov5.models.yolo import ClassificationModel, DetectionModel
|
||||
from app.yolov5.utils.downloads import attempt_download
|
||||
from app.yolov5.utils.general import LOGGER, check_requirements, intersect_dicts, logging
|
||||
from app.yolov5.utils.torch_utils import select_device
|
||||
|
||||
if not verbose:
|
||||
LOGGER.setLevel(logging.WARNING)
|
||||
|
@ -72,7 +72,7 @@ class Ensemble(nn.ModuleList):
|
||||
|
||||
def attempt_load(weights, device=None, inplace=True, fuse=True):
|
||||
# Loads an ensemble of models weights=[a,b,c] or a single model weights=[a] or weights=a
|
||||
from models.yolo import Detect, Model
|
||||
from app.yolov5.models.yolo import Detect, Model
|
||||
|
||||
model = Ensemble()
|
||||
for w in weights if isinstance(weights, list) else [weights]:
|
||||
|
@ -27,12 +27,12 @@ import torch
|
||||
import torch.nn as nn
|
||||
from tensorflow import keras
|
||||
|
||||
from models.common import (C3, SPP, SPPF, Bottleneck, BottleneckCSP, C3x, Concat, Conv, CrossConv, DWConv,
|
||||
from app.yolov5.models.common import (C3, SPP, SPPF, Bottleneck, BottleneckCSP, C3x, Concat, Conv, CrossConv, DWConv,
|
||||
DWConvTranspose2d, Focus, autopad)
|
||||
from models.experimental import MixConv2d, attempt_load
|
||||
from models.yolo import Detect
|
||||
from utils.activations import SiLU
|
||||
from utils.general import LOGGER, make_divisible, print_args
|
||||
from app.yolov5.models.experimental import MixConv2d, attempt_load
|
||||
from app.yolov5.models.yolo import Detect
|
||||
from app.yolov5.utils.activations import SiLU
|
||||
from app.yolov5.utils.general import LOGGER, make_divisible, print_args
|
||||
|
||||
|
||||
class TFBN(keras.layers.Layer):
|
||||
|
@ -462,7 +462,7 @@ def train(hyp, opt, device, data_list,id,callbacks): # hyp is path/to/hyp.yaml
|
||||
# break # must break all DDP ranks
|
||||
######实时传输训练精度参数#############
|
||||
#gain_train_report(int(epoch + 1), float(results[0]), pro, version, epochs)
|
||||
report_cellback(epoch, epochs, float(results[0]),train_num)
|
||||
report_cellback(epoch, epochs, float(results[0]))
|
||||
# end epoch ----------------------------------------------------------------------------------------------------
|
||||
########训练数量和保存模型###########
|
||||
#save_train_report_result(pro, train_num, best)
|
||||
|
@ -64,7 +64,7 @@ def safe_download(file, url, url2=None, min_bytes=1E0, error_msg=''):
|
||||
|
||||
def attempt_download(file, repo='ultralytics/yolov5', release='v6.2'):
|
||||
# Attempt file download from GitHub release assets if not found locally. release = 'latest', 'v6.2', etc.
|
||||
from utils.general import LOGGER
|
||||
from app.yolov5.utils.general import LOGGER
|
||||
|
||||
def github_assets(repository, version='latest'):
|
||||
# Return GitHub repo tag (i.e. 'v6.2') and assets (i.e. ['yolov5s.pt', 'yolov5m.pt', ...])
|
||||
|
@ -64,7 +64,7 @@ def smart_DDP(model):
|
||||
|
||||
def reshape_classifier_output(model, n=1000):
|
||||
# Update a TorchVision classification model to class count 'n' if required
|
||||
from models.common import Classify
|
||||
from app.yolov5.models.common import Classify
|
||||
name, m = list((model.model if hasattr(model, 'model') else model).named_children())[-1] # last module
|
||||
if isinstance(m, Classify): # YOLOv5 Classify() head
|
||||
if m.linear.out_features != n:
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user