Code Monkey home page Code Monkey logo

tonquer / waifu2x-vulkan Goto Github PK

View Code? Open in Web Editor NEW
47.0 2.0 5.0 43.16 MB

waifu2x-ncnn-vulkan-python, use nihui/waifu2x-ncnn-vulkan

License: MIT License

CMake 0.35% C 34.91% C++ 57.23% Python 0.45% Shell 2.38% PowerShell 0.01% Lua 0.28% Objective-C 0.48% Makefile 0.80% Assembly 0.13% M4 0.11% DIGITAL Command Language 0.20% Dockerfile 0.01% Batchfile 0.02% Roff 1.49% Awk 0.23% Module Management System 0.02% SAS 0.01% Ada 0.48% Pascal 0.40%
waifu2x-ncnn-vulkan waifu2x vulkan python waifu2x-ncnn-vulkan-python waifu2x-vulkan

waifu2x-vulkan's Introduction

waifu2x-ncnn-vulkan-python

  • This is modified waifu2x-ncnn-vulkan, Export pyd and so files to Python
  • Support Linux, Windows, MacOs
  • Support import JPG, PNG, BMP, GIF, WEBP, Animated WEBP, APNG
  • Support export JPG, PNG, BMP, WEBP, Animated WEBP, APNG

Install

pip install waifu2x-vulkan -v

Use

from waifu2x_vulkan import waifu2x_vulkan

# init
waifu2x_vulkan.setDebug(True)
sts = waifu2x_vulkan.init()
if sts < 0:
    # cpu model
    isCpuModel = True
gpuList = waifu2x_vulkan.getGpuInfo()
print(gpuList)
sts = waifu2x_vulkan.initSet(gpuId=0, threadNum=2)
assert sts==0

# add picture ...
# waifu2x.add(...)

# load picture...
# newData, status, backId, tick = waifu2x.load(0)

Example

Build

pip install wheel
python setup.py bdist_wheel

waifu2x-vulkan's People

Contributors

nihui avatar tonquer avatar z-fly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

waifu2x-vulkan's Issues

Segfault on 16-bit image

I am consistently getting a segfault (in src/stb_image.h) when trying to run on images with a 16 bit image depth. Below is the simple test script that I use to show the behavior with an example image.
test2

from waifu2x_vulkan import waifu2x_vulkan as waifu2x
sts = waifu2x.init()
sts = waifu2x.initSet(0)
fileIn = "/home/gin/Pictures/test2.png"

f = open(fileIn, "rb")
data = f.read()
f.close()
waifu2x.add(data, waifu2x.MODEL_ANIME_STYLE_ART_RGB_NOISE3, 1, 2)

Since the code segfaults in the cpython library, I ran with gdb to get a backtrace:

Thread 4 "python3" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe76bc6c0 (LWP 21377)]
stbi__convert_16_to_8 (channels=4, h=<optimized out>, w=<optimized out>, orig=0x0) at src/stb_image.h:1140
1140    src/stb_image.h: No such file or directory.
(gdb) bt
#0  stbi__convert_16_to_8 (channels=4, h=<optimized out>, w=<optimized out>, orig=0x0) at src/stb_image.h:1140
#1  stbi_xload (v=...) at src/other_image.h:174
#2  0x00007ffff631863b in to_load (v=...) at src/other_image.h:232
#3  0x00007ffff6318c36 in waifu2x_decode (args=<optimized out>) at src/waifu2x_main.cpp:70
#4  0x00007ffff789ebb5 in ?? () from /usr/lib/libc.so.6
#5  0x00007ffff7920d90 in ?? () from /usr/lib/libc.so.6

The issue appears to be localized to the stbi__convert_16_to_8 function. If I convert the image to 8-bit first (using PIL) then waifu2x does not segfault, leading me to think it's isolated to 16-bit images.

编译报错

❯ python setup.py bdist_wheel
linux
Traceback (most recent call last):
  File "/home/ploki/Program/waifu2x-vulkan/setup.py", line 111, in <module>
    if 'arm64' in platform.platform or 'aarch64' in platform.platform:
TypeError: argument of type 'function' is not iterable

Linux 下 Python 解释器没有立即退出

问题

我在 Ubuntu 下调试时, 执行 exit() 之后 Python 解释器 (进程) 没有立即退出.
跑示例脚本 test.py 的时候也会遇到同样的问题. (于是现在最简单的退出方式可能是 ^c / ^d)..

感觉这个行为就像是仍有一个或者多个线程没有退出所导致的..
但是貌似在其他平台上 (Windows, macOS) 不能复现..

复现过程

import waifu2x
waifu2x.init()
waifu2x.initSet(0, xxx)
exit()
1.mov

如何在Linux Arm64上编译

  src/waifu2x_py.cpp:46:16: note: ‘sprintf’ output between 5 and 260 bytes into a destination of size 256
     46 |         sprintf(modelNameTTa, "%s_TTA", modelName);
        |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  aarch64-linux-gnu-g++ -shared -Wl,-O1 -Wl,-Bsymbolic-functions -g -fwrapv -O2 build/temp.linux-aarch64-cpython-311/src/waifu2x.o build/temp.linux-aarch64-cpython-311/src/waifu2x_main.o build/temp.linux-aarch64-cpython-311/src/waifu2x_py.o build/temp//ncnntmp/src/libncnn.a build/temp//webptmp/libwebp.a build/temp//webptmp/libwebpmux.a build/temp//webptmp/libwebpdemux.a build/temp//pngtmp/libpng.a build/temp//pngtmp/zlib/libz.a VulkanSDK/linux/libvulkan.so build/temp//ncnntmp/glslang/SPIRV/libSPIRV.a build/temp//ncnntmp/glslang/glslang/libglslang.a build/temp//ncnntmp/glslang/glslang/libMachineIndependent.a build/temp//ncnntmp/glslang/OGLCompilersDLL/libOGLCompiler.a build/temp//ncnntmp/glslang/glslang/OSDependent/Unix/libOSDependent.a build/temp//ncnntmp/glslang/glslang/libGenericCodeGen.a -L/usr/lib/aarch64-linux-gnu -lgomp -o build/lib.linux-aarch64-cpython-311/waifu2x_vulkan/waifu2x_vulkan.cpython-311-aarch64-linux-gnu.so -fopenmp
  /usr/bin/ld: VulkanSDK/linux/libvulkan.so: error adding symbols: file in wrong format
  collect2: error: ld returned 1 exit status
  error: command '/usr/bin/aarch64-linux-gnu-g++' failed with exit code 1
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for waifu2x-vulkan
Failed to build waifu2x-vulkan

编译 macOS 版本

我尝试了在 mac 上编译本项目( Here ),
能跑 demo(虽然是用 CPU,但是理论上如果设备有 AMD 独显的话就能用 GPU 跑)
image
image

毕竟原项目( https://github.com/nihui/waifu2x-ncnn-vulkan ) 就是可以在 mac 上面运行的嘛,
但是....
image

于是目前核显好像就只能用 CPU 跑了...qwq(速度慢的1p )
(另外没有编译 ARM64 的,因为懒以及我没有 ARM Mac(逃

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.