Hyunjun

add dataset

...@@ -59,3 +59,9 @@ googel chrome의 확장프로그램을 활용한 구글 이미지 검색 결과 크롤링 프로그램 구현 ...@@ -59,3 +59,9 @@ googel chrome의 확장프로그램을 활용한 구글 이미지 검색 결과 크롤링 프로그램 구현
59 make_img.py에서는 라즈베리파이에 연결된 카메라가 촬영을 하면 그 사진을 32*32*3 사이즈로 resize해준 후 input.txt파일로 변환해줌 59 make_img.py에서는 라즈베리파이에 연결된 카메라가 촬영을 하면 그 사진을 32*32*3 사이즈로 resize해준 후 input.txt파일로 변환해줌
60 main.cpp에서 convnet 코드 실행 60 main.cpp에서 convnet 코드 실행
61 predict.sh 쉘파일로 전체 실행 61 predict.sh 쉘파일로 전체 실행
62 +
63 +
64 +13. dataset 추가
65 +image_process.py : cropping을 통해 정사각형 형태를 만들고 32*32 크기로 resize, 사진 반전, 회전을 통해 사진 1개당 8개의 데이터를 생성
66 +크롤링을 통해 휴지, 소주, 캔음료, 라면, 삼각김밥 각각 500개씩의 이미지를 다운받음
67 +한 카테고리당 4000개의 데이터를 생성
...\ No newline at end of file ...\ No newline at end of file
......
1 +import os, sys
2 +from PIL import Image
3 +
4 +def make_img(filename):
5 + try:
6 + with Image.open(filename + '.png') as im:
7 + print("File ("+filename +".png)")
8 +
9 + if im.width<im.height :
10 + crop_size = (im.height-im.width)/2
11 + area = (0, int(crop_size), im.width, int(crop_size)+im.width)
12 +
13 + elif im.width>im.height :
14 + crop_size = (im.width-im.height) / 2
15 + area = (int(crop_size), 0, int(crop_size)+im.height, im.height)
16 +
17 + else :
18 + area = (0, 0, im.width , im.height)
19 +
20 + cropped_img = im.crop(area)
21 + cropped_img.thumbnail((32, 32))
22 + cropped_img.save(filename + "_0.png")
23 +
24 + im2 = cropped_img.rotate(90)
25 + im2.save(filename + "_90.png")
26 +
27 + im3 = cropped_img.rotate(180)
28 + im3.save(filename + "_180.png")
29 +
30 + im4 = cropped_img.rotate(270)
31 + im4.save(filename + "_270.png")
32 +
33 + im_transpose = cropped_img.transpose(Image.FLIP_LEFT_RIGHT)
34 + im5 = im_transpose
35 + im5.save(filename + "_transpose_0.png")
36 +
37 + im6 = im_transpose.rotate(90)
38 + im6.save(filename + "_transpose_90.png")
39 +
40 + im7 = im_transpose.rotate(180)
41 + im7.save(filename + "_transpose_180.png")
42 +
43 + im8 = im_transpose.rotate(270)
44 + im8.save(filename + "_transpose_270.png")
45 +
46 + os.remove(filename+'.png')
47 +
48 + except IOError:
49 + print("No file ("+filename +".png)")
50 +
51 +
52 +
53 +for i in range(0,1000):
54 + filename = str(i)
55 + make_img(filename)
56 + filename = '0' + str(i)
57 + make_img(filename)
No preview for this file type
This file is too large to display.
No preview for this file type
No preview for this file type
No preview for this file type