BrokenSource / DepthFlow

🌊 Image to → 2.5D Parallax Effect Video. High quality, user first. Free and Open Source Leiapix alternative
https://brokensrc.dev
GNU Affero General Public License v3.0
153 stars 11 forks source link

(BUG) error after update to broken-source 0.3.1 #21

Closed steve02081504 closed 1 month ago

steve02081504 commented 1 month ago
~ >pip list
Package                Version
---------------------- --------------
broken-source          0.3.1
depthflow              2024.1.15

~ >depthflow input -i C:\Users\steve02081504\Downloads\116018494_p0.png main

---------------------------------------------------------------------------------------
198 _run_module_as_main <frozen runpy>
>

88 _run_code <frozen runpy>
>

4 <module> E:\Python\Scripts\depthflow.exe\__main__.py
> from DepthFlow.__main__ import main

4 <module> E:\Python\Lib\site-packages\DepthFlow\__main__.py
> from DepthFlow.DepthFlow import DepthFlowScene

21 <module> E:\Python\Lib\site-packages\DepthFlow\DepthFlow.py
  from ShaderFlow.Optional.Monocular import DepthEstimator
  from ShaderFlow.Scene import ShaderScene
  from ShaderFlow.Texture import ShaderTexture
  from ShaderFlow.Variable import ShaderVariable
  from typer import Option

  from Broken import image_hash
  from Broken.Externals.Upscaler import BrokenUpscaler
  from Broken.Externals.Upscaler.ncnn import BrokenRealEsrgan
  from Broken.Loaders import LoaderImage
> from DepthFlow import DEPTHFLOW

  class DepthFlowState(BaseModel):

      height: float = Field(default=0.35)
      """Peak value of the Depth Map, in the range [0, 1]. The camera is 1 distance away from depth=0
      at the z=1 plane, so this also controls the intensity of the effect"""

      focus: float = Field(default=0.0)
      """Focal depth of offsets, in the range [0, 1]. A value of 0 makes the background (depth=0)

ImportError:
cannot import name 'DEPTHFLOW' from 'DepthFlow' (E:\Python\Lib\site-packages\DepthFlow\__init__.py)
~ >vat E:\Python\Lib\site-packages\DepthFlow\__init__.py
cat E:\Python\Lib\site-packages\DepthFlow\__init__.py [enter/↑/↓/ctrl+c]
# Reserving pypi name
~ >
Tremeschin commented 1 month ago

Oh, sorry, don't install PyPI's depthflow, the wheel is empty. I once tried splitting all the projects in their own packages, but the easiest solution was to bundle everything in a single dependency broken-source

Perhaps I should mirror the main wheel on others, but that might cause some issues

This import error appears after doing so:

~
❯ cd /tmp

/tmp
❯ python -m venv venv

/tmp
❯ source ./venv/bin/activate.fish

/tmp via 🐍 v3.12.3 (venv)
❯ pip install --upgrade broken-source==0.3.1
(...)

/tmp via 🐍 v3.12.3 (venv)
❯ depthflow input -i ~/image.jpg main -o /tmp/depthflow.mp4
(...)
│DepthFlow ├┤5150ms├┤INFO   │ ▸ Finished rendering (/tmp/depthflow.mp4)
│DepthFlow ├┤5151ms├┤INFO   │ ▸ • Stats: (Took 3.96 s) at (151.08 FPS | 2.52 x Realtime) with (600 Total Frames)

/tmp via 🐍 v3.12.3 (venv) took 5s 
❯ depthflow input -i ~/image.jpg main -o /tmp/depthflow.mp4

/tmp via 🐍 v3.12.3 (venv) took 5s 
❯ depthflow input -i ~/image.jpg main -o /tmp/depthflow.mp4
(...)

cannot import name 'DEPTHFLOW' from 'DepthFlow' (/tmp/venv/lib/python3.12/site-packages/DepthFlow/__init__.py)

So, in your case, just pip uninstall depthflow or remove it from pyproject.toml/requirements.txt and sync :)

steve02081504 commented 1 month ago
~ >pip uninstall depthflow
Found existing installation: depthflow 2024.1.15
Uninstalling depthflow-2024.1.15:
  Would remove:
    e:\python\lib\site-packages\depthflow-2024.1.15.dist-info\*
    e:\python\lib\site-packages\depthflow\*
  Would not remove (might be manually added):
    e:\python\lib\site-packages\depthflow\CustomScene.py
    e:\python\lib\site-packages\depthflow\DepthFlow.py
    e:\python\lib\site-packages\depthflow\Resources\Images\DepthFlow.png
    e:\python\lib\site-packages\depthflow\Resources\Images\DepthFlow.svg
    e:\python\lib\site-packages\depthflow\Resources\Shaders\Deprecated\DepthFlow2D.frag
    e:\python\lib\site-packages\depthflow\Resources\Shaders\Deprecated\DepthFlowMarch.frag
    e:\python\lib\site-packages\depthflow\Resources\Shaders\DepthFlow.frag
    e:\python\lib\site-packages\depthflow\__main__.py
Proceed (Y/n)? y
  Successfully uninstalled depthflow-2024.1.15
~ >depthflow input -i C:\Users\steve02081504\Downloads\116018494_p0.png main

---------------------------------------------------------------------------------------
198 _run_module_as_main <frozen runpy>
(...)

ImportError:
cannot import name 'DEPTHFLOW' from 'DepthFlow' (unknown location)

I'm not quite sure what you mean by sync, this is what I get after deleting it

Tremeschin commented 1 month ago

Either reinstall the package pip install --force-reinstall broken-source, or delete the venv and start over


Explanation: Both depthflow and broken-source packages wrote site-packages/DepthFlow on the venv

You probably installed first broken-source, then depthflow, which overwrote the broken-source's extracted directory DepthFlow with empty contents, then uninstalled depthflow, removing the contents, so the "unknown location"


I'm not quite sure what you mean by sync

If you were using a project manager like Poetry, PDM, Rye, etc. to run poetry install, pdm install, rye sync etc

Can ignore this if you're just doing a pip install inside a manually managed venv/scripts 👍🏻

steve02081504 commented 1 month ago

it works, ty for help!