Skip to content

Latest commit

ย 

History

History
78 lines (68 loc) ยท 5.09 KB

README.md

File metadata and controls

78 lines (68 loc) ยท 5.09 KB

Fake_or_Real

Image 1

Introduction

AI CONNECT Fake or Real ์ƒ์„ฑ์ด๋ฏธ์ง€ ํŒ๋ณ„ ๊ฒฝ์ง„๋Œ€ํšŒ 9์œ„ ๊ตฌํ˜„ ์ฝ”๋“œ ์ž…๋‹ˆ๋‹ค. ๋‹ค์–‘ํ•œ ์ƒ์„ฑ ๋ชจ๋ธ๋กœ ์ธํ•ด ์˜์ƒ ์œ„๋ณ€์กฐ์˜ ๋ฌธ์ œ๊ฐ€ ๋Œ€๋‘๋˜๋Š” ์ƒํ™ฉ ์†์—์„œ ์ƒ์„ฑ AI๊ฐ€ ๋งŒ๋“ค์–ด๋‚ธ ๊ฐ€์งœ(Fake) ์ด๋ฏธ์ง€์™€ ์ง„์งœ(Real) ์ด๋ฏธ์ง€๋ฅผ ๋ถ„๋ฅ˜ํ•˜๋Š” ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค.

Model

๋‹ค์–‘ํ•œ ๋ชจ๋ธ์„ ์‚ฌ์šฉํ•ด ๋ณด์•˜์œผ๋‚˜, ์ตœ์ข…์ ์œผ๋กœ Efficient Net์„ ์‚ฌ์šฉํ•˜์˜€์Šต๋‹ˆ๋‹ค. Train data์— ๋Œ€ํ•˜์—ฌ overfitting์ด ์‹ฌํ•˜์˜€๊ณ , ๋ณด๋‹ค ๋ณต์žกํ•œ ๋ชจ๋ธ์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์€ overfitting ์˜คํžˆ๋ ค ์‹ฌํ•˜๊ฒŒ ํ• ๊ฒƒ์ด๋ผ ํŒ๋‹จํ•˜์˜€๊ธฐ์—, ํšจ์œจ์ ์œผ๋กœ ํ•™์Šต์„ ์ง„ํ–‰ํ•  ์ˆ˜ ์žˆ๋Š” Efficient Net์„ ๊ธฐ๋ฐ˜์œผ๋กœ ์ง„ํ–‰ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

Data Augmentation

Validation์—์„œ accuracy, f1 score ๋ชจ๋‘ 99%์— ์œก๋ฐ•ํ•˜์ง€๋งŒ, ์ œ์ถœ์‹œ์— f1 score๊ฐ€ 70๋กœ ๊ฐ์†Œํ•˜๋Š” ์ƒํ™ฉ์ด์˜€๊ธฐ์— Overfitting์„ ํ•ด๊ฒฐํ•˜๋Š” ๊ฒƒ์ด ๊ฐ€์žฅ ์ค‘์š”ํ•˜๋‹ค๊ณ  ํŒ๋‹จ, ๊ฐ€์žฅ ํ™•์‹คํ•œ ๋ฐฉ๋ฒ•์ด Data Augmentation์„ ๋‹ค์–‘ํ•œ ๋ฐฉ๋ฒ•์œผ๋กœ ์‹œํ–‰ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

1) ์™ธ๋ถ€ ๋ฐ์ดํ„ฐ ํ™œ์šฉ

๋ณธ ๋Œ€ํšŒ๋Š” ํŠน์ดํ•˜๊ฒŒ๋„ ์™ธ๋ถ€ ๋ฐ์ดํ„ฐ๊ฐ€ ํ—ˆ์šฉ๋˜์–ด์žˆ๋Š” ๋Œ€ํšŒ์˜€๊ธฐ์— ์™ธ๋ถ€ ๋ฐ์ดํ„ฐ๋ฅผ ์ ๊ทน ํ™œ์šฉํ•˜๊ธฐ๋กœ ํ•˜์˜€์Šต๋‹ˆ๋‹ค. Kaggle์—์„œ Dalle, Midjourney, Stable Diffusion ๋ชจ๋ธ๋“ค์„ ๊ฐ๊ฐ 1000์žฅ, 2000์žฅ, 2000์žฅ ๋ฝ‘์•„์„œ ์ถ”๊ฐ€ํ•˜์˜€๊ณ (์–ด๋–ค ์ƒ์„ฑ๋ชจ๋ธ์„ ์‚ฌ์šฉํ•˜์˜€๋Š”์ง€ ๋ชฐ๋ž๊ธฐ์—, ๋˜๋„๋ก ๊ณ ๋ฅด๊ฒŒ ์‚ฌ์šฉํ•˜์˜€๊ณ , Dalle Dataset์˜ ํ€„๋ฆฌํ‹ฐ๊ฐ€ ์ข‹์ง€ ๋ชปํ•ด ๋น„์ค‘ ์ถ•์†Œ.), Image Net์—์„œ ์‹ค์ œ ๋ฐ์ดํ„ฐ๋ฅผ 5000์žฅ ์ถ”๊ฐ€ ํ•˜์—ฌ ๋ฐ์ดํ„ฐ ์ฆ๊ฐ•์„ ์ง„ํ–‰ํ•˜์˜€์Šต๋‹ˆ๋‹ค(Train set์—์„œ Fake : real ๋น„์œจ์ด 1:1).

Image 1 Image 2 Image 3
2) torchvisio.transforms

Torchvision์˜ transforms function์„ ํ™œ์šฉํ•˜์—ฌ ๊ธฐ์กด๋ฐ์ดํ„ฐ์™€, ์™ธ๋ถ€๋ฐ์ดํ„ฐ๋ฅผ ์ถ”๊ฐ€๋กœ ์ฆ๊ฐ•ํ•˜์˜€์Šต๋‹ˆ๋‹ค. Albumentations ๋ชจ๋“ˆ์€ ๋งŽ์ด ์‚ฌ์šฉํ•ด ๋ณด์•˜๊ธฐ์— Torchvision ์ž์ฒด์˜ ํ•จ์ˆ˜๋ฅผ ํ™œ์šฉํ•ด ๋ณด์•˜์Šต๋‹ˆ๋‹ค. Filp, Rotation, ColorJitter, Crop๋“ฑ์„ ๋‹ค์–‘ํ•˜๊ฒŒ ํ…Œ์ŠคํŠธ ํ•ด ๋ณด์•˜๊ณ  ๊ฒฐ๊ณผ์ ์œผ๋กœ๋Š” ์•„๋ž˜ 3๊ฐ€์ง€ ์ฆ๊ฐ•์„ ํ™œ์šฉํ•˜์˜€์Šต๋‹ˆ๋‹ค.

self.transforms = transforms.Compose([
            transforms.ToTensor(),
            transforms.Resize((224,224)),
            transforms.Normalize([0.485, 0.456,0.406],[0.229,0.224,0.225])
        ])
self.transforms = transforms.Compose([
            transforms.ToTensor(),
            transforms.Resize((256,256)),
            transforms.RandomCrop(200),
            transforms.ColorJitter(brightness=0.2, contrast=0.2, saturation=0.2, hue=0.2),
            transforms.RandomRotation(30),
            transforms.Resize((224, 224)),
            transforms.Normalize([0.485, 0.456,0.406],[0.229,0.224,0.225])
        ])
self.transforms = transforms.Compose([
            transforms.ToTensor(),
            transforms.Resize((256,256)),
            transforms.RandomCrop(224),
            transforms.ColorJitter(brightness=0.2, contrast=0.2, saturation=0.2, hue=0.2),
            transforms.RandomHorizontalFlip(p = 1),
            transforms.RandomRotation(15),
            transforms.Resize((224, 224)),
            transforms.Normalize([0.485, 0.456,0.406],[0.229,0.224,0.225])
        ])


Ensemble

์ตœ์ข…์ ์œผ๋กœ๋Š” ๋‹ค์–‘ํ•œ ๋ชจ๋ธ๋“ค์— ๋Œ€ํ•˜์—ฌ ensemble์„ soft vote ๋ฐฉ์‹์œผ๋กœ ์ง„ํ–‰ํ•˜์—ฌ ์„ฑ๋Šฅ์„ ์ตœ๋Œ€ํ•œ ๋Œ์–ด ์˜ฌ๋ ธ์Šต๋‹ˆ๋‹ค. Train Set์˜ ์ด๋ฏธ์ง€์˜ size๊ฐ€ ๋‹ค์–‘ํ–ˆ๊ธฐ์—, ๋‹ค์–‘ํ•œ size๋กœ ํ•™์Šตํ•œ ๋ชจ๋ธ๋“ค์„ ์•™์ƒ๋ธ” ํ•˜๋ฉด ๋” ์ข‹์€ ์„ฑ๋Šฅ์„ ์–ป์„ ๊ฒƒ์ด๋ผ๊ณ  ํŒ๋‹จํ•˜์˜€๊ณ , ์ด๋ฏธ์ง€์˜ ํฌ๊ธฐ๋ฅผ ๋‹ค๋ฅด๊ฒŒ ํ•˜์—ฌ ํ•™์Šตํ•œ ๋ชจ๋ธ๋“ค์ค‘ ์„ฑ๋Šฅ์ด ์ข‹์€ ๋‹ค์„ฏ๊ฐœ๋ฅผ ์„ ํƒํ•˜์—ฌ ์•™์ƒ๋ธ”์„ ์ง„ํ–‰ํ•˜์˜€์Šต๋‹ˆ๋‹ค. (224x224, 256x256 , 456x456)