question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Save requesting image to local and return a resultant image with bounding box?

See original GitHub issue

🚀 The feature

By requesting curl http://192.168.1.100:8080/predictions/alexnet -T ./serve/examples/image_classifier/kitten.jpg,

Wondering if there is an option to:

  • save the uploaded kitten.jpg to a local folder on http://192.168.1.100 ??
  • return an image with bounding box to the requesting web browser ?

Motivation, pitch

As described in The feature, the motivation is quite obvious.

Alternatives

N/A

Additional context

N/A

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
agunapalcommented, Jun 28, 2022

@TillmannRheude The following code worked for me with the AlexNet example. I modified the inference code to return a tuple of the inference result and input image We can unpack the data in the postprocess method and do the necessary post processing operation on the image and save it

` def inference(self, data, *args, **kwargs): marshalled_data = data.to(self.device) with torch.no_grad(): results = self.model(marshalled_data, *args, **kwargs) return (results, data)

def postprocess(self, data):
    data, inp_img = data[0], data[1][0]
    
    ps = F.softmax(data, dim=1)
    probs, classes = torch.topk(ps, self.topk, dim=1)
    probs = probs.tolist()
    classes = classes.tolist()

    # post process the image
    op_image = inp_img

    # save image to file
    save_image(op_image, "/home/ubuntu/op_img1.png")
    
    return map_class_to_label(probs, self.mapping, classes)

`

Please let us know if this answers your question

1reaction
TillmannRheudecommented, Jun 28, 2022

Thank ya @agunapal, it worked like a charm - My fault was not to define “/home/…” in front of the path for the image.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Extract bounding box and save it as an image - Stack Overflow
this returns cropped image (bounding box). in this aproach, bounding box coordinates bases on pascal-voc annotation formats like here.
Read more >
Mis-aligned bounding boxes in test_batch_labels · Issue #1782
The labels we generate are plotting a bounding box such as this: image. We save our bounding-box coordinates in the label-txt files, ...
Read more >
front end - How to save a bounding box on an image?
enter image description here. Click Cancel in the Selection Tools dialog, but leave the image itself selected: enter image description here.
Read more >
Displaying bounding boxes - Amazon Rekognition
Amazon Rekognition Image operations can return bounding boxes coordinates for items that are detected in images. For example, the DetectFaces operation ...
Read more >
image — CASAdocs documentation - Read the Docs
This function finds the bounding box of a region of interest when it is applied to a particular image. Both float and complex...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found