Browse Source

Docs modifications

master
deeppppp 3 years ago
parent
commit
a071989f6c
  1. 10
      .github/FUNDING.yml
  2. 4
      .github/stale.yml
  3. 31
      .github/workflows/ci.yml
  4. 69
      README.md
  5. 3
      argv/checkpoints.py
  6. BIN
      assets/preview.png
  7. 13
      checkpoints.py
  8. 4
      config.py
  9. 4
      processing/folder.py
  10. 29
      processing/image.py
  11. 14
      processing/utils.py
  12. 5
      scripts/package.json
  13. 112
      scripts/release.js
  14. 40
      transform/opencv/resize.py
  15. 4
      utils.py

10
.github/FUNDING.yml

@ -1,12 +1,4 @@ @@ -1,12 +1,4 @@
# These are supported funding model platforms
#github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: deepmanyy # Replace with a single Patreon username
#open_collective: # Replace with a single Open Collective username
ko_fi: deepmanyy # Replace with a single Ko-fi username
#tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
#community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
#liberapay: # Replace with a single Liberapay username
#issuehunt: # Replace with a single IssueHunt username
#otechie: # Replace with a single Otechie username
#custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
patreon: dreampower # Replace with a single Patreon username

4
.github/stale.yml

@ -1,11 +1,13 @@ @@ -1,11 +1,13 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 30
daysUntilStale: 60
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- security
- documentation
- enhancement
# Label to use when marking an issue as stale
staleLabel: wontfix
# Comment to post when marking an issue as stale. Set to `false` to disable

31
.github/workflows/ci.yml

@ -1,9 +1,8 @@ @@ -1,9 +1,8 @@
name: CI
name: CI/CD
on:
push:
branches:
- master
- canary
tags:
- v*
@ -14,7 +13,7 @@ on: @@ -14,7 +13,7 @@ on:
jobs:
build:
name: Build (${{ matrix.os-short }}-${{ matrix.device }})
name: Build (${{ matrix.os-short }}-${{ matrix.platform }})
runs-on: ${{ matrix.os }}
# Strategy
@ -27,42 +26,33 @@ jobs: @@ -27,42 +26,33 @@ jobs:
- ubuntu-latest
- windows-latest
- macOS-latest
device:
platform:
- any
- cpuonly
include:
- os: ubuntu-latest # Ubuntu
os-short: ubuntu
os-ext: deb
python: python3
- os: ubuntu-latest # Ubuntu & CPU
device: cpuonly
platform: cpuonly
setup-args: --cpu
- os: windows-latest # Windows
os-short: windows
os-ext: exe
python: python
- os: windows-latest # Windows & CPU
device: cpuonly
platform: cpuonly
setup-args: --cpu
- os: macOS-latest # macOS
os-short: macos
os-ext: dmg
python: python3
setup-args: --cpu
exclude:
- os: macOS-latest
device: any
platform: any
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
continue-on-error: true
- uses: actions/checkout@v1
with:
submodules: true
@ -96,20 +86,19 @@ jobs: @@ -96,20 +86,19 @@ jobs:
run: |
${{ matrix.python }} setup.py --debug --pip_no_cache_dir ${{ matrix.setup-args }}
- name: Build - DreamPower
- name: Build
working-directory: scripts
run: |
${{ matrix.python }} build.py --debug
- name: Deploy
- name: Release
working-directory: scripts
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}
S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
S3_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
BUILD_DEVICE: ${{ matrix.device }}
BUILD_OS: ${{ matrix.os-short }}
BUILD_PLATFORM: ${{ matrix.platform }}
run: |
node release.js

69
README.md

@ -1,83 +1,71 @@ @@ -1,83 +1,71 @@
![](assets/dreampower.png)
[![Build Status](https://github.com/private-dreamnet/dreampower/workflows/CI/badge.svg)](https://github.com/private-dreamnet/dreampower/actions)
[![GitHub All Releases](https://img.shields.io/github/downloads/private-dreamnet/dreampower/total?logo=github&logoColor=white)](https://github.com/private-dreamnet/dreampower/releases)
[![Build Status](https://github.com/dreamnettech/dreampower/workflows/CI/CD/badge.svg)](https://github.com/dreamnettech/dreampower/actions)
[![GitHub All Releases](https://img.shields.io/github/downloads/dreamnettech/dreampower/total?logo=github&logoColor=white)](https://github.com/dreamnettech/dreampower/releases)
![GitHub](https://img.shields.io/github/license/private-dreamnet/dreampower)
![GitHub top language](https://img.shields.io/github/languages/top/private-dreamnet/dreampower)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/fcea261a567c47109419d0572160fecf)](https://www.codacy.com/app/kolessios/dreampower?utm_source=github.com&utm_medium=referral&utm_content=private-dreamnet/dreampower&utm_campaign=Badge_Grade)
[![Maintainability](https://api.codeclimate.com/v1/badges/c8cd0a0f104820adc2ba/maintainability)](https://codeclimate.com/github/private-dreamnet/dreampower/maintainability)
![GitHub](https://img.shields.io/github/license/dreamnettech/dreampower)
![GitHub top language](https://img.shields.io/github/languages/top/dreamnettech/dreampower)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/fcea261a567c47109419d0572160fecf)](https://www.codacy.com/app/kolessios/dreampower?utm_source=github.com&utm_medium=referral&utm_content=dreamnettech/dreampower&utm_campaign=Badge_Grade)
[![Maintainability](https://api.codeclimate.com/v1/badges/c8cd0a0f104820adc2ba/maintainability)](https://codeclimate.com/github/dreamnettech/dreampower/maintainability)
# DreamPower
DreamPower is a deep learning algorithm based on [DeepNude](https://github.com/stacklikemind/deepnude_official) with the ability to predict what a naked person's body looks like.
DreamPower is a deep learning algorithm based on [DeepNude](https://github.com/stacklikemind/deepnude_official) with the ability to nudify photos of people.
DreamPower is a CLI application, if you are looking for a **friendly way** to use DreamPower, please use the user interface: [DreamTime](https://time.dreamnet.tech).
DreamPower is a CLI application. If you have no experience in terminals you can use [DreamTime](https://time.dreamnet.tech), an easy way to use the power of DreamPower.
![](assets/preview.png)
## Differences with DeepNude
> If you want to share or modify this software please do it for the same purpose as we do and always release the source code of your modifications. Read the [LICENSE](LICENSE) for more information.
DreamPower is a fork of [deepnude_official](https://github.com/stacklikemind/deepnude_official) but with constant improvements from the developers of DreamNet and the world, we stand out for offering these features:
## Better than DeepNude.
DreamPower is a fork of [deepnude_official](https://github.com/stacklikemind/deepnude_official) but with constant improvements from DreamNet developers and the world, we stand out for offering these features:
- GPU Processing (Transformation in ~10 seconds!)
- Multiple GPU support
- Multithreading
- Auto-resize, auto-rescale, etc
- Support to transform animated GIFs
- Animated GIFs support
- Customization: size of boobs, pubic hair, etc.
- Constant updates!
## DreamNet
Join the DreamNet social networks, the community interested in developing this technology. You can also join just to talk and make friends:
[![Keybase](https://img.shields.io/badge/keybase-33A0FF?logo=keybase&logoColor=white&style=for-the-badge)](https://keybase.io/team/dreamnet)
[![Twitter](https://img.shields.io/twitter/follow/DreamNetCom?label=twitter&logo=twitter&logoColor=white&style=for-the-badge&labelColor=1DA1F2)](https://twitter.com/DreamNetCom)
[![Facebook](https://img.shields.io/badge/facebook-4172B8?logo=facebook&logoColor=white&style=for-the-badge)](https://web.facebook.com/groups/812542509140670)
We are a community interested in developing decentralized applications free of censorship. Join our social networks or repositories:
- [Website](https://dreamnet.tech)
- [GitHub](https://github.com/dreamnettech)
- [NotABug](https://notabug.org/DreamNet)
- [GitGud](https://gitgud.io/dreamnet)
## Support
Developing DreamNet applications is time consuming! Help us accelerate development and offer better updates!
We work every day to offer new features and improvements to the program for free, support us financially to offer more constant and large updates!
[![patreon](https://img.shields.io/badge/become%20a%20patron-fb6c54?logo=patreon&logoColor=white&style=for-the-badge)](https://www.patreon.com/dreampower)
## Source Code
This technology was going to arrive sooner or later and we want to keep it open and free for everyone. Help us in our goal of developing more applications with this technology.
[![GitHub stars](https://img.shields.io/github/stars/private-dreamnet/dreampower?logo=github&style=for-the-badge&labelColor=181717&label=Github)](https://github.com/private-dreamnet/dreampower)
[![DreamNet](https://img.shields.io/badge/dreamnet-E24329?logo=git&logoColor=white&style=for-the-badge)](https://git.dreamnet.tech/dreamnet/dreampower)
[![NotABug](https://img.shields.io/badge/notabug-black?logo=git&logoColor=white&style=for-the-badge)](https://notabug.org/DreamNet/dreampower)
[![GitGud](https://img.shields.io/badge/gitgud-F05032?logo=git&logoColor=white&style=for-the-badge)](https://gitgud.io/dreamnet/dreampower)
If you want to share or modify this software please do it for the same purpose as we do and always release the source code of your modifications. Read the [LICENSE](LICENSE) for more information.
# 💜 Binaries
# 🎉 Releases
## Requirements
- 64 bits OS
- Windows 7 SP1/Windows 8/Windows 10 1803+
- Ubuntu 16.04+
- macOS
- macOS Catalina 10.15+
- **8 GB** of RAM or more.
## GPU Processing Requirements
### GPU Processing
- NVIDIA Graphics card with minimum [3.5 CUDA compute capability](https://developer.nvidia.com/cuda-gpus)
- [Latest NVIDIA drivers](https://www.nvidia.com/Download/index.aspx)
- NVIDIA GPU with minimum [3.5 CUDA compute capability.](https://developer.nvidia.com/cuda-gpus)
- [Latest NVIDIA drivers.](https://www.nvidia.com/Download/index.aspx)
> 👉 If you do not have an NVIDIA or compatible graphics card you can use CPU processing.
> 👉 If you do not have an NVIDIA or compatible GPU you can use CPU processing.
## Download
[![GitHub All Releases](https://img.shields.io/github/downloads/private-dreamnet/dreampower/total?logo=github&logoColor=white&style=for-the-badge&labelColor=181717&color=blue)](https://github.com/private-dreamnet/dreampower/releases)
[![GitHub All Releases](https://img.shields.io/github/downloads/dreamnettech/dreampower/total?logo=github&logoColor=white&style=for-the-badge&labelColor=181717&color=blue)](https://github.com/dreamnettech/dreampower/releases)
## Installation
@ -108,12 +96,11 @@ This will print out help on the parameters the algorithm accepts. @@ -108,12 +96,11 @@ This will print out help on the parameters the algorithm accepts.
---
# 💻 Development > 🚧 Area only for developers!
> **If you are a developer:** Consider making a fork of the project and make PR of any improvement you can do, also join our server in [Keybase](https://keybase.io/team/dreamnet) where we have channels exclusively for development.
# 💻 Development
## Requirements
- [CUDA 10.0](https://developer.nvidia.com/cuda-10.0-download-archive)
- [Python 3.5+](https://www.python.org/downloads/)
## Prerequisite

3
argv/checkpoints.py

@ -47,7 +47,7 @@ def check_arg_checkpoints(parser, args): @@ -47,7 +47,7 @@ def check_arg_checkpoints(parser, args):
Conf.log.debug(args.checkpoints)
if not ('download' in str(args.func)):
for _, v in args.checkpoints.items():
if not os.path.isfile(v):
if (_ != 'checkpoints_path' and not os.path.isfile(v)):
parser.error(
"Checkpoints file not found! "
"You can download them using : {} checkpoints download".format(sys.argv[0])
@ -60,6 +60,7 @@ def set_arg_checkpoints(args): @@ -60,6 +60,7 @@ def set_arg_checkpoints(args):
'correct_to_mask': os.path.join(str(args.checkpoints), "cm.lib"),
'maskref_to_maskdet': os.path.join(str(args.checkpoints), "mm.lib"),
'maskfin_to_nude': os.path.join(str(args.checkpoints), "mn.lib"),
'checkpoints_path': str(args.checkpoints),
}

BIN
assets/preview.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 48 KiB

13
checkpoints.py

@ -38,17 +38,20 @@ def download(_): @@ -38,17 +38,20 @@ def download(_):
try:
Conf.log.info("Downloading {}".format(cdn_url))
dl_file(Conf.checkpoints_cdn.format(Conf.checkpoints_version), temp_zip)
if not os.path.exists(Conf.args['checkpoints']['checkpoints_path']):
os.mkdir(Conf.args['checkpoints']['checkpoints_path'])
Conf.log.info("Extracting {}".format(temp_zip))
unzip(temp_zip, Conf.args['checkpoints'])
unzip(temp_zip, Conf.args['checkpoints']['checkpoints_path'])
Conf.log.info("Moving Checkpoints To Final Location")
for c in ("cm.lib", "mm.lib", "mn.lib"):
if os.path.isfile(os.path.join(Conf.args['checkpoints'], c)):
os.remove(os.path.join(Conf.args['checkpoints'], c))
shutil.move(os.path.join(Conf.args['checkpoints'], 'checkpoints', c), Conf.args['checkpoints'])
shutil.rmtree(os.path.join(Conf.args['checkpoints'], 'checkpoints'))
if os.path.isfile(os.path.join(Conf.args['checkpoints']['checkpoints_path'], c)):
os.remove(os.path.join(Conf.args['checkpoints']['checkpoints_path'], c))
shutil.move(os.path.join(Conf.args['checkpoints']['checkpoints_path'], 'checkpoints', c), Conf.args['checkpoints']['checkpoints_path'])
shutil.rmtree(os.path.join(Conf.args['checkpoints']['checkpoints_path'], 'checkpoints'))
except Exception as e:
Conf.log.error(e)

4
config.py

@ -4,9 +4,9 @@ @@ -4,9 +4,9 @@
class Config:
"""Variables Configuration Class."""
version = "v1.2.2"
version = "v1.2.3"
checkpoints_version = "v0.0.1"
checkpoints_cdn = "https://cdn.dreamnet.tech/releases/checkpoints/{}.zip"
checkpoints_cdn = "https://catalina.dreamnet.tech/ipns/QmUvudWPzRa7hgDSVFiwzFzviAZJohTrvHJNhnvytuPv3H/Releases/Checkpoints/{}.zip"
# experiment specifics
norm = "batch" # instance normalization or batch normalization

4
processing/folder.py

@ -8,7 +8,7 @@ from json import JSONDecodeError @@ -8,7 +8,7 @@ from json import JSONDecodeError
from config import Config as Conf
from processing.multiple import MultipleImageProcessing
from processing.utils import select_phases
from processing.utils import select_phases, is_file
from utils import is_a_supported_image_file_extension
@ -24,7 +24,7 @@ class FolderImageProcessing(MultipleImageProcessing): @@ -24,7 +24,7 @@ class FolderImageProcessing(MultipleImageProcessing):
for r, _, _ in os.walk(self._input_folder_path):
args = copy.deepcopy(self._args)
args['input'] = [
x.path for x in os.scandir(r) if x.is_file() and is_a_supported_image_file_extension(x.path)
x.path for x in os.scandir(r) if is_file(args, x.path) and is_a_supported_image_file_extension(x.path)
]
args['phases'] = select_phases(self._args)
args['output'] = [

29
processing/image.py

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
"""Image Transform Processing."""
import os
import sys
import hashlib
from config import Config as Conf
from processing import Processing
@ -28,8 +29,25 @@ class ImageProcessing(Processing): @@ -28,8 +29,25 @@ class ImageProcessing(Processing):
Conf.log.debug("All Phases : {}".format(self.__phases))
Conf.log.debug("To Be Executed Phases : {}".format(self.__phases[self.__starting_step:self.__ending_step]))
path = self.__altered_path if os.path.isfile(self.__input_path) or not self._args.get('folder_altered') \
else os.path.join(self._args['folder_altered'], os.path.basename(self.__output_path))
imagename_no_ext = os.path.splitext(os.path.basename(self.__input_path))[0]
if (self._args.get('folder_altered')):
folder_name = imagename_no_ext + '_' + str(hashlib.md5(open(self.__input_path, 'rb').read()).hexdigest())
folder_path = os.path.join(self._args['folder_altered'], folder_name)
if (not os.path.isdir(folder_path)):
os.makedirs(folder_path, exist_ok=True)
self._args['folder_altered'] = folder_path
path = self._args['folder_altered']
elif (self.__altered_path):
folder_name = imagename_no_ext + '_' + str(hashlib.md5(open(self.__input_path, 'rb').read()).hexdigest())
folder_path = os.path.join(self.__altered_path, folder_name)
if (not os.path.isdir(folder_path)):
os.makedirs(folder_path, exist_ok=True)
self.__altered_path = folder_path
path = self.__altered_path
self.__image_steps = [self.__input_path] + [
os.path.join(path, "{}.png".format(p().__class__.__name__))
@ -61,9 +79,10 @@ class ImageProcessing(Processing): @@ -61,9 +79,10 @@ class ImageProcessing(Processing):
self.__image_steps.append(r)
if self.__altered_path:
path = self.__altered_path \
if os.path.isfile(self._args['input']) or not self._args.get('folder_altered') \
else os.path.join(self._args['folder_altered'], os.path.basename(self.__output_path))
if (self._args.get('folder_altered')):
path = self._args['folder_altered']
else:
path = self.__altered_path
write_image(r, os.path.join(path, "{}.png".format(p.__name__)))

14
processing/utils.py

@ -59,11 +59,19 @@ def auto_rescale(args, p): @@ -59,11 +59,19 @@ def auto_rescale(args, p):
return add_tail(args, p, ImageToRescale)
def is_file(args):
def is_file(args, path):
if not os.path.isfile(path):
return False
for mod in (overlay, auto_resize, auto_resize_crop, auto_rescale):
if args.get(mod.__name__):
return True
if not args['ignore_size']:
check_shape(args['input'])
check_shape(path)
else:
Conf.log.warn('Image Size Requirements Unchecked.')
return True
def scale_mod(args, p):
@ -71,7 +79,7 @@ def scale_mod(args, p): @@ -71,7 +79,7 @@ def scale_mod(args, p):
if args.get(mod.__name__):
return mod(args, p)
if os.path.isfile(Conf.args["input"]):
is_file(args)
is_file(args, Conf.args["input"])
return p

5
scripts/package.json

@ -5,12 +5,9 @@ @@ -5,12 +5,9 @@
"private": true,
"devDependencies": {
"@octokit/rest": "^16.28.7",
"aws-sdk": "^2.517.0",
"deferred": "^0.7.11",
"jszip": "^3.2.2",
"lodash": "^4.17.15",
"mime-types": "^2.1.24",
"node-7z": "^1.1.1",
"tar": "^4.4.10"
"node-7z": "^1.1.1"
}
}

112
scripts/release.js

@ -1,16 +1,13 @@ @@ -1,16 +1,13 @@
/*
* DreamTime | (C) 2019 by Ivan Bravo Bravo <ivan@dreamnet.tech>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License 3.0 as published by
* the Free Software Foundation.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// DreamPower.
// Copyright (C) DreamNet. All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License 3.0 as published by
// the Free Software Foundation. See <https://www.gnu.org/licenses/gpl-3.0.html>
//
// Written by Ivan Bravo Bravo <ivan@dreamnet.tech>, 2019.
const Octokit = require('@octokit/rest')
const AWS = require('aws-sdk')
const mime = require('mime-types')
const _ = require('lodash')
const Deferred = require('deferred')
@ -18,11 +15,10 @@ const fs = require('fs') @@ -18,11 +15,10 @@ const fs = require('fs')
const path = require('path')
const Seven = require('node-7z')
if (
!process.env.GITHUB_TOKEN ||
!process.env.S3_ACCESS_KEY_ID ||
!process.env.S3_SECRET_ACCESS_KEY
) {
const GITHUB_ORG = 'dreamnettech'
const GITHUB_REPO = 'dreamtime'
if (!process.env.GITHUB_TOKEN) {
console.log('API keys not found!')
process.exit(0)
}
@ -31,24 +27,6 @@ const octokit = new Octokit({ @@ -31,24 +27,6 @@ const octokit = new Octokit({
auth: process.env.GITHUB_TOKEN
})
const S3Client = new AWS.S3({
accessKeyId: process.env.S3_ACCESS_KEY_ID,
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
endpoint: 'https://sfo2.digitaloceanspaces.com'
})
function getOS() {
if (process.platform === 'win32') {
return 'windows'
}
if (process.platform === 'darwin') {
return 'macos'
}
return 'ubuntu'
}
const isTagRelease = _.startsWith(process.env.GITHUB_REF, 'refs/tags')
const tagName = isTagRelease
@ -56,30 +34,19 @@ const tagName = isTagRelease @@ -56,30 +34,19 @@ const tagName = isTagRelease
: _.truncate(process.env.GITHUB_SHA, { length: 7, omission: '' })
const version = tagName
const fileName = `DreamPower-${version}-${getOS()}-${
process.env.BUILD_DEVICE
}.7z`
const fileName = `DreamPower-${version}-${process.env.BUILD_OS}-${process.env.BUILD_PLATFORM}.7z`
const buildPath = path.resolve(__dirname, '../dist/dreampower')
const filePath = path.resolve(__dirname, '../', fileName)
/*
console.log({
tagName,
fileName,
buildPath,
filePath
})
*/
async function getGithubReleaseUrl() {
let response
try {
response = await octokit.repos.getReleaseByTag({
owner: 'private-dreamnet',
repo: 'dreampower',
tag: tagName
owner: GITHUB_ORG,
repo: GITHUB_REPO,
tag: tagName,
})
} catch (err) {
if (err.status !== 404) {
@ -90,44 +57,25 @@ async function getGithubReleaseUrl() { @@ -90,44 +57,25 @@ async function getGithubReleaseUrl() {
try {
response = await octokit.repos.createRelease({
owner: 'private-dreamnet',
repo: 'dreampower',
owner: GITHUB_ORG,
repo: GITHUB_REPO,
tag_name: tagName,
name: version,
prerelease: true,
draft: false
draft: false,
})
} catch (err) {
console.log(err)
throw err
console.warn(err)
console.log('Retrying...')
// eslint-disable-next-line no-return-await
return await getGithubReleaseUrl()
}
}
return response.data.upload_url
}
function uploadToS3(filePath, fileName) {
const deferred = new Deferred()
S3Client.upload(
{
Bucket: 'dreamnet-cdn',
Key: `releases/dreampower/${tagName}/${fileName}`,
Body: fs.createReadStream(filePath)
},
(err, response) => {
if (err) {
deferred.reject(err)
return
}
deferred.resolve(response)
}
)
return deferred.promise
}
async function uploadToGithub(filePath, fileName) {
const stats = fs.statSync(filePath)
const url = await getGithubReleaseUrl()
@ -154,30 +102,28 @@ async function upload(filePath, fileName) { @@ -154,30 +102,28 @@ async function upload(filePath, fileName) {
console.log('Github say: ', response)
}
console.log(`Uploading ${fileName} to S3...`)
response = await uploadToS3(filePath, fileName)
console.log('S3 say:', response)
// TODO: Upload to DreamLink
}
function zip() {
console.log('Compressing build...')
process.chdir(buildPath)
const deferred = new Deferred()
const def = new Deferred()
const sevenProcess = Seven.add(filePath, '*', {
recursive: true
})
sevenProcess.on('error', (err) => {
deferred.reject(err)
def.reject(err)
})
sevenProcess.on('end', (info) => {
deferred.resolve()
def.resolve()
})
return deferred.promise
return def.promise
}
async function main() {

40
transform/opencv/resize.py

@ -18,10 +18,10 @@ class ImageToCrop(ImageTransformOpenCV): @@ -18,10 +18,10 @@ class ImageToCrop(ImageTransformOpenCV):
:param args: <dict> args parameter to run the image transformation (default use Conf.args)
"""
super().__init__(input_index=input_index)
self.__x1 = self._args['overlay'][0]
self.__y1 = self._args['overlay'][1]
self.__x2 = self._args['overlay'][2]
self.__y2 = self._args['overlay'][3]
self.__x1 = Conf.args['overlay'][0]
self.__y1 = Conf.args['overlay'][1]
self.__x2 = Conf.args['overlay'][2]
self.__y2 = Conf.args['overlay'][3]
def _execute(self, *args):
"""
@ -49,6 +49,10 @@ class ImageToOverlay(ImageToCrop): @@ -49,6 +49,10 @@ class ImageToOverlay(ImageToCrop):
:param args: <dict> args parameter to run the image transformation (default use Conf.args)
"""
super().__init__(input_index=input_index)
self.__x1 = Conf.args['overlay'][0]
self.__y1 = Conf.args['overlay'][1]
self.__x2 = Conf.args['overlay'][2]
self.__y2 = Conf.args['overlay'][3]
def _execute(self, *args):
"""
@ -57,16 +61,8 @@ class ImageToOverlay(ImageToCrop): @@ -57,16 +61,8 @@ class ImageToOverlay(ImageToCrop):
:param args: <[RGB,RGB]] Image to overlay, the overlay
:return: <RGB> image
"""
# Remove white border add by resizing in case of the overlay selection was less than 512x512
if abs(self.__x1 - self.__x2) < 512 or abs(self.__y1 - self.__y2) < 512:
gray = cv2.cvtColor(args[1], cv2.COLOR_BGR2GRAY)
gray = 255 * (gray < 128).astype(np.uint8)
coords = cv2.findNonZero(gray)
x, y, w, h = cv2.boundingRect(coords)
img = args[1][y:y + h, x:x + w]
img = args[1]
img = cv2.resize(img, (abs(self.__x1 - self.__x2), abs(self.__y1 - self.__y2)))
img_to_overlay = args[0][:, :, :3]
img = img[:, :, :3]
img_to_overlay = DressToCorrect.correct_color(args[0], 5)
img_to_overlay[self.__y1:self.__y2, self.__x1:self.__x2] = img[:, :, :3]
@ -102,6 +98,24 @@ class ImageToResized(ImageTransformOpenCV): @@ -102,6 +98,24 @@ class ImageToResized(ImageTransformOpenCV):
class ImageToResizedCrop(ImageToResized):
"""Image -> Resized Crop [OPENCV]."""
@staticmethod
def _calculate_new_size(img):
if (img.shape[1] > img.shape[0]):
ratio = float(img.shape[1] / img.shape[0])
new_height = Conf.desired_size
new_width = int(new_height * ratio)
elif (img.shape[1] < img.shape[0]):
ratio = float(img.shape[0] / img.shape[1])
new_width = Conf.desired_size
new_height = int(new_width * ratio)
else:
new_width = Conf.desired_size
new_height = Conf.desired_size
new_size = (new_height, new_width)
return new_size
@staticmethod
def _make_new_image(img, new_size):
delta_w = new_size[1] - Conf.desired_size

4
utils.py

@ -74,8 +74,8 @@ def check_shape(path, shape=Conf.desired_shape): @@ -74,8 +74,8 @@ def check_shape(path, shape=Conf.desired_shape):
img_shape = imageio.mimread(path)[0][:, :, :3].shape
if img_shape != shape:
Conf.log.error("Image is not 512 x 512, got shape: {}".format(img_shape))
Conf.log.error("You should use one of the rescale options")
Conf.log.error("{} Image is not 512 x 512, got shape: {}".format(path, img_shape))
Conf.log.error("You should use one of the rescale options or manually resize the image")
sys.exit(1)

Loading…
Cancel
Save