您好,登錄后才能下訂單哦!
這篇文章主要介紹“Python DPED機器學習怎么實現照片美化”,在日常操作中,相信很多人在Python DPED機器學習怎么實現照片美化問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”Python DPED機器學習怎么實現照片美化”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!
下面是項目的原始結構:
按照項目的說明,我們需要安裝tensorflow以及一些必要的庫。
如果安裝gpu版本的tensorflow需要對照一下
tensorflow官方對照地址:TensorFlow官方CUDA版本對照
我的cuda是11.1的版本,按照tensorflow后還是缺少部分dll,如果有相同問題的,可以用我提供的資源包 提取碼:TUAN。
缺少哪個dll,直接復制到你的NVIDIA GPU Computing Toolkit目錄對應cuda的bin目錄下。
按照自己的版本來,我的tensorflow命令如下:
pip install tensorflow-gpu==2.4.2 -i https://pypi.douban.com/simple pip install tf-nightly -i https://pypi.douban.com/simple
Pillow, scipy, numpy, imageio安裝
pip install Pillow -i https://pypi.douban.com/simple pip install scipy -i https://pypi.douban.com/simple pip install numpy -i https://pypi.douban.com/simple pip install imageio -i https://pypi.douban.com/simple
因為模型文件太大,github的項目中無法上傳這么大的文件,作者讓我們自己下。
我把DPED的資源包統一打包了,也可以從我的云盤下載, 放到項目的vgg_pretrained目錄下。下圖是資源包的目錄
資源包地址 提取碼:TUAN。
項目需要的環境我們都裝好了,我們跳過訓練的部分,測試model的方法官方給出了命令。
我準備了幾張圖,就不全展示了,展示其中的一張。
按照項目的要求,需要放在對應的目錄下。
執行命令
python test_model.py model=iphone_orig test_subset=full resolution=orig use_gpu=true
執行過程
(tensorflow) C:\Users\yi\PycharmProjects\DPED>python test_model.py model=iphone_orig test_subset=full resolution=orig use_gpu=true 2021-11-27 23:42:57.922965: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll 2021-11-27 23:43:00.532645: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. 2021-11-27 23:43:00.535946: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library nvcuda.dll 2021-11-27 23:43:00.559967: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties: pciBusID: 0000:01:00.0 name: GeForce GTX 1070 computeCapability: 6.1 coreClock: 1.759GHz coreCount: 15 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 238.66GiB/s 2021-11-27 23:43:00.560121: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll 2021-11-27 23:43:00.577706: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublas64_11.dll 2021-11-27 23:43:00.577812: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublasLt64_11.dll 2021-11-27 23:43:00.588560: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cufft64_10.dll 2021-11-27 23:43:00.591950: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library curand64_10.dll 2021-11-27 23:43:00.614412: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusolver64_10.dll 2021-11-27 23:43:00.624267: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusparse64_11.dll 2021-11-27 23:43:00.626309: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudnn64_8.dll 2021-11-27 23:43:00.626481: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0 2021-11-27 23:43:01.112598: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1261] Device interconnect StreamExecutor with strength 1 edge matrix: 2021-11-27 23:43:01.112756: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1267] 0 2021-11-27 23:43:01.113098: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1280] 0: N 2021-11-27 23:43:01.113463: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1406] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 6720 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1070, pci bus id: 0000:01:00.0, compute capability: 6.1) 2021-11-27 23:43:01.114296: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set WARNING:tensorflow:From C:\Users\yi\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\compat\v2_compat.py:96: disable_resource_variables (from tensorflow.p ython.ops.variable_scope) is deprecated and will be removed in a future version. Instructions for updating: non-resource variables are not supported in the long term 2021-11-27 23:43:01.478512: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set 2021-11-27 23:43:01.479339: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties: pciBusID: 0000:01:00.0 name: GeForce GTX 1070 computeCapability: 6.1 coreClock: 1.759GHz coreCount: 15 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 238.66GiB/s 2021-11-27 23:43:01.479747: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll 2021-11-27 23:43:01.480519: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublas64_11.dll 2021-11-27 23:43:01.480927: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublasLt64_11.dll 2021-11-27 23:43:01.481155: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cufft64_10.dll 2021-11-27 23:43:01.481568: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library curand64_10.dll 2021-11-27 23:43:01.481823: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusolver64_10.dll 2021-11-27 23:43:01.482188: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusparse64_11.dll 2021-11-27 23:43:01.482416: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudnn64_8.dll 2021-11-27 23:43:01.482638: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0 2021-11-27 23:43:01.482959: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties: pciBusID: 0000:01:00.0 name: GeForce GTX 1070 computeCapability: 6.1 coreClock: 1.759GHz coreCount: 15 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 238.66GiB/s 2021-11-27 23:43:01.483077: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll 2021-11-27 23:43:01.483254: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublas64_11.dll 2021-11-27 23:43:01.483426: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublasLt64_11.dll 2021-11-27 23:43:01.483638: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cufft64_10.dll 2021-11-27 23:43:01.483817: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library curand64_10.dll 2021-11-27 23:43:01.484052: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusolver64_10.dll 2021-11-27 23:43:01.484250: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusparse64_11.dll 2021-11-27 23:43:01.484433: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudnn64_8.dll 2021-11-27 23:43:01.484662: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0 2021-11-27 23:43:01.484841: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1261] Device interconnect StreamExecutor with strength 1 edge matrix: 2021-11-27 23:43:01.484984: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1267] 0 2021-11-27 23:43:01.485152: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1280] 0: N 2021-11-27 23:43:01.485395: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1406] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 6720 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1070, pci bus id: 0000:01:00.0, compute capability: 6.1) 2021-11-27 23:43:01.485565: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set 2021-11-27 23:43:01.518135: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:196] None of the MLIR optimization passes are enabled (registered 0 passes) Testing original iphone model, processing image 3.jpg 2021-11-27 23:43:01.863678: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudnn64_8.dll 2021-11-27 23:43:02.517063: I tensorflow/core/platform/windows/subprocess.cc:308] SubProcess ended with return code: 0 2021-11-27 23:43:02.632790: I tensorflow/core/platform/windows/subprocess.cc:308] SubProcess ended with return code: 0 2021-11-27 23:43:03.210892: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublas64_11.dll 2021-11-27 23:43:03.509052: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublasLt64_11.dll Lossy conversion from float32 to uint8. Range [-0.06221151351928711, 1.0705437660217285]. Convert image to uint8 prior to saving to suppress this warning. Lossy conversion from float32 to uint8. Range [-0.06221151351928711, 1.0705437660217285]. Convert image to uint8 prior to saving to suppress this warning. Testing original iphone model, processing image 4.jpg Lossy conversion from float32 to uint8. Range [-0.05176264047622681, 1.0500218868255615]. Convert image to uint8 prior to saving to suppress this warning. Lossy conversion from float32 to uint8. Range [-0.05176264047622681, 1.0500218868255615]. Convert image to uint8 prior to saving to suppress this warning. Testing original iphone model, processing image 5.jpg Lossy conversion from float32 to uint8. Range [-0.03344374895095825, 1.0417983531951904]. Convert image to uint8 prior to saving to suppress this warning. Lossy conversion from float32 to uint8. Range [-0.03344374895095825, 1.0417983531951904]. Convert image to uint8 prior to saving to suppress this warning. Testing original iphone model, processing image 6.jpg Lossy conversion from float32 to uint8. Range [-0.03614246845245361, 1.063475251197815]. Convert image to uint8 prior to saving to suppress this warning. Lossy conversion from float32 to uint8. Range [-0.03614246845245361, 1.063475251197815]. Convert image to uint8 prior to saving to suppress this warning.
項目會生成前后對比圖以及最終結果圖。
前后效果圖,左邊為原始圖,右邊為對比圖。
結果圖如下
可以明顯的看出,新圖已經明亮了許多,色彩也變的比較鮮明了,效果還是很不錯的。
到此,關于“Python DPED機器學習怎么實現照片美化”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。