刺猬在天冷时围抱取暖,但保持一定距离避免相互|

jinganglang567

园龄:4年5个月粉丝:0关注:20

2023-09-16 20:22阅读: 10评论: 0推荐: 0

深度学习相关课题

pytorch简单了解 读取数据

from torch.utils.data import Dataset

from PIL import Image

import os
class mydata(Dataset):
    def __init__(self,root_dir,label_dir):
        self.root_dir=root_dir
        self.label_dir=label_dir
        self.path=os.path.join(root_dir,label_dir)
        self.img_path=os.listdir(self.path)

    def __getitem__(self, idx):
        imag_name=self.img_path[idx]
        imag_item_path=os.path.join(self.root_dir,self.label_dir,imag_name)
        img=Image.open(imag_item_path)
        label=self.label_dir
        return img,label
    def __len__(self):
        return len(self.img_path)

root_dir='dataset\\hymenoptera_data\\train'
ants_dir='ants'
ants=mydata(root_dir,ants_dir)

tensorboard使用

from torch.utils.tensorboard import SummaryWriter

import numpy as np
from PIL import Image
writer=SummaryWriter("logs")

imagepath=r'dataset\hymenoptera_data\train\ants\0013035.jpg'

imag_PIL=Image.open(imagepath)
ima_array=np.array(imag_PIL)
writer.add_image('test',ima_array,1,dataformats='HWC')

for i in range(100):
    writer.add_scalar('y=2x',2*i,i)

writer.close()

transform常用用法


from PIL import Image
from torch.utils.tensorboard import SummaryWriter
from torchvision import transforms

writer=SummaryWriter('logs')
img=Image.open(r'dataset\hymenoptera_data\train\ants\5650366_e22b7e1065.jpg')
print(img)  #pil数据

trans_totensor=transforms.ToTensor()
img_totensor=trans_totensor(img)  #转化成tensor数据
writer.add_image('totensor1',img_totensor)

print(img_totensor[0][0][0])
transnorm=transforms.Normalize([0.5,0.5,0.5],[0.5,0.5,0.5])
imagnorm=transnorm(img_totensor)  #对tensor数据进行规划
print(imagnorm[0][0][0])


writer.add_image('normal1',imagnorm)


print(img.size)
tran_resize=transforms.Resize((512,512))  #创建类
imgresize=trans_totensor(img)
writer.add_image('resize',imgresize,0)
print(imgresize)


#compose


writer.close()

本文作者:jinganglang567

本文链接:https://www.cnblogs.com/tgfoven/p/17707259.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   jinganglang567  阅读(10)  评论(0编辑  收藏  举报
  1. 1 look after you louis tomlinson
  2. 2 just hold on louis tomlinson
  3. 3 i can steven cooper
  4. 4 rock me one direction
  5. 5 just can't let her go one direction
  6. 6 this town Niall Horan
  7. 7 cut in love july
  8. 8 nemo 夜愿
  9. 9 in the end Black Veil Brides
  10. 10 glad you came the wanted
  11. 11 chasing the sun the wanted
  12. 12 TAKE MY HAND simple plan
  13. 13 wish i had an angel 夜愿
just hold on - louis tomlinson
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.

作词 : Sasha Alex Sloan/Eric Rosse

作曲 : Steve Aoki/Louis Tomlinson/Sasha Alex Sloan/Nolan Lambroza/Eric Rosse

Wish that you could build a time machine

So you could see

The things no one can see

Feels like you're standing on the edge

Looking at the stars

And wishing you were them

What do you do when a chapter ends?

Do you close the book and never read it again?

Where do you go when your story's done?

You can be who you were or who you'll become

Oooh

If it all goes wrong

Oooh

Darling just hold on

The sun goes down and it comes back up

The world it turns no matter what

Oooh

If it all goes wrong

Darling just hold on

Oooh

Darling just hold on

Oooh

It's not over until it's all been said

It's not over until your dying breath

So what do you want them to say when you're gone?

That you gave up or that you kept going on?

What do you do when a chapter ends?

Do you close the book and never read it again?

Where do you go when your story's done?

You can be who you were or who you'll become

Oooh

If it all goes wrong

Oooh

Darling just hold on

The sun goes down and it comes back up

The world it turns no matter what

Oooh

If it all goes wrong

Darling just hold on

Oooh

Darling just hold on

Oooh

Oooh

If it all goes wrong

Oooh

Darling just hold on

Oooh

If it all goes wrong

Darling just hold on

点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起