home/exp1000/acquire_and_label_images.py
def create_input_image(self, png_src_filename, jpeg_dest_filename, input_height, input_width, jpeg_scaling, jpeg_quality, jpeg_processing):
        """Create image file as an input to the image classifier."""

        # Build the command string to create the image input for the image classification program.
        # FIXME create input jpeg directly from the thumbnail jpeg instead of from the png. Maye require an ipk to install jpegtopnm.
        if jpeg_processing != 'none':
            cmd_create_input_image = 'pngtopam {F} | pamscale -xsize {X} -ysize {Y} | {P} | pnmtojpeg -quality {Q} > {O}'.format(\
                F=png_src_filename,\
                Y=input_height,\
                X=input_width,\
                P=jpeg_processing,\
                Q=jpeg_quality,\
                O=jpeg_dest_filename)

        else:
            cmd_create_input_image = 'pngtopam {F} | pamscale -xsize {X} -ysize {Y} | pnmtojpeg -quality {Q} > {O}'.format(\
                F=png_src_filename,\
                Y=input_height,\
                X=input_width,\
                Q=jpeg_quality,\
                O=jpeg_dest_filename)

        # Log the command that will be executed.
        logger.info("Running command to create input: {C}".format(C=cmd_create_input_image))

        # Run the command to create the image input file for the image classification program.
        os.system(cmd_create_input_image)

        # Check that the image input exists.
        if not os.path.isfile(jpeg_dest_filename):
            logger.error(\
                "Failed to generate {X}x{Y} image input for the image classification model.".format(\
                    X=input_width,
                    Y=input_height))

            return False

        # An error in executing the pamscale command can produce an empty image input file.
        if Path(jpeg_dest_filename).stat().st_size == 0:
            logger.error("Generated image input is an empty file (0 KB).")
            
            return False

        # Return success boolean value.
        return True
Create image file as an input to the image classifier.
Create image file as an input to the image classifier.
Create image file as an input to the image classifier .
def create_input_image(self, png_src_filename, jpeg_dest_filename, input_height, input_width, jpeg_scaling, jpeg_quality, jpeg_processing):
        if jpeg_processing != 'none':
            cmd_create_input_image = 'pngtopam {F} | pamscale -xsize {X} -ysize {Y} | {P} | pnmtojpeg -quality {Q} > {O}'.format(\
                F=png_src_filename,\
                Y=input_height,\
                X=input_width,\
                P=jpeg_processing,\
                Q=jpeg_quality,\
                O=jpeg_dest_filename)
        else:
            cmd_create_input_image = 'pngtopam {F} | pamscale -xsize {X} -ysize {Y} | pnmtojpeg -quality {Q} > {O}'.format(\
                F=png_src_filename,\
                Y=input_height,\
                X=input_width,\
                Q=jpeg_quality,\
                O=jpeg_dest_filename)
        logger.info("Running command to create input: {C}".format(C=cmd_create_input_image))
        os.system(cmd_create_input_image)
        if not os.path.isfile(jpeg_dest_filename):
            logger.error(\
                "Failed to generate {X}x{Y} image input for the image classification model.".format(\
                    X=input_width,
                    Y=input_height))
            return False
        if Path(jpeg_dest_filename).stat().st_size == 0:
            logger.error("Generated image input is an empty file (0 KB).")
            return False
        return True
def create_input_image ( self , png_src_filename , jpeg_dest_filename , input_height , input_width , jpeg_scaling , jpeg_quality , jpeg_processing ) : if jpeg_processing != 'none' : cmd_create_input_image = 'pngtopam {F} | pamscale -xsize {X} -ysize {Y} | {P} | pnmtojpeg -quality {Q} > {O}' . format ( F = png_src_filename , Y = input_height , X = input_width , P = jpeg_processing , Q = jpeg_quality , O = jpeg_dest_filename ) else : cmd_create_input_image = 'pngtopam {F} | pamscale -xsize {X} -ysize {Y} | pnmtojpeg -quality {Q} > {O}' . format ( F = png_src_filename , Y = input_height , X = input_width , Q = jpeg_quality , O = jpeg_dest_filename ) logger . info ( "Running command to create input: {C}" . format ( C = cmd_create_input_image ) ) os . system ( cmd_create_input_image ) if not os . path . isfile ( jpeg_dest_filename ) : logger . error ( "Failed to generate {X}x{Y} image input for the image classification model." . format ( X = input_width , Y = input_height ) ) return False if Path ( jpeg_dest_filename ) . stat ( ) . st_size == 0 : logger . error ( "Generated image input is an empty file (0 KB)." ) return False return True
Create image file as an input to the image classifier.
Create image file as an input to the image classifier .
"""Create image file as an input to the image classifier.""" # Build the command string to create the image input for the image classification program. # FIXME create input jpeg directly from the thumbnail jpeg instead of from the png. Maye require an ipk to install jpegtopnm. # Log the command that will be executed. # Run the command to create the image input file for the image classification program. # Check that the image input exists. # An error in executing the pamscale command can produce an empty image input file. # Return success boolean value.
self
png_src_filename
jpeg_dest_filename
input_height
input_width
jpeg_scaling
jpeg_quality
jpeg_processing