Giter VIP home page Giter VIP logo

face-similarity's Issues

Failed with my own tfrecords.

Thank you for your share.
I got a problem when I run it with my own data.
I make bmp files to tfrecords with code below:

import tensorflow as tf
import cv2
import numpy as np

datalistfile = './images/data'
''' format of datalistfile
0 ./images/cgh_0.bmp ./images/cgh_10.bmp
0 ./images/cgh_10.bmp ./images/cgh_11.bmp
'''
dataf = open(datalistfile,'r')
writer = tf.python_io.TFRecordWriter("test.tfrecords")

def _int64_feature(value):
return tf.train.Feature(int64_list=tf.train.Int64List(value = [value]))

def _bytes_feature(value):
return tf.train.Feature(bytes_list=tf.train.BytesList(value = [value]))

data = dataf.readlines()
for i in range(len(data)):
line = data[i]
line = line.strip()
line = line.split(" ")
Xi = tf.gfile.FastGFile(line[1], 'rb').read() # image data type is string
Xj = tf.gfile.FastGFile(line[2], 'rb').read() # image data type is string
image_shape = cv2.imread(line[1]).shape
width = image_shape[1]
height = image_shape[0]
label = int(line[0])
features = {
'Xi': _bytes_feature(Xi),
'Xj': _bytes_feature(Xj),
"label": _int64_feature(label),
"height": _int64_feature(height),
"width": _int64_feature(width)
}
example = tf.train.Example(features = tf.train.Features(feature=features))
writer.write(example.SerializeToString())
writer.close()

So , can you tell me how do you make your test_v2.tfrecords from images?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.