mirror of
https://github.com/Deepshift/DeepCreamPy.git
synced 2025-02-13 15:40:03 +00:00
added ignore in models and changes argument names not to confuse
This commit is contained in:
parent
f145885620
commit
bdf8fd904e
253
.gitignore
vendored
Normal file
253
.gitignore
vendored
Normal file
@ -0,0 +1,253 @@
|
||||
|
||||
# Created by https://www.gitignore.io/api/linux,python,windows,pycharm
|
||||
# Edit at https://www.gitignore.io/?templates=linux,python,windows,pycharm
|
||||
|
||||
### Linux ###
|
||||
*~
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
|
||||
### PyCharm ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
### PyCharm Patch ###
|
||||
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
|
||||
|
||||
# *.iml
|
||||
# modules.xml
|
||||
# .idea/misc.xml
|
||||
# *.ipr
|
||||
|
||||
# Sonarlint plugin
|
||||
.idea/sonarlint
|
||||
|
||||
### Python ###
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
pip-wheel-metadata/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# celery beat schedule file
|
||||
celerybeat-schedule
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
### Windows ###
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
Thumbs.db:encryptable
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
# End of https://www.gitignore.io/api/linux,python,windows,pycharm
|
24
decensor.py
24
decensor.py
@ -36,17 +36,21 @@ class Decensor:
|
||||
return mask
|
||||
|
||||
def load_model(self):
|
||||
self.model = InpaintNN(bar_model_name = "./models/bar/Train_775000.meta", bar_checkpoint_name = "./models/bar/", mosaic_model_name = "./models/mosaic/Train_290000.meta", mosaic_checkpoint_name = "./models/mosaic/", is_mosaic=self.is_mosaic)
|
||||
|
||||
self.model = InpaintNN( bar_model_name = "./models/bar/Train_775000.meta",
|
||||
bar_checkpoint_name = "./models/bar/",
|
||||
mosaic_model_name = "./models/mosaic/Train_290000.meta",
|
||||
mosaic_checkpoint_name = "./models/mosaic/",
|
||||
is_mosaic=self.is_mosaic)
|
||||
|
||||
def decensor_all_images_in_folder(self):
|
||||
#load model once at beginning and reuse same model
|
||||
#self.load_model()
|
||||
color_dir = self.args.decensor_input_path
|
||||
file_names = os.listdir(color_dir)
|
||||
|
||||
|
||||
input_dir = self.args.decensor_input_path
|
||||
output_dir = self.args.decensor_output_path
|
||||
|
||||
|
||||
# Change False to True before release --> file.check_file( input_dir, output_dir, True)
|
||||
file_names, self.files_removed = file.check_file( input_dir, output_dir, False)
|
||||
|
||||
@ -64,7 +68,7 @@ class Decensor:
|
||||
self.files_removed.append((color_file_path,3))
|
||||
# incase of abnormal file format change (ex : text.txt -> text.png)
|
||||
continue
|
||||
|
||||
|
||||
#if we are doing a mosaic decensor
|
||||
if self.is_mosaic:
|
||||
#get the original file that hasn't been colored
|
||||
@ -91,7 +95,7 @@ class Decensor:
|
||||
if(self.files_removed is not None):
|
||||
file.error_messages(None, self.files_removed)
|
||||
print("\nDecensoring complete!")
|
||||
|
||||
|
||||
#decensors one image at a time
|
||||
#TODO: decensor all cropped parts of the same image in a batch (then i need input for colored an array of those images and make additional changes)
|
||||
def decensor_image(self, ori, colored, file_name=None):
|
||||
@ -146,13 +150,13 @@ class Decensor:
|
||||
mask_img = mask_img.crop(bounding_box)
|
||||
mask_img = mask_img.resize((256, 256))
|
||||
# mask_img.show()
|
||||
#convert mask_img back to array
|
||||
#convert mask_img back to array
|
||||
mask_array = image_to_array(mask_img)
|
||||
#the mask has been upscaled so there will be values not equal to 0 or 1
|
||||
|
||||
# mask_array[mask_array > 0] = 1
|
||||
# crop_img_array[..., :-1][mask_array==0] = (0,0,0)
|
||||
|
||||
|
||||
if not self.is_mosaic:
|
||||
a, b = np.where(np.all(mask_array == 0, axis = -1))
|
||||
# print(a,b)
|
||||
@ -182,7 +186,7 @@ class Decensor:
|
||||
# print(np.amax(crop_img_array))
|
||||
# print(np.amax(mask_array))
|
||||
# # print(np.amax(masked))
|
||||
|
||||
|
||||
# print(np.amin(crop_img_array))
|
||||
# print(np.amin(mask_array))
|
||||
# # print(np.amin(masked))
|
||||
@ -194,7 +198,7 @@ class Decensor:
|
||||
|
||||
# Run predictions for this batch of images
|
||||
pred_img_array = self.model.predict(crop_img_array, crop_img_array, mask_array)
|
||||
|
||||
|
||||
pred_img_array = np.squeeze(pred_img_array, axis = 0)
|
||||
pred_img_array = (255.0 * ((pred_img_array + 1.0) / 2.0)).astype(np.uint8)
|
||||
|
||||
|
9
file.py
9
file.py
@ -1,13 +1,12 @@
|
||||
import os
|
||||
|
||||
def check_file(input_dir, output_dir, Release_version = True):
|
||||
def check_file(input_dir_path, output_dir_path, Release_version = True):
|
||||
file_list = []
|
||||
output_file_list = []
|
||||
files_removed = []
|
||||
input_dir = os.listdir(input_dir_path)
|
||||
output_dir = os.listdir(output_dir_path)
|
||||
|
||||
input_dir = os.listdir(input_dir)
|
||||
output_dir = os.listdir(output_dir)
|
||||
|
||||
for file_in in input_dir:
|
||||
if not file_in.startswith('.'):
|
||||
file_list.append(file_in)
|
||||
@ -53,4 +52,4 @@ def error_messages(file_list, files_removed):
|
||||
elif reason == 1:
|
||||
print(" REMOVED : (" + str(remove_this) +") already exists")
|
||||
elif reason == 2:
|
||||
print(" REMOVED : (" + str(remove_this) +") file unreadable")
|
||||
print(" REMOVED : (" + str(remove_this) +") file unreadable")
|
||||
|
2
models/.gitignore
vendored
2
models/.gitignore
vendored
@ -1 +1,3 @@
|
||||
*.h5
|
||||
/bar/*
|
||||
/mosaic/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user