<jupyter_start><jupyter_text><jupyter_code>!git clone https://github.com/rtolps/Cats2dogs_ONNX
%cd Cats2dogs_ONNX<jupyter_output>Cloning into 'Cats2dogs_ONNX'...
remote: Enumerating objects: 2320, done.[K
remote: Counting objects: 100% (2320/2320), done.[K
remote: Compressing objects: 100% (2309/2309), done.[K
remote: Total 2390 (delta 44), reused 2262 (delta 10), pack-reused 70[K
Receiving objects: 100% (2390/2390), 17.82 MiB | 38.75 MiB/s, done.
Resolving deltas: 100% (67/67), done.
/content/Cats2dogs_ONNX<jupyter_text>Training<jupyter_code>!python main.py --dataset cat2dog  --iteration 100 --light True --save_freq 100 --ch 16<jupyter_output>number of epochs must be larger than or equal to one

##### Information #####
# light :  True
# dataset :  cat2dog
# batch_size :  1
# iteration per epoch :  100

##### Generator #####
# residual blocks :  4

##### Discriminator #####
# discriminator layer :  6

##### Weight #####
# adv_weight :  1
# cycle_weight :  10
# identity_weight :  10
# cam_weight :  1000
training start !
[    1/  100] time: 0.7729 d_loss: 8.24095058, g_loss: 12106.68359375
[    2/  100] time: 1.3152 d_loss: 6.13549423, g_loss: 8334.96289062
[    3/  100] time: 1.8301 d_loss: 5.44864368, g_loss: 12482.91699219
[    4/  100] time: 2.2981 d_loss: 5.56386948, g_loss: 5987.66357422
[    5/  100] time: 2.7835 d_loss: 5.03865814, g_loss: 3981.89550781
[    6/  100] time: 3.2544 d_loss: 4.87487698, g_loss: 2599.95898438
[    7/  100] time: 3.7682 d_loss: 4.47340631, g_loss: 5252.29492188
[    8/  100] time: 4.2997 d_loss: 4.91270828, g_loss: 2053.40771484
[    9/  100] time: 4.8112 d_loss: 5.54815388, g_loss: 2870.768[...]<jupyter_text>Testing<jupyter_code>!python main.py --dataset  cat2dog --iteration 100 --phase test --light True --ch 16<jupyter_output>number of epochs must be larger than or equal to one

##### Information #####
# light :  True
# dataset :  cat2dog
# batch_size :  1
# iteration per epoch :  100

##### Generator #####
# residual blocks :  4

##### Discriminator #####
# discriminator layer :  6

##### Weight #####
# adv_weight :  1
# cycle_weight :  10
# identity_weight :  10
# cam_weight :  1000
 [*] Load SUCCESS
 [*] Test finished!<jupyter_text>**WARNING PART BELOW NOT WORKING!**

Export ONNX  call a custom script (modifiedmain.py probably) where "test" feature is turned into export feature. I added code (which is commented) at the bottom of the UGATIT script to return out genA2B for exporting per [this Snapchat Guide.](https://lensstudio.snapchat.com/guides/machine-learning/ml-frameworks/export-from-pytorch/) Extra info about training the model as 0,255 instead: https://discuss.pytorch.org/t/how-to-change-torchvision-model-input-range-from-0-1-to-0-256/58511/3

Also check out "result.clamp(min=0, max=255)" mentioned in https://pytorch.org/docs/stable/nn.functional.html<jupyter_code>#check python version
!python -V
#check Cuda version
!nvcc --version
#check pytorch version
import torch
print(torch.__version__)<jupyter_output><empty_output><jupyter_text>This explains no attribute dim error: https://discuss.pytorch.org/t/function-object-has-no-attribute-dim/61199/2 Trying to do this from YouTube Tutorial: https://www.youtube.com/watch?v=7nutT3Aacyw Issue exporting torch.var() fix right here. Basically it outputs the variance but instead you could use a function to ouput the standard deviation with an exponent of 2 (which is the equation to get variance in statistics anyways):
https://github.com/onnx/tutorials/issues/125

Here's how torch.var works: https://pytorch.org/docs/stable/generated/torch.var.htmltorch.var

Here's how torch.std works:
https://pytorch.org/docs/stable/generated/torch.std.htmltorch.std

Issue with nn code (torch.var function is used with list instead of int) also here related to that section with torch.var():
https://github.com/znxlwm/UGATIT-pytorch/issues/38

I fixed both of these issues above. IT SUCCESFULLY EXPORTS ONNX FILE!

This branch might be better!
https://github.com/Lornatang/UGATIT-PyTorch<jupyter_code>!python convert_to_onnx.py<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1295754026354319, 'fraction_numerical': 0.10224499755978526, 'mean_word_length': 4.421957671957672, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 11, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '279474', 'license': 'MIT', 'n_tokens_mistral': 1745, 'n_tokens_neox': 1495, 'n_words': 406, 'path': 'WorkingCatsToDogsPytorch.ipynb', 'repo_name': 'rtolps/Cats2dogs_ONNX', 'size': '4098'}