Skip to content

Refactor pytorch-related inference logic #119

Description

@lyuzinmaxim

For each refactoring ticket, we need to ensure that all affected scripts and modules continue to function correctly and produce identical results to the pre-refactoring version.
Run both the pre-refactored and refactored versions of the script, then compare their outputs (console logs, generated files, or results) to confirm there are no differences.

This also includes verifying that:

  • Imports, file paths, and output directories are updated consistently across the project.
  • Documentation accurately reflects the new structure and usage.

In this ticket, we need to refactor the pytorch-related inference logic. Please don't touch now onnx inference, pytorch->onnx conversion, and evaluation scripts. The proposed (feel free to suggest) dir structure looks like:

src/
    inference/
        base/
            classifier_inference_base.py
        pytorch/
            resnet_inference.py
            mobilenet_inference.py
        onnx/ # <- we don't touch it in this ticket
        utils/
            <FILE_NAME> # e.g., for _to_pil_image(...) image_conversion.py

  • src/inference/base/classifier_inference_base.py contains only base class
  • src/inference/pytorch/resnet_inference.py and mobilenet_inference.py contain only related classes
  • utils functions needed for all those classes moved to src/inference/utils/, arranged into files based on logic
  • process_images_with_oop(...) moved to src/inference/utils/ and renamed (we don't need to specify the OOP in the name)
  • if needed, move the functions from __main__ block to a separate file in src/inference/utils/

DoD:

  • refactored code working in the same way as previously, all docs updated (if needed)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions