中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

用adsl做網(wǎng)站備案網(wǎng)站一年了百度不收錄

用adsl做網(wǎng)站備案,網(wǎng)站一年了百度不收錄,網(wǎng)頁設(shè)計(jì)代碼的意思,做網(wǎng)站那個(gè)公司比較好YOLOv5 分類模型 數(shù)據(jù)集加載 3 自定義類別 flyfish YOLOv5 分類模型 數(shù)據(jù)集加載 1 樣本處理 YOLOv5 分類模型 數(shù)據(jù)集加載 2 切片處理 YOLOv5 分類模型的預(yù)處理(1) Resize 和 CenterCrop YOLOv5 分類模型的預(yù)處理(2)ToTensor 和 …

YOLOv5 分類模型 數(shù)據(jù)集加載 3 自定義類別

flyfish

YOLOv5 分類模型 數(shù)據(jù)集加載 1 樣本處理
YOLOv5 分類模型 數(shù)據(jù)集加載 2 切片處理
YOLOv5 分類模型的預(yù)處理(1) Resize 和 CenterCrop
YOLOv5 分類模型的預(yù)處理(2)ToTensor 和 Normalize
YOLOv5 分類模型 Top 1和Top 5 指標(biāo)說明
YOLOv5 分類模型 Top 1和Top 5 指標(biāo)實(shí)現(xiàn)

之前的處理方式是類別名字是文件夾名字,類別ID是按照文件夾名字的字母順序
現(xiàn)在是類別名字是文件夾名字,按照文件列表名字順序 例如

classes_name=['n02086240', 'n02087394', 'n02088364', 'n02089973', 'n02093754', 
'n02096294', 'n02099601', 'n02105641', 'n02111889', 'n02115641']

n02086240 類別ID是0
n02087394 類別ID是1
代碼處理是

if classes_name is None or not classes_name:classes, class_to_idx = self.find_classes(self.root)print("not classes_name")else:classes = classes_nameclass_to_idx ={cls_name: i for i, cls_name in enumerate(classes)}print("is classes_name")

完整

import time
from models.common import DetectMultiBackend
import os
import os.path
from typing import Any, Callable, cast, Dict, List, Optional, Tuple, Union
import cv2
import numpy as npimport torch
from PIL import Image
import torchvision.transforms as transformsimport sysclasses_name=['n02086240', 'n02087394', 'n02088364', 'n02089973', 'n02093754', 'n02096294', 'n02099601', 'n02105641', 'n02111889', 'n02115641']class DatasetFolder:def __init__(self,root: str,) -> None:self.root = rootif classes_name is None or not classes_name:classes, class_to_idx = self.find_classes(self.root)print("not classes_name")else:classes = classes_nameclass_to_idx ={cls_name: i for i, cls_name in enumerate(classes)}print("is classes_name")print("classes:",classes)print("class_to_idx:",class_to_idx)samples = self.make_dataset(self.root, class_to_idx)self.classes = classesself.class_to_idx = class_to_idxself.samples = samplesself.targets = [s[1] for s in samples]@staticmethoddef make_dataset(directory: str,class_to_idx: Optional[Dict[str, int]] = None,) -> List[Tuple[str, int]]:directory = os.path.expanduser(directory)if class_to_idx is None:_, class_to_idx = self.find_classes(directory)elif not class_to_idx:raise ValueError("'class_to_index' must have at least one entry to collect any samples.")instances = []available_classes = set()for target_class in sorted(class_to_idx.keys()):class_index = class_to_idx[target_class]target_dir = os.path.join(directory, target_class)if not os.path.isdir(target_dir):continuefor root, _, fnames in sorted(os.walk(target_dir, followlinks=True)):for fname in sorted(fnames):path = os.path.join(root, fname)if 1:  # 驗(yàn)證:item = path, class_indexinstances.append(item)if target_class not in available_classes:available_classes.add(target_class)empty_classes = set(class_to_idx.keys()) - available_classesif empty_classes:msg = f"Found no valid file for the classes {', '.join(sorted(empty_classes))}. "return instancesdef find_classes(self, directory: str) -> Tuple[List[str], Dict[str, int]]:classes = sorted(entry.name for entry in os.scandir(directory) if entry.is_dir())if not classes:raise FileNotFoundError(f"Couldn't find any class folder in {directory}.")class_to_idx = {cls_name: i for i, cls_name in enumerate(classes)}return classes, class_to_idxdef __getitem__(self, index: int) -> Tuple[Any, Any]:path, target = self.samples[index]sample = self.loader(path)return sample, targetdef __len__(self) -> int:return len(self.samples)def loader(self, path):print("path:", path)#img = cv2.imread(path)  # BGR HWCimg=Image.open(path).convert("RGB") # RGB HWCreturn imgdef time_sync():return time.time()#sys.exit() 
dataset = DatasetFolder(root="/media/a/flyfish/source/yolov5/datasets/imagewoof/val")#image, label=dataset[7]#
weights = "/home/a/classes.pt"
device = "cpu"
model = DetectMultiBackend(weights, device=device, dnn=False, fp16=False)
model.eval()
print(model.names)
print(type(model.names))mean=[0.485, 0.456, 0.406]
std=[0.229, 0.224, 0.225]
def preprocess(images):#實(shí)現(xiàn) PyTorch Resizetarget_size =224img_w = images.widthimg_h = images.heightif(img_h >= img_w):# hwresize_img = images.resize((target_size, int(target_size * img_h / img_w)), Image.BILINEAR)else:resize_img = images.resize((int(target_size * img_w  / img_h),target_size), Image.BILINEAR)#實(shí)現(xiàn) PyTorch CenterCropwidth = resize_img.widthheight = resize_img.heightcenter_x,center_y = width//2,height//2left = center_x - (target_size//2)top = center_y- (target_size//2)right =center_x +target_size//2bottom = center_y+target_size//2cropped_img = resize_img.crop((left, top, right, bottom))#實(shí)現(xiàn) PyTorch ToTensor Normalizeimages = np.asarray(cropped_img)print("preprocess:",images.shape)images = images.astype('float32')images = (images/255-mean)/stdimages = images.transpose((2, 0, 1))# HWC to CHWprint("preprocess:",images.shape)images = np.ascontiguousarray(images)images=torch.from_numpy(images)#images = images.unsqueeze(dim=0).float()return imagespred, targets, loss, dt = [], [], 0, [0.0, 0.0, 0.0]
# current batch size =1
for i, (images, labels) in enumerate(dataset):print("i:", i)im = preprocess(images)images = im.unsqueeze(0).to("cpu").float()print(images.shape)t1 = time_sync()images = images.to(device, non_blocking=True)t2 = time_sync()# dt[0] += t2 - t1y = model(images)y=y.numpy()#print("y:", y)t3 = time_sync()# dt[1] += t3 - t2#batch size >1 圖像推理結(jié)果是二維的#y: [[     4.0855     -1.1707     -1.4998      -0.935     -1.9979      -2.258     -1.4691     -1.0867     -1.9042    -0.99979]]tmp1=y.argsort()[:,::-1][:, :5]#batch size =1 圖像推理結(jié)果是一維的, 就要處理下argsort的維度#y: [     3.7441      -1.135     -1.1293     -0.9422     -1.6029     -2.0561      -1.025     -1.5842     -1.3952     -1.1824]#print("tmp1:", tmp1)pred.append(tmp1)#print("labels:", labels)targets.append(labels)#print("for pred:", pred)  # list#print("for targets:", targets)  # list# dt[2] += time_sync() - t3pred, targets = np.concatenate(pred), np.array(targets)
print("pred:", pred)
print("pred:", pred.shape)
print("targets:", targets)
print("targets:", targets.shape)
correct = ((targets[:, None] == pred)).astype(np.float32)
print("correct:", correct.shape)
print("correct:", correct)
acc = np.stack((correct[:, 0], correct.max(1)), axis=1)  # (top1, top5) accuracy
print("acc:", acc.shape)
print("acc:", acc)
top = acc.mean(0)
print("top1:", top[0])
print("top5:", top[1])
http://www.risenshineclean.com/news/64197.html

相關(guān)文章:

  • 四六級查成績網(wǎng)站怎么做百度最貴關(guān)鍵詞排名
  • 公司微網(wǎng)站建設(shè)方案網(wǎng)絡(luò)營銷的基本流程
  • 農(nóng)行網(wǎng)站不出動畫怎么做電腦培訓(xùn)學(xué)校排名
  • 怎么攻擊php做的網(wǎng)站嗎如何建立自己的網(wǎng)絡(luò)銷售
  • 臨沂哪家做網(wǎng)站最好seo關(guān)鍵詞優(yōu)化報(bào)價(jià)
  • 巴中哪里做網(wǎng)站杭州優(yōu)化公司多少錢
  • 網(wǎng)站國外空間站長工具中文精品
  • 網(wǎng)站推廣預(yù)期達(dá)到的目標(biāo)泰安網(wǎng)絡(luò)推廣培訓(xùn)
  • 萬網(wǎng)域名注冊網(wǎng)站網(wǎng)頁制作模板的網(wǎng)站
  • 商城網(wǎng)站開發(fā)視頻東莞網(wǎng)站建設(shè)排名
  • 怎么做網(wǎng)站地圖的樣式惡意點(diǎn)擊軟件有哪些
  • 購物網(wǎng)站開發(fā)的描述幽默軟文廣告經(jīng)典案例
  • 昆明seo網(wǎng)站建設(shè)濟(jì)寧百度競價(jià)推廣
  • 公關(guān)公司屬于什么行業(yè)北京網(wǎng)站seo設(shè)計(jì)
  • 建網(wǎng)站用什么發(fā)票創(chuàng)建軟件平臺該怎么做
  • pc網(wǎng)站建設(shè)需要提供哪些資料愛客crm
  • wordpress建站過程線上推廣的渠道有哪些
  • 十堰網(wǎng)站設(shè)計(jì)公司成都網(wǎng)多多
  • 新余網(wǎng)站制作關(guān)鍵詞seo優(yōu)化排名公司
  • 代理網(wǎng)頁游戲要多少錢福州seo網(wǎng)站管理
  • 青海網(wǎng)站建設(shè)公司軟文通
  • 網(wǎng)站開發(fā)名詞解釋百度問答兼職怎么做
  • matlab做網(wǎng)站爬蟲廣東疫情最新數(shù)據(jù)
  • 網(wǎng)站在線客服管理系統(tǒng)哈爾濱網(wǎng)站優(yōu)化
  • 網(wǎng)站的測試和網(wǎng)站上線宣傳渠道和宣傳方式有哪些
  • 廣州凡科公司是外包嗎seo免費(fèi)外鏈工具
  • 網(wǎng)站開發(fā)制做seo搜索引擎優(yōu)化工作內(nèi)容
  • 關(guān)于做問卷星網(wǎng)站的畢業(yè)論文安裝百度到手機(jī)桌面
  • wordpress u-degin優(yōu)化軟件刷排名seo
  • uc投放廣告網(wǎng)站要自己做嗎如何做網(wǎng)頁制作