資源簡介
谷歌Deep Dream源代碼,可以直接運行,不錯的參考資料
代碼片段和文件信息
#?coding:utf-8
from?__future__?import?print_function
import?os
from?io?import?BytesIO
import?numpy?as?np
from?functools?import?partial
import?PIL.Image
import?scipy.misc
import?tensorflow?as?tf
graph?=?tf.Graph()
model_fn?=?‘tensorflow_inception_graph.pb‘
sess?=?tf.InteractiveSession(graph=graph)
with?tf.gfile.FastGFile(model_fn?‘rb‘)?as?f:
????graph_def?=?tf.GraphDef()
????graph_def.ParseFromString(f.read())
t_input?=?tf.placeholder(np.float32?name=‘input‘)??#?define?the?input?tensor
imagenet_mean?=?117.0
t_preprocessed?=?tf.expand_dims(t_input?-?imagenet_mean?0)
tf.import_graph_def(graph_def?{‘input‘:?t_preprocessed})
def?savearray(img_array?img_name):
????scipy.misc.toimage(img_array).save(img_name)
????print(‘img?saved:?%s‘?%?img_name)
def?visstd(a?s=0.1):
????return?(a?-?a.mean())?/?max(a.std()?1e-4)?*?s?+?0.5
def?resize_ratio(img?ratio):
????min?=?img.min()
????max?=?img.max()
????img?=?(img?-?min)?/?(max?-?min)?*?255
????img?=?np.float32(scipy.misc.imresize(img?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????.......??????3552??2018-03-15?17:49??chapter_4\gen_deepdream.py
????.......??????4591??2018-03-15?17:49??chapter_4\gen_lapnorm.py
????.......??????2820??2018-03-15?17:49??chapter_4\gen_multiscale.py
????.......??????1810??2018-03-15?17:49??chapter_4\gen_naive.py
????.......??????1334??2018-03-15?17:49??chapter_4\load_inception.py
????.......???????971??2018-03-15?17:49??chapter_4\README.md
????.......?????41535??2018-03-15?17:49??chapter_4\test.jpg
?????目錄??????????0??2018-03-15?17:49??chapter_4
-----------?---------??----------?-----??----
????????????????56613????????????????????8
- 上一篇:用authorware做的電子讀物
- 下一篇:DLX實驗報告
評論
共有 條評論