質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

機械学習

機械学習は、データからパターンを自動的に発見し、そこから知能的な判断を下すためのコンピューターアルゴリズムを指します。人工知能における課題のひとつです。

Q&A

解決済

1回答

950閲覧

Noiseprintの実行時の不具合

xeno

総合スコア16

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

機械学習

機械学習は、データからパターンを自動的に発見し、そこから知能的な判断を下すためのコンピューターアルゴリズムを指します。人工知能における課題のひとつです。

0グッド

0クリップ

投稿2021/05/17 05:12

前提・実現したいこと

ソースコード
上記リンクで公開されているNoiseprintを抽出しするコードmain_extraction.pyを実行し、それを表示するコードmain_showout.pyを実行すると失敗時の画像になってしまいます。
正確に動作させたいのですが何を行えばよいでしょうか?
成功すると成功画像のようになるらしいです。

成功画像
イメージ説明

失敗時の画像
イメージ説明

該当のソースコード

Noiseprint抽出コード

# This is the code to extract Noiseprint # python main_extraction.py input.png noiseprint.mat # python main_showout.py input.png noiseprint.mat # # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # # Copyright (c) 2019 Image Processing Research Group of University Federico II of Naples ('GRIP-UNINA'). # All rights reserved. # This work should only be used for nonprofit purposes. # # By downloading and/or using any of these files, you implicitly agree to all the # terms of the license, as specified in the document LICENSE.txt # (included in this package) and online at # http://www.grip.unina.it/download/LICENSE_OPEN.txt # from sys import argv from time import time from noiseprint.noiseprint import genNoiseprint from noiseprint.utility.utilityRead import imread2f from noiseprint.utility.utilityRead import jpeg_qtableinv imgfilename = argv[1] outfilename = argv[2] timestamp = time() img, mode = imread2f(imgfilename, channel=1) try: QF = jpeg_qtableinv(strimgfilenameeam) except: QF = 200 res = genNoiseprint(img,QF) timeApproach = time() - timestamp out_dict = dict() out_dict['noiseprint'] = res out_dict['QF'] = QF out_dict['time'] = timeApproach if outfilename[-4:] == '.mat': import scipy.io as sio sio.savemat(outfilename, out_dict) else: import numpy as np np.savez(outfilename, **out_dict)

Noiseprint表示コード

# This code shows the noiseprint_blind output # python main_blind.py input.png output.mat # python main_showout.py input.png output.mat # # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # # Copyright (c) 2019 Image Processing Research Group of University Federico II of Naples ('GRIP-UNINA'). # All rights reserved. # This work should only be used for nonprofit purposes. # # By downloading and/or using any of these files, you implicitly agree to all the # terms of the license, as specified in the document LICENSE.txt # (included in this package) and online at # http://www.grip.unina.it/download/LICENSE_OPEN.txt # import matplotlib.pyplot as plt import numpy as np from sys import argv imgfilename = argv[1] outfilename = argv[2] print(' %s' % imgfilename) from noiseprint.utility.utilityRead import imread2f img, mode = imread2f(imgfilename, channel = 3) print('size : ', img.shape) if outfilename[-4:] == '.mat': import scipy.io as sio dat = sio.loadmat(outfilename) else: import numpy as np dat = np.load(outfilename) time = dat['time'].flatten() qf = dat['QF'].flatten() print('time : %g' % time) print('qf : %g' % qf) if 'noiseprint' in dat.keys(): res = dat['noiseprint'] vmin = np.min(res[34:-34,34:-34]) vmax = np.max(res[34:-34,34:-34]) plt.figure() plt.subplot(1,2,1) plt.imshow(img, clim=[0,1]) plt.title('input \n image (%s, %d)' % (mode, qf)) plt.subplot(1,2,2) plt.imshow(res.clip(vmin,vmax), clim=[vmin,vmax], cmap='gray') plt.title('noiseprint') plt.show() if 'map' in dat.keys(): mapp = dat['map'] valid = dat['valid'] range0 = dat['range0'].flatten() range1 = dat['range1'].flatten() imgsize = dat['imgsize'].flatten() from noiseprint.noiseprint_blind import genMappUint8 mapUint8 = genMappUint8(mapp, valid, range0,range1, imgsize) plt.figure() plt.subplot(1,2,1) plt.imshow(img, clim=[0,1]) plt.title('input \n image (%s, %d)' % (mode, qf)) plt.subplot(1,2,2) plt.imshow(mapUint8, clim=[0,255], cmap='gray') plt.title('heatmap') plt.show()

試したこと

tensorflow、cuDNN、CUDAの再インストール

補足情報(FW/ツールのバージョンなど)

ubuntu18.04
python3.6
tensorflow1.14.0
cuDNN7.4
CUDA10.0.130

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

jbpb0

2021/05/18 04:31

質問の「失敗時の画像」をダウンロードして、周囲をトリミングして元の画像部分だけにして、 https://github.com/grip-unina/noiseprint からダウンロードしたコードを無修正で、 python main_extraction.py testnp.jpg testnp.npz python main_showout.py testnp.jpg testnp.npz みたいに実行したら、左に元画像、右にモヤモヤっとした画像が並んで表示されました (「testnp.jpg」が、質問の画像をトリミングしたもの) ただし、元画像の黒い部分(左下の長方形と右端)は、モヤモヤっとしてなくてグレーの塗り潰しになってましたので、質問の「成功画像」とは違いますけど、質問の「失敗時の画像」のような普通の画像ではありませんでした
xeno

2021/05/30 02:26

返信遅れてすみません。 その方法を試したら確かに普通の画像ではなくなりました。 その考えはありませんでした。ありがとうございます。
jbpb0

2021/05/30 02:32

うまくいかなかったのは、それぞれの「*.py」を使った実行コマンドを間違えてたのですか?
xeno

2021/05/30 02:40

matでやっていたのですが、npzにしたところ上手くいきました。 さらに、tensorflowの1.6以上だと上手くいかないPCがあるという記事を見かけ1.5.0にダウングレードしたところmatでも上手くできました。
jbpb0

2021/05/30 02:55

> 1.5.0にダウングレードしたところmatでも上手くできました なるほど 3年くらい前のTFのバージョンじゃないと、matだと動かないのですね
xeno

2021/05/30 02:59

動かない場合があるという感じらしいです。 なにはともあれありがとうございました。
guest

回答1

0

自己解決

生成ファイルの拡張子をmatからnpzに変更したところ成功しました。
tensorflowの1.6以上だと上手くいかないPCがあるので、1.5.0にダウングレードを行ったところmatでも成功しました。

投稿2021/05/30 03:02

xeno

総合スコア16

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問