Files
TashaSkyUp-EternalKernelPyt…/tests/test_torchvision_nodes.py
T
Tasha Upchurch d2d16cadfe Enhanced PyTorch Functionalities and Server Endpoints; Introduced Torchvision and Hugging Face Diffusers Integration
This commit introduces significant enhancements and new features across multiple files in the project. Major changes include:

1. `pytorch_nodes.py`: Expanded PyTorch node functionalities with additional imports, device compatibility checks, optimizer state updates, and training enhancements. Introduced new methods like `optimizer_to` for transferring optimizer state to a specified device, `reset_optimizer_weights` to clear optimizer states, and `make_image_tensor` for converting outputs to image tensors. Also, improved the training process with device compatibility checks, optimizer updates, and the ability to save and load models during training for efficiency.

2. `server_endpoints.py`: Modified server endpoints for improved git integration and user management. Adjustments include dynamic handling of different git repositories, refined branch and user management in GitIO class, and the integration of user-specific git settings in user management functions.

3. `config.yaml`: Added new configurations for temporary directory and git repositories, providing more flexibility and control over file management and version control integration.

4. `torchvision_nodes.py`: Introduced a new file to integrate torchvision functionalities. It includes classes for transform composition, application of torchvision transforms, and handling of torchvision-specific data structures.

5. `hf_diffusers_nodes.py`: Integrated Hugging Face's diffusers library with new nodes for loading and utilizing DDPMPipelines, handling tensor to image conversions, and managing datasets from the Hugging Face ecosystem.

6. `image.py`, `video.py`, `functional.py`: Refactored and enhanced existing functionalities. Included minor tweaks and bug fixes to improve the overall efficiency and robustness of image and video processing capabilities.

7. `requirements.txt`: Updated dependencies, replacing `fastnoisesimd` with `diffusers` to align with the newly integrated Hugging Face diffusers functionalities.

8. `config.py`: Improved the configuration file loading mechanism with dynamic path handling and the ability to replace placeholders with actual paths, enhancing the flexibility of configuration management.

This comprehensive update significantly enhances the project's capabilities in machine learning, especially in PyTorch and torchvision, and improves server endpoint functionalities for better user and version control management.
2023-12-27 13:22:48 -05:00

49 lines
1.3 KiB
Python

import pytest
from ..torchvision_nodes import TorchVisionTransformCompositionList
from ..torchvision_nodes import TorchVisionTransformNode
from ..torchvision_nodes import TorchVisionCallComposition
# when testing set "UNIT_TEST" to true in the environment to avoid loading all of ComfyUI
def test_TorchVisionTransformCompositionList():
tvtcl_node = TorchVisionTransformCompositionList()
ret = tvtcl_node.compose("test")
ret = ret[0]
assert ret is not None
def test_TorchVisionTransformNode():
node1 = TorchVisionTransformCompositionList()
node2 = TorchVisionTransformNode()
ret = node1.compose("test")
ret = ret[0]
assert ret is not None
ret = node2.compose(ret,"GaussianBlur","1")
ret = ret[0]
assert ret is not None
def test_TorchVisionCallComposition():
node1 = TorchVisionTransformCompositionList()
node2 = TorchVisionTransformNode()
node3 = TorchVisionCallComposition()
ret = node1.compose("test")
ret = ret[0]
assert ret is not None
ret = node2.compose(ret,"GaussianBlur","1")
ret = ret[0]
assert ret is not None
import torch
test_tensor = torch.rand(1,256,256,3)
ret = node3.compose(ret,test_tensor)
ret = ret[0]
assert ret is not None
if __name__ == "__main__":
pytest.main()