Comments (3)
Successfully exported to onnx and can be inference
model = TED().to(device)
model.load_state_dict(torch.load('checkpoints/BIPED/7/7_model.pth',
map_location=device))
img_height = 352
img_width = 352
batch_size = 8
dummy_input = torch.rand(batch_size, 3, img_height, img_width)
params = {
0 : 'batch_size',
2 : 'image_height',
3 : 'image_width',
}
dynamic_axes_dict = {
'input': params,
'out_1': params,
'out_2': params,
'out_3': params,
'block_cat': params,
}
onnx_program = torch.onnx.export(model,
dummy_input,
"teed.onnx",
dynamic_axes=dynamic_axes_dict,
output_names=['out_1', 'out_2', 'out_3', 'block_cat'],
input_names=['input'])
def sigmoid(z):
return 1/(1 + np.exp(-z))
ort_session = ort.InferenceSession("teed.onnx")
image_path = 'test.jpg'
device = "cuda" if torch.cuda.is_available() else "cpu"
image = cv2.imread(image_path, cv2.IMREAD_COLOR)
i_h, i_w, _ = image.shape
image = cv2.resize(image, None, fx=0.3, fy= 0.3, interpolation=cv2.INTER_LINEAR)
img_width = ((image.shape[1] // 16) + 1) * 16
img_height = ((image.shape[0] // 16) + 1) * 16
image = cv2.resize(image, (img_width, img_height))
image = np.array(image, dtype=np.float32)
image = image.transpose((2, 0, 1))
image = image[np.newaxis, :]
start_time = time.time()
outputs = ort_session.run(
None,
{"input": image},
)
outputs = np.array(outputs)
print("--- %s seconds ---" % (time.time() - start_time))
edge_maps = []
for i in outputs:
tmp = sigmoid(i)
edge_maps.append(tmp)
tensor = np.array(edge_maps)
output = tensor[:, 0, ...]
output = np.squeeze(output)
fuse = output[-1]
fuse = np.uint8(image_normalization(fuse))
fuse = cv2.bitwise_not(fuse)
fuse = cv2.resize(fuse, (i_w, i_h), interpolation=cv2.INTER_LINEAR)
cv2.imwrite('out.png', fuse)
from teed.
I thank for interesting in TEED.
honestly, I do not know, but it is a simple network maybe you can. Please let me know the advance.
Xavier
from teed.
Successfully exported to onnx and can be inference
model = TED().to(device) model.load_state_dict(torch.load('checkpoints/BIPED/7/7_model.pth', map_location=device)) img_height = 352 img_width = 352 batch_size = 8 dummy_input = torch.rand(batch_size, 3, img_height, img_width) params = { 0 : 'batch_size', 2 : 'image_height', 3 : 'image_width', } dynamic_axes_dict = { 'input': params, 'out_1': params, 'out_2': params, 'out_3': params, 'block_cat': params, } onnx_program = torch.onnx.export(model, dummy_input, "teed.onnx", dynamic_axes=dynamic_axes_dict, output_names=['out_1', 'out_2', 'out_3', 'block_cat'], input_names=['input'])def sigmoid(z): return 1/(1 + np.exp(-z)) ort_session = ort.InferenceSession("teed.onnx") image_path = 'test.jpg' device = "cuda" if torch.cuda.is_available() else "cpu" image = cv2.imread(image_path, cv2.IMREAD_COLOR) i_h, i_w, _ = image.shape image = cv2.resize(image, None, fx=0.3, fy= 0.3, interpolation=cv2.INTER_LINEAR) img_width = ((image.shape[1] // 16) + 1) * 16 img_height = ((image.shape[0] // 16) + 1) * 16 image = cv2.resize(image, (img_width, img_height)) image = np.array(image, dtype=np.float32) image = image.transpose((2, 0, 1)) image = image[np.newaxis, :] start_time = time.time() outputs = ort_session.run( None, {"input": image}, ) outputs = np.array(outputs) print("--- %s seconds ---" % (time.time() - start_time)) edge_maps = [] for i in outputs: tmp = sigmoid(i) edge_maps.append(tmp) tensor = np.array(edge_maps) output = tensor[:, 0, ...] output = np.squeeze(output) fuse = output[-1] fuse = np.uint8(image_normalization(fuse)) fuse = cv2.bitwise_not(fuse) fuse = cv2.resize(fuse, (i_w, i_h), interpolation=cv2.INTER_LINEAR) cv2.imwrite('out.png', fuse)
thank you for share it!
from teed.
Related Issues (20)
- this code is not run HOT 3
- import dataset error HOT 9
- Application scenarios for edge images HOT 1
- sizes not match HOT 2
- Evaluation ODS/OIS/AP HOT 1
- Sketch recognition, JPG to MAT file HOT 9
- The setting problem of TEED training parameters HOT 2
- Question about Fmish in DoubleFusion HOT 1
- Why are your edge maps finer HOT 1
- Some problem of training process
- When I run main.py, it tells me that I don't have utils.AF, where should I find that file or the library HOT 1
- What are the meanings of each of the 8 models given in the document? HOT 1
- Can i extract xy coordinates of detected edge? HOT 1
- Hello, have you ever tried to reason with openvino or libtorch?
- Fine-tuning TEED Model with Custom Dataset for Diverse Object Outlines HOT 1
- I found out that the train_pair0.lst file and BIPED don't match. HOT 1
- BIPED datase HOT 2
- evaluation
- evaluation HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from teed.