Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
50 lines (36 loc) · 1.25 KB

File metadata and controls

50 lines (36 loc) · 1.25 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import tensorflow as tf
import numpy as np
import os
import cv2
from PIL import Image
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]))
DEPTH = 3
def convert_to(data_path, name):
rows = 256
cols = 256
depth = DEPTH
writer = tf.python_io.TFRecordWriter(name + '.tfrecords')
for img_name in os.listdir(data_path):
img_path = data_path + '\\' + img_name
img = Image.open(img_path)
img = img.resize((256, 256))
img_raw = img.tobytes()
label = img_name[:-4]
label = int(label)
example = tf.train.Example(features = tf.train.Features(feature = {
'image_label': _int64_feature(label),
'image_raw':_bytes_feature(img_raw)
}))
writer.write(example.SerializeToString())
writer.close()
data_path = r'E:\work\Python\shoes\train\images'
name = 'shoes_images_train'
convert_to(data_path, name)
data_path = r'E:\work\Python\shoes\train\sketches'
name = 'shoes_sketches_train'
convert_to(data_path, name)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.