GithubHelp home page GithubHelp logo

roboflow / roboflow-computer-vision-utilities Goto Github PK

View Code? Open in Web Editor NEW
35.0 9.0 7.0 4.94 MB

Interface with the Roboflow API and Python package for running inference (receiving predictions) and customizing result images from your Roboflow Train computer vision models.

License: Apache License 2.0

Python 80.13% Jupyter Notebook 19.87%

roboflow-computer-vision-utilities's People

Contributors

mo-traor3-ai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

roboflow-computer-vision-utilities's Issues

Problem with object counting

Hi, I'm trying to make an object counter with a yolo v8 model that I trained localy but when I try to adapt your code I get this error: IndexError: too many indices for tensor of dimension 2, on this line of code: if prediction['class'] in target_classes: inside the count_objects function.

Here is my code:

def count_objects(predictions, target_classes):
    """
    Helper method to count the number of objects in an image for a given class
    :param predictions: predictions returned from calling the predict method
    :param target_class: str, target class for object count
    :return: dictionary with target class and total count of occurrences in image
    """
    object_counts = {x:0 for x in target_classes}
    for prediction in predictions:
        if prediction['class'] in target_classes:
            object_counts[prediction['class']] += 1
        elif prediction['class'] not in target_classes:
            object_counts[prediction['class']] = 1

    present_objects = object_counts.copy()

    for i in object_counts:
        if object_counts[i] < 1:
            present_objects.pop(i)

    return present_objects

predictions = model.predict(source = "folderImages", conf = 0.6)
class_counts= count_objects(predictions, model.names)

print('/n', "Class Counts:", '/n')
print(class_counts)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.