91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 5KB
    文件類型: .py
    金幣: 1
    下載: 0 次
    發布日期: 2021-06-14
  • 語言: Python
  • 標簽: cifar10??深度學習??

資源簡介

用自己的數據,制作python版本的cifar10數據集。可以任意別類任意數量,根據自己爬取的數據修改代碼參數即可。

資源截圖

代碼片段和文件信息

#!/usr/bin/env?python
#?coding:?utf-8

#?#參考來源:https://blog.csdn.net/qq_39131592/article/details/78990775
#?
#?1、rgb?=
#?img.split():(已解決)
#?valueError:too?many?values?to?unpack(expected?3)
#?unpack的個數對不上,比如:ab?=?tuple(123)?就會報出這個錯誤
#?通過Img.mode發現有的圖片是“1”、“L”、“P”和“RGBA”模式,需要convert
#?
#?2、rgb?=
#?img.split():(待解決)
#?OSError:cannot?identify
#?image?file:路徑+格式
#??暫時理解為系統兼容性問題
#?
#?參考:https://blog.csdn.net/l297969586/article/details/70597826
#??folder=“H:/VOC2007/test_ad“是最初的圖片文件夾?
#??folder_ad=“H:/VOC2007/test_rs“是resize后的圖片文件夾?
#??binpath=“H:/VOC2007/get4/test_batch“?是要生成的cifar10測試集test_batch的路徑

#?In[1]:


from?PIL?import?Image
import?numpy?as?np
import?pickleglobos
import?operator
from?os?import?listdir
import?sys
import?pickle
import?random


#?In[2]:


data={}
list1=[]
list2=[]
list3=[]

def?img_tra():
????for?k?in?range(0?num):
????????currentpath=folder?+?“\\“?+?imglist[k]
????????im=Image.open(currentpath)
????????#width=im.size[0]
????????#height=im.size[1]
????????
????????x_s=200
????????y_s=200
????????
????????out?=?im.resize((x_sy_s)Image.ANTIALIAS)
????????out.save(folder_ad?+?“\\“?+?str(imglist[k]))
????????
def?addWord(theIndexwordadder):
????theIndex.setdefault(word[]).append(adder)
????
def?seplabel(fname):
????filestr=fname.split(“.“)[0]
????label=int(filestr.split(“_“)[0])
????return?label

def?mkcf():
????global?data
????global?list1
????global?list2
????global?list3
????
????for?k?in?range(0?num):
????????currentpath=folder_ad?+?“\\“?+?imglist[k]
????????im=Image.open(currentpath)
????????with?open(‘./data_batch_5‘?‘a‘)?as?f:???#三通道的200*200
????????????for?i?in?range?(0200):
????????????????for?j?in?range?(0200):
????????????????????cl=im.getpixel((ij))
????????????????????list1.append(cl[0])
????????????????????
????????????for?i?in?range?(0200):
????????????????for?j?in?range?(0200):
????????????????????cl=im.getpixel((ij))
????????????????????#with?open(binpath?‘a‘)?as?f:
????????????????????#mid=str(cl[1])
????????????????????#f.write(mid)
????????????????????list1.append(cl[1])

????????????for?i?in?range?(0200):
????????????????for?j?in?range?(0200):
????????????????????cl=im.getpixel((ij))
????????????????????list1.append(cl[2])
????????????????????
????????list2.append(list1)
????????list1=[]
????????f.close()
????????print(“image“+

評論

共有 條評論