完成U-net细胞分割的一些准备
生活随笔
收集整理的這篇文章主要介紹了
完成U-net细胞分割的一些准备
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
#使用本地上傳文件
from google.colab import files
uploaded = files.upload()
for fn in uploaded.keys():print('User uploaded file "{name}" with length {length} bytes'.format(name=fn, length=len(uploaded[fn])))
#刪除文件以及文件夾
import os
import shutilpath='../source_file_clxiao/'#os.remove(path) #刪除文件
#os.removedirs(path) #刪除空文件夾#shutil.rmtree(path) #遞歸刪除文件夾
#CV2圖像顯示
from google.colab.patches import cv2_imshow
!curl -o logo.png https://colab.research.google.com/img/colab_favicon_256px.png
import cv2
img = cv2.imread('logo.png', cv2.IMREAD_UNCHANGED)
cv2_imshow(img)
#文件上傳加文件讀取
from google.colab import files
import cv2
uploaded = files.upload()
ii=0
for fn in uploaded.keys():input=cv2.imread(fn)ii=ii+1
#圖片讀取加圖像擴增from keras.preprocessing.image import ImageDataGenerator, array_to_img, img_to_array, load_imgdatagen = ImageDataGenerator(rotation_range=1,width_shift_range=0.2,height_shift_range=0.2,shear_range=0.6,zoom_range=0.6,horizontal_flip=True,fill_mode='nearest')img = load_img('test_1.tif') # this is a PIL imagex = img_to_array(img) # this is a Numpy array with shape (3, 150, 150)x = x.reshape((1,) + x.shape) # this is a Numpy array with shape (1, 3, 150, 150)# the .flow() command below generates batches of randomly transformed images# and saves the results to the `preview/` directoryi = 0import matplotlib.pyplot as pltfrom PIL import Imagelist=datagen.flow(x, batch_size=4,save_to_dir='test_1/', save_prefix='test_1_', save_format='tif')#print(list.size)for batch in list:i += 1if i > 5:break # otherwise the generator would loop indefinitelyprint(batch.size)#plt.imshow(batch)#cv2.WaitKey(20)
?
總結
以上是生活随笔為你收集整理的完成U-net细胞分割的一些准备的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 深度学习目标检测相关论文资源合辑
- 下一篇: keras fine-tune方法