Coder Social home page Coder Social logo

marvin-desmond / yolov4-yolov5-inference Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 484 KB

A repo for inference pipeline implementations of YOLOv4 Darknet and YOLOv5 PyTorch by AlexeyAB (took over from Joseph Redmon) and Ultralytics respectively

Python 100.00%

yolov4-yolov5-inference's Introduction

Hi there! πŸ‘‹


YOLOv412 darknet YOLOv53 πŸš€

This repo contains the inference pipelines for both AlexeyAB YOLO Darknet model and Ultralytics YOLO PyTorch model.

Concepts that have been illustrated include:

  • Loading the models and the configurations
  • Preprocessing pipelines for the models
  • Inference of the images
  • Post-processing
    • Non max suppression
    • Bounding box coordinates conversion
  • Showing detections on image
  • Visualize image

πŸ“Œ NB: During PyTorch serialization, the pickling tends to reference the Layer modules during torch.load, why so?

torch.save basically only calls torch._save Inside this function there is a function named persistent_id defined and beside other things the return values of this function are pickled.

For torch.nn.Module this function does the following:

if  isinstance(obj, type) and  issubclass(obj, nn.Module): 
	if obj in serialized_container_types: 
		return  None 
	serialized_container_types[obj] = True 
	source_file = source = None  
	try: 
		source_file = inspect.getsourcefile(obj) 
		source = inspect.getsource(obj) 
	except Exception: 
		# saving the source is optional, 
		# so we can ignore any errors 
		warnings.warn("Couldn't retrieve source code for container of "  
		"type " + obj.__name__ + ". It won't be checked "  
		"for correctness upon loading.") 
	return ('module', obj, source_file, source)

Which means the source code and the source file are pickled to. This results in the fact, that your source file will be parsed again during loading (and compared to the pickled source code to generate warnings if necessary). This source file is then used for model creation if the changes can be merged automatically. And thus adding new methods is valid as long as you don’t change the existing ones in a way that prevents python from merging automatically.

PyTorch forums Question about serialization while saving models in PyTorch

Hence, the files yolo.py and common.py cannot be deleted since serialization uses them during torch.load

linkedin github

Footnotes

  1. YOLOv4 model zoo ↩

  2. πŸ‘‰ YOLOv4 Interesting Article by Jonathan Hui ↩

  3. YOLOv5 model zoo ↩

yolov4-yolov5-inference's People

Watchers

James Cloos avatar  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.