AlexanderLutsenko / nobuco

Pytorch to Keras/Tensorflow/TFLite conversion made intuitive
MIT License
272 stars 17 forks source link

color traceback on error messages / upgraded progressbar #64

Open johndpope opened 1 month ago

johndpope commented 1 month ago

this is commented out - console.print_exception(show_locals=True) - but it will show the tensors in question like this

Screenshot 2024-10-17 at 12 39 00 PM

otherwise - by default will just show shorter message in color

Screenshot 2024-10-17 at 12 40 53 PM
johndpope commented 1 month ago

i tweak the convert.py Screenshot from 2024-10-17 16-50-09

updated progressbar Screenshot from 2024-10-17 17-02-08

should be able to test using pip install git+https://github.com/johndpope/nobuco

AlexanderLutsenko commented 1 month ago

Hi, thanks! Such a beauty. It works incorrectly on my machine, though (Linux Ubuntu). No traceback is shown:

Screenshot from 2024-10-25 15-40-27

Any idea how to make it work consistently?

johndpope commented 1 month ago

Im on ubuntu 22.04 too - you can use oh-my-zsh to make terminal look nicer https://ohmyz.sh/ (it's going to upgrade things to use .zsh - this is the default .zshrc - what mac uses )

with rich you can add to any python program

from rich.console import Console
from rich.traceback import install
console = Console(width=3000)
# Install Rich traceback handling
install(show_locals=True) # will show the variables - too much info.
#install()rich                                     13.4.2

i did upgrade the progressbar - which looked great - but had too many problems losing context of ops count.

my version is

pip install rich==13.4.2

if that doesn't fix it - let me know i dig deeper.

I think because the graph is long - traceback for each validation error in node i suppress.

https://github.com/AlexanderLutsenko/nobuco/pull/64/files#diff-bf6a5d8902723cc0540aedc6d797482b742eaefc68121d5e36f53d54435281a1L62

       warnings.warn(f"Validation exception on node '{op_type.__name__}': {e}")
        # Use rich to print the traceback in color
        from rich.traceback import Traceback
        tb = Traceback()
        rprint(tb)

try converting a torch file fully - i have problematic one google checkpoint saved uploaded on this ticket https://github.com/google-ai-edge/ai-edge-torch/issues/305 google checkpoint saved https://drive.google.com/file/d/15MvTEkWAnhtSCcbeDUcJ2DCPyj6nNMbd/view?usp=drive_link