onnx / onnx/models

Super resolution model test

Open
#386 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Jupyter Notebook
Stars
9.8k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

The following code was used in testing super resolution model.

orig_img = Image.open("midge_header_2.jpg")
img = resizeimage.resize_cover(orig_img, [224,224], validate=False)
img_ycbcr = img.convert('YCbCr')
img_y_0, img_cb, img_cr = img_ycbcr.split()
img_ndarray = np.asarray(img_y_0)

img_4 = np.expand_dims(np.expand_dims(img_ndarray, axis=0), axis=0)
img_5 = img_4.astype(np.float32) / 255.0


ort_session = onnxruntime.InferenceSession("model/super-resolution-10/super_resolution/super_resolution.onnx")
ort_inputs = {ort_session.get_inputs()[0].name: img_5} 
ort_outs = ort_session.run(None, ort_inputs)
img_out_y = ort_outs[0]

img_out_y = Image.fromarray(np.uint8((img_out_y[0] * 255.0).clip(0, 255)[0]), mode='L')
# get the output image follow post-processing step from PyTorch implementation
final_img = Image.merge(
    "YCbCr", [
        img_out_y,
        img_cb.resize(img_out_y.size, Image.BICUBIC),
        img_cr.resize(img_out_y.size, Image.BICUBIC),
    ]).convert("RGB")
#plt.imshow(final_img)
plt.figure(figsize=(20, 10))

images = [orig_img, final_img]
titles = ['LR', f'SR (x{final_img.size[0] // orig_img.size[0]})']

for i, (img, title) in enumerate(zip(images, titles)):
   plt.subplot(1, 2, i+1)
   plt.imshow(img)
   plt.title(title)
   plt.xticks([])
   plt.yticks([])
plt.savefig('sample_detection.png', bbox_inches='tight')

Not very sure what parameter to modify.
But the output image was not full image as original and resolution is not good. The output image is blur.
What could be the problem?

You can see input and output image here

The test image to test is here.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided Python code with midge_header_2.jpg and the model at model/super-resolution-10/super_resolution/super_resolution.onnx. Compare the generated sample_detection.png with the linked input and output, focusing on the resize, YCbCr conversion, model input, and output post-processing. Done means identifying the parameter or processing step responsible for the cropped or blurred result.

Written by the indexing model from the issue text.

Assessment

Tech stack
matplotlib, numpy, python
Domain
computer-vision, machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.