master
/ Untitled1.ipynb

Untitled1.ipynb @4cd1a00view markup · raw · history · blame

Notebook

图片扩展

1. 项目介绍

图片扩展是一项基于计算机视觉的学习任务。
我们只需要上传待扩展的图片,便能快速生成对图像周围像素的预测,将原图像补全,快来试试吧!

2. 项目结构

In [1]:
# 显示文件夹树状目录
import os
import os.path
 
def dfs_showdir(path, depth):
    if depth == 0:
        print("root:[" + path + "]")
 
    for item in os.listdir(path):
        if item[0] not in ['.', '__']:
            print("|      " * depth + "+--" + item)
            newitem = path +'/'+ item
            if os.path.isdir(newitem):
                dfs_showdir(newitem, depth +1)
 
 
if __name__ == '__main__':
    path = os.getcwd()             # 文件夹路径
    dfs_showdir(path, 0)  # 显示文件夹的树状结构
root:[/home/jovyan/work]
+--results
|      +--README.md
|      +--tb_results
|      |      +--README.md
|      +--city_output.png
|      +--test_output.png
+--_README.ipynb
+--_OVERVIEW.md
+--utils
|      +--login.sh
|      +--sync_models.sh
|      +--sync.sh
+--lit
|      +--iizuka.pdf
|      +--liu.pdf
+--README.md
+--src
|      +--util.py
|      +--model.py
|      +--model_ld.py
|      +--run.sh
|      +--test.py
|      +--train_ld.py
|      +--gen.py
|      +--run_ld.sh
|      +--train.py
|      +--figs.py
|      +--__pycache__
|      |      +--train.cpython-36.pyc
|      |      +--test.cpython-36.pyc
|      |      +--model.cpython-37.pyc
|      |      +--util.cpython-36.pyc
|      |      +--util.cpython-37.pyc
|      +--output
|      |      +--models
|      |      |      +--model227000.ckpt.index
|      |      |      +--model227000.ckpt.meta
|      |      |      +--model227000.ckpt.data-00000-of-00001
+--images
|      +--city_128.png
|      +--test.png
+--etc
|      +--dev-indices.txt
|      +--results.png
|      +--cost.xlsx
|      +--outpainting.png
|      +--recursive.png
+--coding_here.ipynb
+--job_logs
|      +--job-gpu-62b5d2d8c06b81cd38279610.log
|      +--job-gpu-62b5d344b5c4eec184cc05b0.log
|      +--job-gpu-62b5d39fd4e7f8c811b53eb1.log
|      +--job-gpu-62b5d4052a85ae797c345e17.log
|      +--job-gpu-62b5d43bc06b81cd38279613.log
|      +--job-gpu-62b94f70c584fdf74ee42dd3.log
|      +--job-gpu-62b94f9cb17f87f3a6d7445b.log
|      +--job-gpu-62b94fd2f752e3e25d1d3e30.log
|      +--job-gpu-62b95050f752e3e25d1d3e32.log
|      +--job-gpu-62b95091a393bd89f5bbaa0e.log
|      +--job-gpu-62b950d6f9c7fbd55d4e9e0f.log
|      +--job-gpu-62b96ec3f901e7972521f6bc.log
|      +--job-gpu-62b9701b8029151df74612ce.log
|      +--job-gpu-62b971036452cd65a61ca625.log
|      +--job-gpu-62cae2855cdb670ebbe876b4.log
|      +--job-gpu-62cae2b3924968835f19fd7f.log
+--poster
|      +--msabini-gili__image-outpainting-poster.pdf
+--Untitled.ipynb
+--app_spec.yml
+--handler.py
+--project_requirements.txt
+--Untitled1.ipynb

3. 项目demo

In [2]:
# 导入相关模块
from handler import *
2022-08-30 14:34:39.102754: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcudart.so.10.1'; dlerror: libcudart.so.10.1: cannot open shared object file: No such file or directory
2022-08-30 14:34:39.102786: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
WARNING:tensorflow:From /usr/local/lib/python3.7/dist-packages/tensorflow/python/compat/v2_compat.py:96: disable_resource_variables (from tensorflow.python.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
Imported model (for Places365, 128x128 images)
In [6]:
print("Input img:")
Image.open('/home/jovyan/work/images/test.png').resize((128, 128))
Input img:
Out[6]:
In [4]:
handle({'Photo': '/home/jovyan/work/images/test.png'})
Output img:
WARNING:tensorflow:From /home/jovyan/work/src/model.py:20: conv2d (from tensorflow.python.keras.legacy_tf_layers.convolutional) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.keras.layers.Conv2D` instead.
WARNING:tensorflow:From /usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/legacy_tf_layers/convolutional.py:424: Layer.apply (from tensorflow.python.keras.engine.base_layer_v1) is deprecated and will be removed in a future version.
Instructions for updating:
Please use `layer.__call__` method instead.
WARNING:tensorflow:From /home/jovyan/work/src/model.py:79: conv2d_transpose (from tensorflow.python.keras.legacy_tf_layers.convolutional) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.keras.layers.Conv2DTranspose` instead.
INFO:tensorflow:Restoring parameters from ./src/output/models/model227000.ckpt
2022-08-30 14:35:43.987477: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory
2022-08-30 14:35:43.987507: W tensorflow/stream_executor/cuda/cuda_driver.cc:312] failed call to cuInit: UNKNOWN ERROR (303)
2022-08-30 14:35:43.987527: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (notebook): /proc/driver/nvidia/version does not exist
2022-08-30 14:35:43.987796: 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 AVX512F FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2022-08-30 14:35:44.009476: I tensorflow/core/platform/profile_utils/cpu_utils.cc:104] CPU Frequency: 2500000000 Hz
2022-08-30 14:35:44.023013: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x46192d0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2022-08-30 14:35:44.023034: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
Runned time: 6.194 s
Out[4]:
{'Output': './results/test_output.png'}
In [7]:
print("Output img:")
Image.open('./results/test_output.png').resize((128, 128))
Output img:
Out[7]: