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

Remote Inference using JS #42

Open
shams3049 opened this issue Sep 6, 2021 · 1 comment
Open

Remote Inference using JS #42

shams3049 opened this issue Sep 6, 2021 · 1 comment
Labels
question Further information is requested

Comments

@shams3049
Copy link

❔Question

I am trying to get an inference on an image using hava script in a webapp. however everytime I make the request, the yolov5 serve app shuts down. with the error below, I know I, i am not passing data in the right format, however I am not sure how to fix it, any direction?!

Unexpected exception in main. main_name=main, stack=[
  Traceback (most recent call last):
    File "/usr/local/lib/python3.8/dist-packages/supervisely_lib/function_wrapper.py", line 15, in main_wrapper
      main_func(*args, **kwargs)
    File "/sessions/325348/repo/supervisely/serve/src/sly_serve.py", line 204, in main
      my_app.run(initial_events=[{"command": "preprocess"}])
    File "/usr/local/lib/python3.8/dist-packages/supervisely_lib/app/app_service.py", line 286, in run
      raise self._error
    File "/usr/local/lib/python3.8/dist-packages/supervisely_lib/app/app_service.py", line 191, in handle_message_sync
      self.callbacks[command](api=user_public_api,
    File "/usr/local/lib/python3.8/dist-packages/supervisely_lib/decorators/profile.py", line 11, in wrapper_timer
      value = func(*args, **kwargs)
    File "/sessions/325348/repo/supervisely/serve/src/sly_serve.py", line 113, in inference_image_url
      image_url = state["image_url"]
  TypeError: 'NoneType' object is not subscriptable

Additional context

my ret is formatted as such:

var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
var url = "https://app.supervise.ly/public/api/v3/tasks.request.direct";

var xhr = new XMLHttpRequest();
xhr.open("POST", url);
xhr.setRequestHeader("x-api-key", "key goes here");
xhr.setRequestHeader('Content-Type', 'application/json');

image_url = "https://i.imgur.com/tEkCb69.jpg"

xhr.onreadystatechange = function () {
   if (xhr.readyState === 4) {
      console.log(xhr.status);
      console.log(xhr.responseText);
   }};

const json = {
  "taskId": 325348,
  "command": "inference_image_url",
  "data": {
    "image_id": image_url,
  },
};

xhr.send(JSON.stringify(json));
@shams3049 shams3049 added the question Further information is requested label Sep 6, 2021
@github-actions
Copy link

github-actions bot commented Sep 6, 2021

👋 Hello @shams3049, thank you for your interest in 🚀 YOLOv5! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://www.ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com.

Requirements

Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:

$ pip install -r requirements.txt

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

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

No branches or pull requests

1 participant