Coder Social home page Coder Social logo

yolox-inference's Introduction

YOLOX-Inference

A simple script of using YOLOX model just for inference.

I kept only necessary code to do inference in yolox.py.

To load a pretrained model and do inference:

from yolox import create_yolox_model, load_image
import torch

conf_threshold = 0.25
nms_threshold = 0.45

model = create_yolox_model("yolox-s", "yolox_s.pth", conf_threshold, nms_threshold)
print("yolox model loaded.")

inp, ratio = load_image("xzl.jpg")

with torch.no_grad():
    outputs = model(inp).cpu()
    # Detections ordered as (x1, y1, x2, y2, obj_conf, class_conf, class_pred)
    bboxes = outputs[:, 0:4]
    bboxes /= ratio
    cls_idxes = outputs[:, 6]
    scores = outputs[:, 4] * outputs[:, 5]
    for bbox, cls_idx, score in zip(bboxes, cls_idxes, scores):
        print(f"class={cls_idx}, conf={score}, bbox={bbox}")

Terminla Outputs

yolox model loaded.
class=0.0, conf=0.4121667146682739, bbox=tensor([1175.3997,  325.5804, 1246.6086,  473.2525])
class=33.0, conf=0.37325724959373474, bbox=tensor([466.2440, 819.2187, 508.7644, 896.0631])
class=6.0, conf=0.2587979733943939, bbox=tensor([   8.5561,    5.7042, 1976.1226, 1082.2935])

yolox-inference's People

Contributors

fatescript avatar joker316701882 avatar goatmessi7 avatar developer0hye avatar yuanmu97 avatar ankandrew avatar wwqgtxx avatar zhiqwang avatar nihui avatar haolongzhangm avatar f0xzz avatar armaxik avatar yancie-yjr avatar deftruth avatar rangilyu avatar jario-jin avatar r-b-g-b avatar swhl avatar tonysy avatar stephanxu avatar waynemao avatar woowonjin avatar xxr3376 avatar yulv-git avatar amazingzby avatar futabato avatar robin-maillot avatar shachargluska avatar cmdbug avatar wico-silva avatar

Stargazers

 avatar

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.