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

NotImplementedError #341

Closed
1 task done
xiaolu-luu opened this issue Apr 6, 2024 · 4 comments
Closed
1 task done

NotImplementedError #341

xiaolu-luu opened this issue Apr 6, 2024 · 4 comments
Labels
bug Something isn't working question Further information is requested

Comments

@xiaolu-luu
Copy link

Search before asking

  • I have searched the Inference issues and found no similar feature requests.

Question

When I was running this code (main/examples/sam-client/app.py), this error occurred, what could be the cause? I set --image_path to "./cat.jpg"
Traceback (most recent call last):
File "/home/z/deeplearning/roboflow/test3.py", line 42, in
inference_results = model.infer(image_path)
File "/home/z/anaconda3/envs/inference1/lib/python3.10/site-packages/inference/core/models/base.py", line 23, in infer
preproc_image, returned_metadata = self.preprocess(image, **kwargs)
File "/home/z/anaconda3/envs/inference1/lib/python3.10/site-packages/inference/core/models/base.py", line 35, in preprocess
raise NotImplementedError
NotImplementedError

Additional

No response

@xiaolu-luu xiaolu-luu added the question Further information is requested label Apr 6, 2024
@PawelPeczek-Roboflow
Copy link
Collaborator

Indeed - there is a bug in the example.

Could u tell what you wanted to achieve - we can guide you towards the solution

@PawelPeczek-Roboflow PawelPeczek-Roboflow added the bug Something isn't working label Apr 10, 2024
@xiaolu-luu
Copy link
Author

xiaolu-luu commented Apr 10, 2024

Indeed - there is a bug in the example.

Could u tell what you wanted to achieve - we can guide you towards the solution

Thank you for your prompt response. I am looking to deploy Sam's inference on my local GPU and subsequently execute sequential inference on the images within the designated folder, saving the results.
Looking forward to your reply,thank you very much.

@PawelPeczek-Roboflow
Copy link
Collaborator

Ok, so there are couple of options.

You can run our inference server via command-line tool that we ship in inference or inference-cli libraries (make sure one of them is installed in your env):

inference server start

That should start docker container with our server (you can confirm via docker ps)

Then you can send requests either to embed image or segment it:

import requests

API_KEY = "<YOUR-ROBOFLOW-API-KEY>"   # see https://docs.roboflow.com/api-reference/authentication for help

infer_payload = {
    "image": {
        "type": "url",
        "value": "https://t3.ftcdn.net/jpg/01/73/37/16/360_F_173371622_02A2qGqjhsJ5SWVhUPu0t9O9ezlfvF8l.jpg",   # this is an example image
    },
    "point_coords": [[380, 350]],  # this is example input
    "point_labels": [1],  # this is example input
    "image_id": "example_image_id",  # this is example input - if you use single image multiple times, use uuids for to recognise images - then we will use cache
}

res = requests.post(
    f"http://127.0.0.1:9001/sam/segment_image?api_key={API_KEY}",
    json=infer_payload,
)

masks = res.json()

Alternatively, you can modify example to be something like that:

import cv2
from inference.models import SegmentAnything

YOUR_IMAGE = cv2.imread("<path-to-your-image>")

model = SegmentAnything(api_key="<YOUR-ROBOFLOW-API-KEY>")
inference_results = model.segment_image(
    image=YOUR_IMAGE,
    point_coords=[[380, 350]],
    point_labels=[1],
    image_id="...",
)

# then do whatever you need with prediction

@PawelPeczek-Roboflow
Copy link
Collaborator

PawelPeczek-Roboflow commented Apr 11, 2024

You can find API ref. for the model class here

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

No branches or pull requests

2 participants