chigozienri / VQGAN-CLIP-animations

133 stars 28 forks source link

Import Error: ---> 26 from taming.models import cond_transformer, vqgan #24

Closed tim-andes closed 2 years ago

tim-andes commented 2 years ago

Describe the bug

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-8-dbaa526c00d0> in <module>()
     24 from omegaconf import OmegaConf
     25 from PIL import Image
---> 26 from taming.models import cond_transformer, vqgan
     27 import torch
     28 from torch import nn, optim

3 frames
/content/taming-transformers/taming/data/helper_types.py in <module>()
----> 1 from typing import Dict, Tuple, Literal, Optional, NamedTuple, Union
      2 
      3 from PIL.Image import Image as pil_image
      4 from torch import Tensor
      5 

ImportError: cannot import name 'Literal' from 'typing' (/usr/lib/python3.7/typing.py)

Parameters used Did not get to parameters

Which cell you saw the error in "# @title Loading of libraries and definitions"

Error message See above

JuanPabloEs commented 2 years ago

Hi, I had the same error and this solution works for me. https://github.com/python/typing/issues/707 I'm sure it's not the best solution so... If someone knows something better please help us.

chigozienri commented 2 years ago

Thanks for the report. The issue was in a dependency, and has been fixed upstream (https://github.com/CompVis/taming-transformers/commit/37afdf35f0bdd30a8b95ebc9a4fc4bd6bc1e8c03) - if you restart and try again, it should work now.

AparnaLiza commented 1 year ago

Hi, so it is getting quite difficult to find the solution for the error.

The code is not installing the taming models

below is the error code and then the source code -

38

ModuleNotFoundError                       Traceback (most recent call last)
[<ipython-input-12-c026441db553>](https://localhost:8080/#) in <cell line: 13>()
     11 from omegaconf import OmegaConf
     12 from PIL import Image
---> 13 from taming.models import cond_transformer, vqgan
     14 import torch
     15 from torch import nn, optim

2 frames
[/content/./taming-transformers/taming/data/utils.py](https://localhost:8080/#) in <module>
      9 import torch
     10 from taming.data.helper_types import Annotation
---> 11 from torch._six import string_classes
     12 from torch.utils.data._utils.collate import np_str_obj_array_pattern, default_collate_err_msg_format
     13 from tqdm import tqdm

ModuleNotFoundError: No module named 'torch._six'

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.


import argparse
import math
from pathlib import Path
import sys

sys.path.append('./taming-transformers')
from IPython import display
from base64 import b64encode
from omegaconf import OmegaConf
from PIL import Image
from taming.models import cond_transformer, vqgan
import torch
from torch import nn, optim
from torch.nn import functional as F
from torchvision import transforms
from torchvision.transforms import functional as TF
from tqdm.notebook import tqdm

from CLIP import clip
import kornia.augmentation as K
import numpy as np
import imageio
from PIL import ImageFile, Image
from imgtag import ImgTag    # metadatos
from libxmp import *         # metadatos
import libxmp                # metadatos
from stegano import lsb
import json
ImageFile.LOAD_TRUNCATED_IMAGES = True```