bcmi / libcom

Image composition toolbox: everything you want to know about image composition or object insertion
Apache License 2.0
276 stars 18 forks source link

ModuleNotFoundError error for trilinear package #4

Closed anoubhav closed 10 months ago

anoubhav commented 10 months ago

On importing ImageHarmonizationModel, I get the ModuleNotFoundError error for trilinear package. Also I am not able to pip install the trilinear package. It says the following: pip install trilinear ERROR: Could not find a version that satisfies the requirement trilinear ERROR: No matching distribution found for trilinear

from libcom import ImageHarmonizationModel
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[10], line 1
----> 1 from libcom import ImageHarmonizationModel

File ~/anoubhav/image_editing/libcom/libcom/__init__.py:6
      4 from .harmony_score import *
      5 from .inharmonious_region_localization import *
----> 6 from .image_harmonization import *
      7 from .painterly_image_harmonization import *
      8 from .fopa_heat_map import *

File ~/anoubhav/image_editing/libcom/libcom/image_harmonization/__init__.py:2
      1 # change to your lib name
----> 2 from .image_harmonization import ImageHarmonizationModel
      4 __all__ = ['ImageHarmonizationModel']

File ~/anoubhav/image_editing/libcom/libcom/image_harmonization/image_harmonization.py:8
      6 import os
      7 import torchvision.transforms as transforms
----> 8 from .source.pct_net import *
      9 from .source.cdt_net import *
     11 cur_dir   = os.path.dirname(os.path.abspath(__file__))

File ~/anoubhav/image_editing/libcom/libcom/image_harmonization/source/pct_net.py:6
      3 import torch.nn.functional as F
      4 from functools import partial
----> 6 from .functions import PCT, ViT_Harmonizer
      9 class PCTNet(nn.Module):
     11     def __init__(
     12         self,
     13         backbone_type='ViT', 
   (...)
     16         clamp=True, color_space = 'RGB', use_attn = False
     17     ):

File ~/anoubhav/image_editing/libcom/libcom/image_harmonization/source/functions.py:11
      9 from functools import partial
     10 import os
---> 11 import trilinear
     16 class Bottleneck(torch.nn.Module):
     17     expansion = 1 

ModuleNotFoundError: No module named 'trilinear'
bo-zhang-cs commented 10 months ago

This trilinear library should be installed from source code by running the following commands:

cd libcom/image_harmonization/source/trilinear_cpp
sh setup.sh

If you encounter other issues during installing trilinear, please refer to its official repository.