python show an image via subprocess.Popen

import tensorflow as tf
import Image
import os
import subprocess

def main(argv): 
  folder = argv[0]
  if (len(argv) > 1):
    if tf.gfile.Exists(argv[1]):
      folder = argv[1]
    else:
      print ('%s not existed' % argv[1])
      return
  else:
    print ("please input training image data folder path")
    return
  for f in tf.gfile.ListDirectory(folder):
    filepath = os.path.join(folder, f)
    try:
      im = Image.open(filepath)
      p = subprocess.Popen(["display", filepath])
      label = raw_input("please label the image, 0 means cat, 1 means dog:")
      p.kill()
    except Exception, e:
      print (e)

Comments

Popular posts from this blog

How to fix error : no module named sendgrid when try to use sendgrid python lib in PHP.

react-native run-android : sun.security.provider.cert path.SunCertPathBuilderException : unable to find valid certification path to req uested target

react-native run-android : do not build/update modified code(App.js)