以下のサイトから超解像のプログラムを取得してきました.
https://github.com/Saafke/EDSR_Tensorflow
そのrun.pyのupscaleFromPb関数
python
1def upscaleFromPb(self, path): 2 """ 3 Upscale single image by desired model. This loads a .pb file. 4 """ 5 # Read model 6 pbPath = "./models/EDSR_x{}.pb".format(self.scale) 7 8 # Get graph 9 graph = self.load_pb(pbPath) 10 11 fullimg = cv2.imread(path, 3) 12 floatimg = fullimg.astype(np.float32) - self.mean 13 LR_input_ = floatimg.reshape(1, floatimg.shape[0], floatimg.shape[1], 3) 14 15 LR_tensor = graph.get_tensor_by_name("IteratorGetNext:0") 16 HR_tensor = graph.get_tensor_by_name("NHWC_output:0") 17 18 with tf.compat.v1.Session(graph=graph) as sess: 19 print("Loading pb...") 20 output = sess.run(HR_tensor, feed_dict={LR_tensor: LR_input_}) 21 Y = output[0] 22 HR_image = (Y + self.mean).clip(min=0, max=255) 23 HR_image = (HR_image).astype(np.uint8) 24 25 cv2.imwrite("./finish.jpg", HR_image) 26 cv2.destroyAllWindows() 27 28 sess.close()
のoutput = sess.run(HR_tensor, feed_dict={LR_tensor: LR_input_})部分で
error
1tensorflow.python.framework.errors_impl.ResourceExhaustedError: 2 root error(s) found. 2 (0) Resource exhausted: OOM when allocating tensor with shape[1,256,2480,3508] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc 3 [[node Conv2D (defined at D:\Downloads\EDSR_Tensorflow-master\EDSR_Tensorflow-master\run.py:224) ]] 4Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info. This isn't available when running in Eager mode. 5
が発生します.
2021/10/20 01:36
退会済みユーザー
2021/10/20 13:30 編集
退会済みユーザー
2021/10/20 13:34
2021/10/20 17:36
2021/10/22 13:43