the use of GPU in the Tensorflow framework will only affect speed and why it will also affect the running results.
when you close GPU, the result will be blank. Using GPU is normal
https://pan.baidu.com/s/1mfA7.
Code as above, can be run directly
the main code is as follows:
-sharp -*- coding: utf-8 -*-
import numpy as np
from scipy.misc import imread, imsave
import argparse
import time
import os
-sharp os.environ["CUDA_VISIBLE_DEVICES"] = "-1" -sharp -1 CPU GPU
import tensorflow as tf
def run(session):
args = argparse.Namespace()
args.input = "./7.jpg"
args.output = "./7_666.jpg"
args.model = "./models/wave.model"
args.arch = "./models/model.meta"
args.image = imread(args.input, mode="RGB").astype(np.float32)
args.image = np.expand_dims(args.image, axis=0)
-sharp
saver = tf.train.import_meta_graph(args.arch, clear_devices=True)
saver.restore(session, args.model)
inputs = tf.get_collection("inputs")[0]
output = tf.get_collection("output")[0]
result = output.eval({inputs: args.image})
result = np.clip(result, 0.0, 255.0).astype(np.uint8)
result = np.squeeze(result, 0)
imsave(args.output, result)
def main():
session = tf.Session()
with session.as_default():
run(session)
if __name__ == "__main__":
time_a = time.time()
main()
time_b = time.time()
print("run_time", time_b - time_a)