bcmi / libcom Goto Github PK
View Code? Open in Web Editor NEWImage composition toolbox: everything you want to know about image composition or object insertion
License: Apache License 2.0
Image composition toolbox: everything you want to know about image composition or object insertion
License: Apache License 2.0
Hi!
I tried to use image harmonization, but it seems like the model produces undesired output.
Could you tell me how can I improve the result?
Here's the code I executed.
`# image harmonization
PCTNet = ImageHarmonizationModel(device=3, model_type='CDTNet') # CDTNet
comp_img1 = os.getcwd() + '/libcom/tests/source/composite/Comp1.png'
comp_mask1 = os.getcwd() + '/libcom/tests/source/composite_mask/Comp_mask1.png'
PCT_result1 = PCTNet(comp_img1, comp_mask1)
cv2.imwrite(os.getcwd()+'/libcom/temp.png', PCT_result1)`
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'
I am following the documentation of Libcom, and I have tested the example code. My RAM is running out of memory. I am using Linux and have 16GB of RAM with a 10GB swap area. All of my RAM is being consumed along with the swap. Additionally, I have a 16GB GPU, and I am running my model on the GPU using the .to("cuda")
command in PyTorch. However, my RAM usage continues to increase. I want to know what the minimum requirements are to run the models. Do I have insufficient resources, or am I doing something wrong? I am strictly following the documentation.
I have completed the installation as instructed in the documents and ran the example of "ControlComModel", but it didn't work.
https://libcom.readthedocs.io/en/latest/api.html
Greate Work! But I notice that the ControlCom has the other two tasks can be performed which is named as 'viewsynthesis', 'composition'. But they can't be performed in this libcom project even if I have changed the indicator map as (1,1) or (1,0).
Traceback (most recent call last):
File "C:\Users\userAdmin\Documents\TechDev\cdf_demo\LipSick\inference.py", line 1, in <module>
from libcom import ImageHarmonizationModel
File "C:\Users\userAdmin\miniconda3\envs\lipsick\lib\site-packages\libcom-0.0.2.post1-py3.10-win-amd64.egg\libcom\__init__.py", line 6, in <module>
from .image_harmonization import *
File "C:\Users\userAdmin\miniconda3\envs\lipsick\lib\site-packages\libcom-0.0.2.post1-py3.10-win-amd64.egg\libcom\image_harmonization\__init__.py", line 2, in <module> from .image_harmonization import ImageHarmonizationModel
File "C:\Users\userAdmin\miniconda3\envs\lipsick\lib\site-packages\libcom-0.0.2.post1-py3.10-win-amd64.egg\libcom\image_harmonization\image_harmonization.py", line 8,
in <module>
from .source.pct_net import *
File "C:\Users\userAdmin\miniconda3\envs\lipsick\lib\site-packages\libcom-0.0.2.post1-py3.10-win-amd64.egg\libcom\image_harmonization\source\pct_net.py", line 6, in <module>
from .functions import PCT, ViT_Harmonizer
File "C:\Users\userAdmin\miniconda3\envs\lipsick\lib\site-packages\libcom-0.0.2.post1-py3.10-win-amd64.egg\libcom\image_harmonization\source\functions.py", line 11, in <module>
import trilinear
ImportError: DLL load failed while importing trilinear: The specified module could not be found.
Hi, I created a new environment and have ran the setup.sh scripts for both libcom and trilinear which can be seen in my environment libraries and also when calling pip list but keep encountering this error. Is there a way to resolve this?
win11:
python:3.10.11
creating build\temp.win-amd64-cpython-310\Release
creating build\temp.win-amd64-cpython-310\Release\libcom
creating build\temp.win-amd64-cpython-310\Release\libcom\image_harmonization
creating build\temp.win-amd64-cpython-310\Release\libcom\image_harmonization\source
creating build\temp.win-amd64-cpython-310\Release\libcom\image_harmonization\source\trilinear_cpp
creating build\temp.win-amd64-cpython-310\Release\libcom\image_harmonization\source\trilinear_cpp\src
"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -Ilibcom/image_harmonization/source/trilinear_cpp/src -ID:\Python310\lib\site-packages\torch\include -ID:\Python310\lib\site-packages\torch\include\torch\csrc\api\include -ID:\Python310\lib\site-packages\torch\include\TH -ID:\Python310\lib\site-packages\torch\include\THC -ID:\Python310\include -ID:\Python310\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt" /EHsc /Tplibcom/image_harmonization/source/trilinear_cpp/src/trilinear.cpp /Fobuild\temp.win-amd64-cpython-310\Release\libcom/image_harmonization/source/trilinear_cpp/src/trilinear.obj /MD /wd4819 /wd4251 /wd4244 /wd4267 /wd4275 /wd4018 /wd4190 /wd4624 /wd4067 /wd4068 /EHsc -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=trilinear -D_GLIBCXX_USE_CXX11_ABI=0 /std:c++17
trilinear.cpp
c1xx: fatal error C1083: 无法打开源文件: “libcom/image_harmonization/source/trilinear_cpp/src/trilinear.cpp”: No such file or directory
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe' failed with exit code 2
在管理cmd中执行如下命令:pip install libcom,报上面的错误
I'm on mac and getting error during harmonization process: Only GPU are supported
Are you planning to support cpu as a device type?
Collecting libcom
Using cached libcom-0.0.1.post9.tar.gz (354 kB)
Preparing metadata (setup.py) ... done
Building wheels for collected packages: libcom
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
Building wheel for libcom (setup.py) ... error
ERROR: Failed building wheel for libcom
Running setup.py clean for libcom
Failed to build libcom
ERROR: Could not build wheels for libcom, which is required to install pyproject.toml-based projects
我在windows系统上的trilinear_cpp目录下使用完sh setup.sh命令,在pycharm中运行代码仍有缺少trilinear库的报错,请问是windows系统无法使用该库的原因吗
This library seems to require downscaling to 512x512 which is way too low. Is there a way to make this work at 1024 or even 2048 resolution?
调用opa_score功能代码如下:
from libcom import get_composite_image
from libcom.utils.process_image import make_image_grid
from PIL import Image
import cv2
net = OPAScoreModel(device=0, model_type='SimOPA')
bg_img = Image.open('/home/wenhuaszhgc/users/xqq/tools/images/8_bg.png')
fg_img = Image.open('/home/wenhuaszhgc/users/xqq/tools/images/8_o.png')
mask_img = Image.open('/home/wenhuaszhgc/users/xqq/tools/images/8.png')
comp_img = Image.open('/home/wenhuaszhgc/users/xqq/tools/images/8_cp.png')
score8 = net(comp_img, mask_img)
print(score8)
报错提示:RuntimeError: Given groups=1, weight of size [64, 4, 7, 7], expected input[1, 8, 256, 256] to have 4 channels, but got 8 channels instead,具体报错信息如下:
╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│ /home/wenhuaszhgc/users/xqq/gradio/opa_score_test.py:19 in <module> │
│ │
│ 16 # comp2, comp_mask2 = get_composite_image(fg_img, fg_mask, bg_img, bbox │
│ 17 # score1 = net(comp1, comp_mask1) │
│ 18 # score2 = net(comp2, comp_mask2) │
│ ❱ 19 score8 = net(comp_img, mask_img) │
│ 20 # grid_img = make_image_grid([comp1, comp_mask1, comp2, comp_mask2], │
│ 21 # text_list=[f'opa_score:{score1:.2f}', 'com │
│ 22 # cv2.imwrite('../docs/_static/image/opascore_result1.jpg', grid_img) │
│ │
│ /home/wenhuaszhgc/miniconda3/envs/xqqpy38/lib/python3.8/site-packages/torch/ │
│ autograd/grad_mode.py:27 in decorate_context │
│ │
│ 24 │ │ @functools.wraps(func) │
│ 25 │ │ def decorate_context(*args, **kwargs): │
│ 26 │ │ │ with self.clone(): │
│ ❱ 27 │ │ │ │ return func(*args, **kwargs) │
│ 28 │ │ return cast(F, decorate_context) │
│ 29 │ │
│ 30 │ def _wrap_generator(self, func): │
│ │
│ /home/wenhuaszhgc/miniconda3/envs/xqqpy38/lib/python3.8/site-packages/libcom │
│ /opa_score/opa_score_prediction.py:98 in __call__ │
│ │
│ 95 │ │ │
│ 96 │ │ """ │
│ 97 │ │ inputs = self.inputs_preprocess(composite_image, composite_ │
│ ❱ 98 │ │ outputs = self.model(inputs) │
│ 99 │ │ preds = self.outputs_postprocess(outputs) │
│ 100 │ │ return preds │
│ 101 │
│ │
│ /home/wenhuaszhgc/miniconda3/envs/xqqpy38/lib/python3.8/site-packages/torch/ │
│ nn/modules/module.py:1130 in _call_impl │
│ │
│ 1127 │ │ # this function, and just call forward. │
│ 1128 │ │ if not (self._backward_hooks or self._forward_hooks or self._ │
│ 1129 │ │ │ │ or _global_forward_hooks or _global_forward_pre_hooks │
│ ❱ 1130 │ │ │ return forward_call(*input, **kwargs) │
│ 1131 │ │ # Do not call functions when jit is used │
│ 1132 │ │ full_backward_hooks, non_full_backward_hooks = [], [] │
│ 1133 │ │ if self._backward_hooks or _global_backward_hooks: │
│ │
│ /home/wenhuaszhgc/miniconda3/envs/xqqpy38/lib/python3.8/site-packages/libcom │
│ /opa_score/source/object_place_net.py:38 in forward │
│ │
│ 35 │ │ global_feature = None │
│ 36 │ │ if opt.without_mask: │
│ 37 │ │ │ img_cat = img_cat[:,0:3] │
│ ❱ 38 │ │ feature_map = self.backbone(img_cat) # b,512,8,8 (resnet layer │
│ 39 │ │ global_feature = self.avgpool1x1(feature_map) # b,512,1,1 │
│ 40 │ │ global_feature = global_feature.flatten(1) # b,512 │
│ 41 │
│ │
│ /home/wenhuaszhgc/miniconda3/envs/xqqpy38/lib/python3.8/site-packages/torch/ │
│ nn/modules/module.py:1130 in _call_impl │
│ │
│ 1127 │ │ # this function, and just call forward. │
│ 1128 │ │ if not (self._backward_hooks or self._forward_hooks or self._ │
│ 1129 │ │ │ │ or _global_forward_hooks or _global_forward_pre_hooks │
│ ❱ 1130 │ │ │ return forward_call(*input, **kwargs) │
│ 1131 │ │ # Do not call functions when jit is used │
│ 1132 │ │ full_backward_hooks, non_full_backward_hooks = [], [] │
│ 1133 │ │ if self._backward_hooks or _global_backward_hooks: │
│ │
│ /home/wenhuaszhgc/miniconda3/envs/xqqpy38/lib/python3.8/site-packages/torch/ │
│ nn/modules/container.py:139 in forward │
│ │
│ 136 │ # with Any as TorchScript expects a more precise type │
│ 137 │ def forward(self, input): │
│ 138 │ │ for module in self: │
│ ❱ 139 │ │ │ input = module(input) │
│ 140 │ │ return input │
│ 141 │ │
│ 142 │ def append(self, module: Module) -> 'Sequential': │
│ │
│ /home/wenhuaszhgc/miniconda3/envs/xqqpy38/lib/python3.8/site-packages/torch/ │
│ nn/modules/module.py:1130 in _call_impl │
│ │
│ 1127 │ │ # this function, and just call forward. │
│ 1128 │ │ if not (self._backward_hooks or self._forward_hooks or self._ │
│ 1129 │ │ │ │ or _global_forward_hooks or _global_forward_pre_hooks │
│ ❱ 1130 │ │ │ return forward_call(*input, **kwargs) │
│ 1131 │ │ # Do not call functions when jit is used │
│ 1132 │ │ full_backward_hooks, non_full_backward_hooks = [], [] │
│ 1133 │ │ if self._backward_hooks or _global_backward_hooks: │
│ │
│ /home/wenhuaszhgc/miniconda3/envs/xqqpy38/lib/python3.8/site-packages/torch/ │
│ nn/modules/conv.py:457 in forward │
│ │
│ 454 │ │ │ │ │ │ self.padding, self.dilation, self.groups) │
│ 455 │ │
│ 456 │ def forward(self, input: Tensor) -> Tensor: │
│ ❱ 457 │ │ return self._conv_forward(input, self.weight, self.bias) │
│ 458 │
│ 459 class Conv3d(_ConvNd): │
│ 460 │ __doc__ = r"""Applies a 3D convolution over an input signal compo │
│ │
│ /home/wenhuaszhgc/miniconda3/envs/xqqpy38/lib/python3.8/site-packages/torch/ │
│ nn/modules/conv.py:453 in _conv_forward │
│ │
│ 450 │ │ │ return F.conv2d(F.pad(input, self._reversed_padding_repea │
│ 451 │ │ │ │ │ │ │ weight, bias, self.stride, │
│ 452 │ │ │ │ │ │ │ _pair(0), self.dilation, self.groups) │
│ ❱ 453 │ │ return F.conv2d(input, weight, bias, self.stride, │
│ 454 │ │ │ │ │ │ self.padding, self.dilation, self.groups) │
│ 455 │ │
│ 456 │ def forward(self, input: Tensor) -> Tensor: │
╰──────────────────────────────────────────────────────────────────────────────╯
RuntimeError: Given groups=1, weight of size [64, 4, 7, 7], expected input[1, 8, 256, 256] to have 4 channels, but got 8 channels instead
Process finished with exit code 1
请问应该如何修改?
Hi, is there a plan or estimated timeline to stablize and then release other two tasks 'view synthesis' and 'composition' for ControlCom model? Thanks!
Multiple automatic downloads are often done with broken symlinks, forcing me to manually fix them for all the tests. Secondly, shared pre-trained models like Vit are often broken again and again when the Zip file function is envoked.
Could I ask whether Windows system can use this project as a tool for image composition?
conda env create -f libcom.yaml 环境创建失败
Hi Author,
I ran your code "python test_image_harmonization.py", it always triggered a bug as below:
begin testing image_harmonization...
Segmentation fault (core dumped)
I found out there was something wrong with the 'CDTNet.pth'. No matter downloaded from the code automatically or from the modelscope.cn, the model just didn't work.
Btw, my Env:
OS - Ubuntu 20.04
GPU - Nvidia 4090
cuda - 11.3.r11.3
python - 3.8.5
Please help or fix the bug.
Traceback (most recent call last):
File "tests/test_fopa_heat_map.py", line 19, in
net = FOPAHeatMapModel(device=0)
File "/home/largedata/qianlei/parking_slot_detection/libcom/libcom/fopa_heat_map/fopa_heat_map.py", line 68, in init
download_pretrained_model(sopa_weight)
File "/home/largedata/qianlei/parking_slot_detection/libcom/libcom/utils/model_download.py", line 18, in download_pretrained_model
download_file_from_network(model_name, save_dir)
File "/home/largedata/qianlei/parking_slot_detection/libcom/libcom/utils/model_download.py", line 50, in download_file_from_network
file_path = model_file_download(model_id=ms_repo,
File "/home/qianlei/miniconda3/envs/Libcom/lib/python3.8/site-packages/modelscope/hub/file_download.py", line 136, in model_file_download
raise NotExistError('The file path: %s not exist in: %s' %
modelscope.hub.errors.NotExistError: The file path: SOPA.pth.tar not exist in: bcmizb/Libcom_pretrained_models
Hello, failed to download the model. I tried to open the download link, but it couldn't be opened.
copying libcom/controllable_composition/source/ControlCom/configs/controlcom.yaml -> build/lib.linux-x86_64-cpython-311/libcom/controllable_composition/source/ControlCom/configs
copying libcom/fos_score/source/config/config_rfosd.yaml -> build/lib.linux-x86_64-cpython-311/libcom/fos_score/source/config
copying libcom/fos_score/source/config/config.sfosd.yaml -> build/lib.linux-x86_64-cpython-311/libcom/fos_score/source/config
copying libcom/shadow_generation/source/cldm_v15.yaml -> build/lib.linux-x86_64-cpython-311/libcom/shadow_generation/source
copying libcom/painterly_image_harmonization/source/PHDiffusion/stable_diffusion.yaml -> build/lib.linux-x86_64-cpython-311/libcom/painterly_image_harmonization/source/PHDiffusion
running build_ext
building 'trilinear' extension
creating /tmp/pip-install-jbn64orc/libcom_468d5c874bb849d9a5be66d430575b81/build/temp.linux-x86_64-cpython-311
creating /tmp/pip-install-jbn64orc/libcom_468d5c874bb849d9a5be66d430575b81/build/temp.linux-x86_64-cpython-311/libcom
creating /tmp/pip-install-jbn64orc/libcom_468d5c874bb849d9a5be66d430575b81/build/temp.linux-x86_64-cpython-311/libcom/image_harmonization
creating /tmp/pip-install-jbn64orc/libcom_468d5c874bb849d9a5be66d430575b81/build/temp.linux-x86_64-cpython-311/libcom/image_harmonization/source
creating /tmp/pip-install-jbn64orc/libcom_468d5c874bb849d9a5be66d430575b81/build/temp.linux-x86_64-cpython-311/libcom/image_harmonization/source/trilinear_cpp
creating /tmp/pip-install-jbn64orc/libcom_468d5c874bb849d9a5be66d430575b81/build/temp.linux-x86_64-cpython-311/libcom/image_harmonization/source/trilinear_cpp/src
Emitting ninja build file /tmp/pip-install-jbn64orc/libcom_468d5c874bb849d9a5be66d430575b81/build/temp.linux-x86_64-cpython-311/build.ninja...
Compiling objects...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
ninja: error: '/tmp/pip-install-jbn64orc/libcom_468d5c874bb849d9a5be66d430575b81/libcom/image_harmonization/source/trilinear_cpp/src/trilinear.cpp', needed by '/tmp/pip-install-jbn64orc/libcom_468d5c874bb849d9a5be66d430575b81/build/temp.linux-x86_64-cpython-311/libcom/image_harmonization/source/trilinear_cpp/src/trilinear.o', missing and no known rule to make it
Traceback (most recent call last):
File "/home/hangyi/anaconda3/envs/inpaint/lib/python3.11/site-packages/torch/utils/cpp_extension.py", line 2100, in _run_ninja_build
subprocess.run(
File "/home/hangyi/anaconda3/envs/inpaint/lib/python3.11/subprocess.py", line 571, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/tmp/pip-install-jbn64orc/libcom_468d5c874bb849d9a5be66d430575b81/setup.py", line 109, in <module>
setup(
File "/home/hangyi/anaconda3/envs/inpaint/lib/python3.11/site-packages/setuptools/__init__.py", line 103, in setup
return distutils.core.setup(**attrs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/hangyi/anaconda3/envs/inpaint/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 185, in setup
return run_commands(dist)
^^^^^^^^^^^^^^^^^^
File "/home/hangyi/anaconda3/envs/inpaint/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
dist.run_commands()
File "/home/hangyi/anaconda3/envs/inpaint/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
self.run_command(cmd)
File "/home/hangyi/anaconda3/envs/inpaint/lib/python3.11/site-packages/setuptools/dist.py", line 989, in run_command
super().run_command(command)
File "/home/hangyi/anaconda3/envs/inpaint/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
cmd_obj.run()
File "/home/hangyi/anaconda3/envs/inpaint/lib/python3.11/site-packages/wheel/bdist_wheel.py", line 364, in run
self.run_command("build")
File "/home/hangyi/anaconda3/envs/inpaint/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
self.distribution.run_command(command)
File "/home/hangyi/anaconda3/envs/inpaint/lib/python3.11/site-packages/setuptools/dist.py", line 989, in run_command
super().run_command(command)
File "/home/hangyi/anaconda3/envs/inpaint/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
cmd_obj.run()
File "/home/hangyi/anaconda3/envs/inpaint/lib/python3.11/site-packages/setuptools/_distutils/command/build.py", line 131, in run
self.run_command(cmd_name)
File "/home/hangyi/anaconda3/envs/inpaint/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
self.distribution.run_command(command)
File "/home/hangyi/anaconda3/envs/inpaint/lib/python3.11/site-packages/setuptools/dist.py", line 989, in run_command
super().run_command(command)
File "/home/hangyi/anaconda3/envs/inpaint/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
cmd_obj.run()
File "/home/hangyi/anaconda3/envs/inpaint/lib/python3.11/site-packages/setuptools/command/build_ext.py", line 88, in run
_build_ext.run(self)
File "/home/hangyi/anaconda3/envs/inpaint/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 345, in run
self.build_extensions()
File "/home/hangyi/anaconda3/envs/inpaint/lib/python3.11/site-packages/torch/utils/cpp_extension.py", line 873, in build_extensions
build_ext.build_extensions(self)
File "/home/hangyi/anaconda3/envs/inpaint/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 467, in build_extensions
self._build_extensions_serial()
File "/home/hangyi/anaconda3/envs/inpaint/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 493, in _build_extensions_serial
self.build_extension(ext)
File "/home/hangyi/anaconda3/envs/inpaint/lib/python3.11/site-packages/setuptools/command/build_ext.py", line 249, in build_extension
_build_ext.build_extension(self, ext)
File "/home/hangyi/anaconda3/envs/inpaint/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 548, in build_extension
objects = self.compiler.compile(
^^^^^^^^^^^^^^^^^^^^^^
File "/home/hangyi/anaconda3/envs/inpaint/lib/python3.11/site-packages/torch/utils/cpp_extension.py", line 686, in unix_wrap_ninja_compile
_write_ninja_file_and_compile_objects(
File "/home/hangyi/anaconda3/envs/inpaint/lib/python3.11/site-packages/torch/utils/cpp_extension.py", line 1774, in _write_ninja_file_and_compile_objects
_run_ninja_build(
File "/home/hangyi/anaconda3/envs/inpaint/lib/python3.11/site-packages/torch/utils/cpp_extension.py", line 2116, in _run_ninja_build
raise RuntimeError(message) from e
RuntimeError: Error compiling objects for extension
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for libcom
Running setup.py clean for libcom
Failed to build libcom
ERROR: Could not build wheels for libcom, which is required to install pyproject.toml-based projects
when I use python 3.11 to install libcom (pip install libcom), the error is like above,
because I have some packages have to use python > 3.11, there are some conflicts with libcom,
I think other people have similar problems, and I have check the libcom.yaml,
since I mainly use the ShadowGenerationModel, so is it okay to update the python version from 3.8 to 3.11, or which packages conflict with python 3.11, thanks a lot.
Hi , i want to use image harmonization
by source in https://bcmi.sjtu.edu.cn/home/niuli/demo_image_composition/; Could you give me some advice? what files should i see? Thank you very much .
请问,如何训练自己的图片,进行前景图的提取,以及到后面的图像融合还有色彩协调呢?
如题,对于像素小于30*30的小目标是否具有较好的效果呢
Hello, I'm trying to
$ pip install libcom
It's failing with this message:
ninja: error: '/tmp/pip-install-6mqbh3s0/libcom_1d0a9345d9964e32bf19615494336cec/libcom/image_harmonization/source/trilinear_cpp_torch1.11/src/trilinear_cuda.cpp', needed by '/tmp/pip-install-6mqbh3s0/libcom_1d0a9345d9964e32bf19615494336cec/build/t
emp.linux-x86_64-cpython-310/tmp/pip-install-6mqbh3s0/libcom_1d0a9345d9964e32bf19615494336cec/libcom/image_harmonization/source/trilinear_cpp_torch1.11/src/trilinear_cuda.o', missing and no known rule to make it
Traceback (most recent call last):
File "/home/predmodl/.pyenv/versions/python310/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 2096, in _run_ninja_build
subprocess.run(
File "/home/predmodl/.pyenv/versions/3.10.11/lib/python3.10/subprocess.py", line 526, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.
Any suggestions? Thanks!
Hi,
Firstly, thank you for your great work. I'm trying different model types for image harmonization. Successfully tested PCTNet, but encountered the following error when trying to adopt CDTNet:
(Libcom) root@LUCAS-DEV-a17a0b:~/lky/TSR/libcom/demo# python compose.py
cudaCheckError() failed : no kernel image is available for execution on the device
I built the environment on Linux with python = 3.8.5 and torch = 1.10.1, also checked that cuda is available.
(Libcom) root@LUCAS-DEV-a17a0b:~/lky/TSR/libcom/demo# pip list | grep torch
open-clip-torch 2.7.0
pytorch-lightning 1.9.0
torch 1.10.1
torchaudio 0.10.1
torchmetrics 1.3.0.post0
torchvision 0.11.2
(Libcom) root@LUCAS-DEV-a17a0b:~/lky/TSR/libcom/demo# nvidia-smi
Thu Feb 29 15:36:10 2024
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.129.06 Driver Version: 470.129.06 CUDA Version: 11.4 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA A100-SXM... On | 00000000:65:01.0 Off | 0 |
| N/A 57C P0 410W / 400W | 18859MiB / 81251MiB | 78% Default |
| | | Disabled |
+-------------------------------+----------------------+----------------------+
| 1 NVIDIA A100-SXM... On | 00000000:67:01.0 Off | 0 |
| N/A 46C P0 88W / 400W | 27981MiB / 81251MiB | 53% Default |
| | | Disabled |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
+-----------------------------------------------------------------------------+
When using ImageHarmonization with
PCTNet = ImageHarmonizationModel(device=torch.device('cuda', 0), model_type='PCTNet')
PCT_result = PCTNet(image, mask)
90 CPU kernels (out of 120) are used, and it only takes 4G GPU memory. I wonder why it would happen since I have set the device to be CUDA:0.
Do you have any idea how I could move most of the computation to GPU?
Hi,
I am testing both PCTNet and CDTNet for harmonization.
I am getting bad results when using my own images as well as when I use images provided by you.
specifically I tried libcom/tests/harmony_score_prediction/composite/ameland-5651866_harm.jpg
and its corresponding mask. (the images you are showing in the docs are not available at this repo)
any idea to what could be the problem? I am following the example provided in the docs
#Use CDTNet
CDTNet = ImageHarmonizationModel(device=0, model_type='CDTNet')
comp_img1 = image_path
comp_mask1 = mask_pth
CDT_result1 = CDTNet(comp_img1, comp_mask1)
#Use PCTNet
PCTNet = ImageHarmonizationModel(device=0, model_type='PCTNet')
comp_img1 = image_path
comp_mask1 = mask_pth
PCT_result1 = PCTNet(comp_img1, comp_mask1)
Thanks
how can we finetune/train the models ?
when running: !pip install -r libcom/requirements/runtime.txt
Collecting albumentations==1.3.0 (from -r libcom/requirements/runtime.txt (line 1))
Using cached albumentations-1.3.0-py3-none-any.whl.metadata (34 kB)
Collecting einops==0.3.0 (from -r libcom/requirements/runtime.txt (line 2))
Using cached einops-0.3.0-py2.py3-none-any.whl.metadata (10 kB)
Collecting huggingface_hub==0.13.4 (from -r libcom/requirements/runtime.txt (line 3))
Using cached huggingface_hub-0.13.4-py3-none-any.whl.metadata (7.5 kB)
Collecting imageio==2.9.0 (from -r libcom/requirements/runtime.txt (line 4))
Using cached imageio-2.9.0-py3-none-any.whl.metadata (2.6 kB)
Collecting mmdet==3.2.0 (from -r libcom/requirements/runtime.txt (line 5))
Using cached mmdet-3.2.0-py3-none-any.whl.metadata (32 kB)
Collecting mmpose==1.2.0 (from -r libcom/requirements/runtime.txt (line 6))
Using cached mmpose-1.2.0-py2.py3-none-any.whl.metadata (29 kB)
Collecting modelscope==1.9.3 (from -r libcom/requirements/runtime.txt (line 7))
Using cached modelscope-1.9.3-py3-none-any.whl.metadata (33 kB)
Collecting omegaconf==2.3.0 (from -r libcom/requirements/runtime.txt (line 8))
Using cached omegaconf-2.3.0-py3-none-any.whl.metadata (3.9 kB)
ERROR: Ignored the following yanked versions: 3.4.11.39
ERROR: Could not find a version that satisfies the requirement opencv_python==4.1.2.30 (from versions: 3.4.0.14, 3.4.10.37, 3.4.11.41, 3.4.11.43, 3.4.11.45, 3.4.13.47, 3.4.15.55, 3.4.16.57, 3.4.16.59, 3.4.17.61, 3.4.17.63, 3.4.18.65, 4.3.0.38, 4.4.0.40, 4.4.0.42, 4.4.0.44, 4.4.0.46, 4.5.1.48, 4.5.3.56, 4.5.4.58, 4.5.4.60, 4.5.5.62, 4.5.5.64, 4.6.0.66, 4.7.0.68, 4.7.0.72, 4.8.0.74, 4.8.0.76, 4.8.1.78, 4.9.0.80)
ERROR: No matching distribution found for opencv_python==4.1.2.30
I couldn't get it installed on Mac M2.
Any chance you can make a HuggingFace Space so that we can use it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.