Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use in python #1

Open
Johnreidsilver opened this issue Feb 14, 2021 · 1 comment
Open

how to use in python #1

Johnreidsilver opened this issue Feb 14, 2021 · 1 comment

Comments

@Johnreidsilver
Copy link

This is very cool, I always wanted to use "CUDA only" software in other hardware like though Vulkan.

I've installed Tencent's ncnn for python (had to clone and compile, pip couldn't find ncnn wheel) but have no idea how to adapt the transformations in your C code example for python

`
import sys
import cv2
import numpy as np
import ncnn

net = ncnn.Net()
#net.opt.use_vulkan_compute = net.use_gpu

net.load_param("deoldify.256.param")
net.load_model("deoldify.256.bin")

path = 'image.png'
input=cv2.imread(path,cv2.IMREAD_GRAYSCALE)

mat_in = ncnn.Mat.from_pixels_resize(input,ncnn.Mat.PixelType.PIXEL_BGR2RGB,input.shape[1],input.shape[0],256,256)

ex = net.create_extractor()
ex.input("input",mat_in)
mat_out = ncnn.Mat()

ret, mat_out = ex.extract("out")
`

after this I'm unsure about the transformations needed to write a valid image

@KeepGoing2019HaHa
Copy link
Owner

I am not familiar with ncnn Python API. You may need to find out the matrix layout in Python ncnn and reconstruct it to opencv array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants