Browse Source

Update __init__.py

pull/7/head
tin2tin 2 years ago committed by GitHub
parent
commit
4ae20922e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 39
      __init__.py

39
__init__.py

@ -12,6 +12,9 @@ bl_info = {
import bpy import bpy
from bpy.types import Operator, Panel from bpy.types import Operator, Panel
import site
import subprocess
import sys
def import_module(self, module): def import_module(self, module):
@ -19,10 +22,6 @@ def import_module(self, module):
try: try:
exec("import " + module) exec("import " + module)
except ModuleNotFoundError: except ModuleNotFoundError:
import site
import subprocess
import sys
app_path = site.USER_SITE app_path = site.USER_SITE
if app_path not in sys.path: if app_path not in sys.path:
sys.path.append(app_path) sys.path.append(app_path)
@ -39,13 +38,6 @@ def import_module(self, module):
try: try:
exec("import " + module) exec("import " + module)
except ModuleNotFoundError: except ModuleNotFoundError:
# print("Installation of the " + module + " module failed")
# self.report(
# {"INFO"},
# "Installing "
# + module
# + " module failed! Try to run Blender as administrator.",
# )
return False return False
return True return True
@ -64,8 +56,29 @@ class SequencerImportMovieOperator(Operator):
def execute(self, context): def execute(self, context):
scene = context.scene scene = context.scene
subprocess.check_call(
[
pybin,
"-m",
"pip",
"install",
"git+https://github.com/modelscope/modelscope.git",
"--user",
]
)
try:
import modelscope
except ModuleNotFoundError:
print("Installation of the modelscope module failed")
self.report(
{"INFO"},
"Installing modelscope module failed! Try to run Blender as administrator.",
)
return False
import_module(self, "open_clip_torch") import_module(self, "open_clip_torch")
if import_module(self, "modelscope"): import_module(self, "pytorch-lightning")
from modelscope.pipelines import pipeline from modelscope.pipelines import pipeline
from modelscope.outputs import OutputKeys from modelscope.outputs import OutputKeys
@ -110,7 +123,7 @@ def register():
bpy.utils.register_class(SequencerPanel) bpy.utils.register_class(SequencerPanel)
bpy.types.Scene.my_movie_filename = bpy.props.StringProperty( bpy.types.Scene.my_movie_filename = bpy.props.StringProperty(
name="My Movie Filename", default="" name="My Movie Filename", default=""
) # , update=bpy.ops.sequencer.import_movie) )
def unregister(): def unregister():

Loading…
Cancel
Save