This repository has been archived by the owner on Aug 5, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the APIs,scripts and models to support DCGAN.
- Loading branch information
Yu, Chong
committed
Oct 31, 2017
1 parent
3b14c6f
commit f9ccaa5
Showing
12 changed files
with
1,087 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/Celeb-A_Cropped/000001.jpg 1 | ||
/Celeb-A_Cropped/000002.jpg 1 | ||
/Celeb-A_Cropped/000003.jpg 1 | ||
/Celeb-A_Cropped/000004.jpg 1 | ||
/Celeb-A_Cropped/000005.jpg 1 | ||
/Celeb-A_Cropped/000006.jpg 1 | ||
/Celeb-A_Cropped/000007.jpg 1 | ||
/Celeb-A_Cropped/000008.jpg 1 | ||
/Celeb-A_Cropped/000009.jpg 1 | ||
/Celeb-A_Cropped/000010.jpg 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from PIL import Image | ||
import os | ||
import sys | ||
|
||
print "" | ||
print "Prepare Celeb-A Dataset! (1. Crop the images. 2. Generate a train list file.)" | ||
print "" | ||
print "-------------------------------------------------------------------------------" | ||
|
||
current_path = os.getcwd() | ||
celebA_path = "" | ||
celebA_cropped_path = "" | ||
print "The current path containing this python file is: " + current_path | ||
if len(sys.argv) == 1: | ||
print "Please give the path of original Celeb-A dataset!" | ||
exit(0) | ||
elif len(sys.argv) > 1: | ||
print "The path of original Celeb-A dataset is: " + str(sys.argv[1]) | ||
celebA_path = sys.argv[1] | ||
celebA_cropped_path = os.path.dirname(celebA_path) + os.sep + "Cropped" #To avoid crop the generated images again if this parameter is not provided | ||
if len(sys.argv) > 2: | ||
print "The path of cropped Celeb-A dataset will be: " + str(sys.argv[2]) | ||
celebA_cropped_path = sys.argv[2] | ||
else: | ||
print "The path of cropped Celeb-A dataset will be defult, set as: " + celebA_cropped_path | ||
|
||
if os.path.exists(celebA_cropped_path): | ||
print "The path of cropped Celeb-A dataset exists." | ||
else: | ||
print "The path of cropped Celeb-A dataset doesn't exist! I will create it now!" | ||
os.makedirs(celebA_cropped_path) | ||
print "-------------------------------------------------------------------------------" | ||
|
||
training_list_file = os.path.join(celebA_cropped_path, "celebA.txt") | ||
list_file = open(training_list_file, 'w') | ||
total_image_num = 0 | ||
x1, y1 = 30, 40 | ||
cropped_box = (x1, y1, x1 + 138, y1 + 138) | ||
|
||
for parent,dirnames,filenames in os.walk(celebA_path): | ||
for filename in filenames: | ||
if filename.endswith(".jpg"): | ||
total_image_num += 1 | ||
#print "parent is:" + parent | ||
#print "filename is:" + filename | ||
image_path_and_name = os.path.join(parent,filename) | ||
print "the full name of the file is: " + image_path_and_name | ||
input_image = Image.open(image_path_and_name) | ||
#input_image.show() | ||
cropped_image = input_image.crop(cropped_box) | ||
#cropped_image.show() | ||
scaled_cropped_image = cropped_image.resize((64, 64)) | ||
#scaled_cropped_image.show() | ||
save_result_image_path_and_name = os.path.join(celebA_cropped_path,filename) | ||
scaled_cropped_image.save(save_result_image_path_and_name, 'jpeg') | ||
list_file.writelines(save_result_image_path_and_name) | ||
list_file.writelines(" 1" + "\n") #Must add label to list file | ||
print "There are " + str(total_image_num) + " images are finished with cropping and scaling operations!" | ||
list_file.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
layer { | ||
name: "data" | ||
type: "ImageData" | ||
top: "data" | ||
top: "label" | ||
transform_param { | ||
mirror: true | ||
mean_value: 104 | ||
mean_value: 117 | ||
mean_value: 123 | ||
} | ||
image_data_param { | ||
source: "data/Celeb-A/celebA.txt" | ||
batch_size: 64 | ||
} | ||
} |
Oops, something went wrong.