Spaces:
Runtime error
Runtime error
jmanhype
commited on
Commit
·
ed46d76
1
Parent(s):
43e677e
Improve file handling and add more debugging
Browse files- Dockerfile +10 -10
- app.py +41 -6
Dockerfile
CHANGED
@@ -43,26 +43,25 @@ RUN pip install --no-cache-dir openmim && \
|
|
43 |
mim install "mmdet>=3.1.0" && \
|
44 |
mim install "mmpose>=1.1.0"
|
45 |
|
|
|
|
|
|
|
46 |
# Clone and set up MuseV
|
47 |
-
RUN git clone https://github.com/TMElyralab/MuseV.git
|
48 |
-
mkdir -p MuseV && \
|
49 |
-
cp -r /tmp/MuseV/* MuseV/ && \
|
50 |
cd MuseV && \
|
51 |
git clone https://github.com/huggingface/diffusers.git && \
|
52 |
git clone https://github.com/patrickvonplaten/controlnet_aux.git && \
|
53 |
cd diffusers && pip install -e . && \
|
54 |
cd ../controlnet_aux && pip install -e . && \
|
55 |
cd .. && \
|
56 |
-
|
57 |
-
cp
|
|
|
58 |
chmod +x ../gradio_*.py
|
59 |
|
60 |
# Set up Python path
|
61 |
ENV PYTHONPATH="${HOME}/app:${HOME}/app/MuseV:${HOME}/app/MuseV/MMCM:${HOME}/app/MuseV/diffusers/src:${HOME}/app/MuseV/controlnet_aux/src:${HOME}/app/MuseV/scripts/gradio"
|
62 |
|
63 |
-
# Copy application code
|
64 |
-
COPY --chown=user:user . .
|
65 |
-
|
66 |
# Debug information
|
67 |
RUN echo "Current directory:" && pwd && \
|
68 |
echo "Directory contents:" && ls -la && \
|
@@ -71,8 +70,9 @@ RUN echo "Current directory:" && pwd && \
|
|
71 |
echo "Python path:" && echo $PYTHONPATH && \
|
72 |
echo "Checking gradio scripts:" && ls -la gradio_*.py && \
|
73 |
echo "Verifying file contents:" && \
|
74 |
-
head -n
|
75 |
-
|
|
|
76 |
|
77 |
EXPOSE 7860
|
78 |
|
|
|
43 |
mim install "mmdet>=3.1.0" && \
|
44 |
mim install "mmpose>=1.1.0"
|
45 |
|
46 |
+
# Copy application code first
|
47 |
+
COPY --chown=user:user . .
|
48 |
+
|
49 |
# Clone and set up MuseV
|
50 |
+
RUN git clone https://github.com/TMElyralab/MuseV.git && \
|
|
|
|
|
51 |
cd MuseV && \
|
52 |
git clone https://github.com/huggingface/diffusers.git && \
|
53 |
git clone https://github.com/patrickvonplaten/controlnet_aux.git && \
|
54 |
cd diffusers && pip install -e . && \
|
55 |
cd ../controlnet_aux && pip install -e . && \
|
56 |
cd .. && \
|
57 |
+
# Copy gradio scripts to app directory
|
58 |
+
cp scripts/gradio/gradio_video2video.py ../gradio_video2video.py && \
|
59 |
+
cp scripts/gradio/gradio_text2video.py ../gradio_text2video.py && \
|
60 |
chmod +x ../gradio_*.py
|
61 |
|
62 |
# Set up Python path
|
63 |
ENV PYTHONPATH="${HOME}/app:${HOME}/app/MuseV:${HOME}/app/MuseV/MMCM:${HOME}/app/MuseV/diffusers/src:${HOME}/app/MuseV/controlnet_aux/src:${HOME}/app/MuseV/scripts/gradio"
|
64 |
|
|
|
|
|
|
|
65 |
# Debug information
|
66 |
RUN echo "Current directory:" && pwd && \
|
67 |
echo "Directory contents:" && ls -la && \
|
|
|
70 |
echo "Python path:" && echo $PYTHONPATH && \
|
71 |
echo "Checking gradio scripts:" && ls -la gradio_*.py && \
|
72 |
echo "Verifying file contents:" && \
|
73 |
+
cat gradio_video2video.py | head -n 5 && \
|
74 |
+
echo "---" && \
|
75 |
+
cat gradio_text2video.py | head -n 5
|
76 |
|
77 |
EXPOSE 7860
|
78 |
|
app.py
CHANGED
@@ -9,17 +9,33 @@ import gradio as gr
|
|
9 |
import spaces
|
10 |
import cuid
|
11 |
import importlib.util
|
|
|
12 |
|
13 |
from huggingface_hub import snapshot_download
|
14 |
|
15 |
print("Starting application...")
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
def import_from_path(module_name, file_path):
|
18 |
"""Import a module from a file path."""
|
19 |
if not os.path.exists(file_path):
|
20 |
raise ImportError(f"File not found: {file_path}")
|
21 |
|
22 |
print(f"Importing {module_name} from {file_path}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
spec = importlib.util.spec_from_file_location(module_name, file_path)
|
24 |
module = importlib.util.module_from_spec(spec)
|
25 |
spec.loader.exec_module(module)
|
@@ -28,10 +44,22 @@ def import_from_path(module_name, file_path):
|
|
28 |
# Set up paths
|
29 |
ProjectDir = os.path.dirname(os.path.abspath(__file__))
|
30 |
CheckpointsDir = os.path.join(ProjectDir, "checkpoints")
|
31 |
-
MuseVDir = os.path.join(ProjectDir, "MuseV")
|
32 |
-
GradioScriptsDir = os.path.join(MuseVDir, "scripts", "gradio")
|
33 |
|
34 |
print(f"Project directory: {ProjectDir}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
print(f"MuseV directory: {MuseVDir}")
|
36 |
print(f"Gradio scripts directory: {GradioScriptsDir}")
|
37 |
|
@@ -77,16 +105,23 @@ for path in sys.path:
|
|
77 |
|
78 |
print("Attempting to import gradio modules...")
|
79 |
|
80 |
-
#
|
81 |
-
video2video_path =
|
82 |
-
text2video_path =
|
83 |
|
84 |
print(f"Looking for modules at:")
|
85 |
print(f"video2video: {video2video_path}")
|
86 |
print(f"text2video: {text2video_path}")
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
try:
|
89 |
-
print("Attempting to import
|
90 |
video2video = import_from_path("gradio_video2video", video2video_path)
|
91 |
text2video = import_from_path("gradio_text2video", text2video_path)
|
92 |
online_v2v_inference = video2video.online_v2v_inference
|
|
|
9 |
import spaces
|
10 |
import cuid
|
11 |
import importlib.util
|
12 |
+
import glob
|
13 |
|
14 |
from huggingface_hub import snapshot_download
|
15 |
|
16 |
print("Starting application...")
|
17 |
|
18 |
+
def find_file(pattern, search_path="."):
|
19 |
+
"""Find a file matching the pattern in the search path."""
|
20 |
+
matches = glob.glob(os.path.join(search_path, pattern))
|
21 |
+
if matches:
|
22 |
+
return matches[0]
|
23 |
+
return None
|
24 |
+
|
25 |
def import_from_path(module_name, file_path):
|
26 |
"""Import a module from a file path."""
|
27 |
if not os.path.exists(file_path):
|
28 |
raise ImportError(f"File not found: {file_path}")
|
29 |
|
30 |
print(f"Importing {module_name} from {file_path}")
|
31 |
+
with open(file_path, 'r') as f:
|
32 |
+
print(f"File contents (first 5 lines):")
|
33 |
+
for i, line in enumerate(f):
|
34 |
+
if i < 5:
|
35 |
+
print(line.strip())
|
36 |
+
else:
|
37 |
+
break
|
38 |
+
|
39 |
spec = importlib.util.spec_from_file_location(module_name, file_path)
|
40 |
module = importlib.util.module_from_spec(spec)
|
41 |
spec.loader.exec_module(module)
|
|
|
44 |
# Set up paths
|
45 |
ProjectDir = os.path.dirname(os.path.abspath(__file__))
|
46 |
CheckpointsDir = os.path.join(ProjectDir, "checkpoints")
|
47 |
+
MuseVDir = os.path.join(ProjectDir, "MuseV")
|
|
|
48 |
|
49 |
print(f"Project directory: {ProjectDir}")
|
50 |
+
print(f"Directory contents:")
|
51 |
+
print(os.listdir(ProjectDir))
|
52 |
+
|
53 |
+
# Find MuseV directory with case-insensitive search
|
54 |
+
musev_candidates = [d for d in os.listdir(ProjectDir) if d.lower() == "musev"]
|
55 |
+
if musev_candidates:
|
56 |
+
MuseVDir = os.path.join(ProjectDir, musev_candidates[0])
|
57 |
+
print(f"Found MuseV directory: {MuseVDir}")
|
58 |
+
else:
|
59 |
+
print("Warning: Could not find MuseV directory")
|
60 |
+
|
61 |
+
GradioScriptsDir = os.path.join(MuseVDir, "scripts", "gradio")
|
62 |
+
|
63 |
print(f"MuseV directory: {MuseVDir}")
|
64 |
print(f"Gradio scripts directory: {GradioScriptsDir}")
|
65 |
|
|
|
105 |
|
106 |
print("Attempting to import gradio modules...")
|
107 |
|
108 |
+
# Search for gradio modules in multiple locations
|
109 |
+
video2video_path = find_file("gradio_video2video.py", ProjectDir)
|
110 |
+
text2video_path = find_file("gradio_text2video.py", ProjectDir)
|
111 |
|
112 |
print(f"Looking for modules at:")
|
113 |
print(f"video2video: {video2video_path}")
|
114 |
print(f"text2video: {text2video_path}")
|
115 |
|
116 |
+
if not video2video_path or not text2video_path:
|
117 |
+
print("Searching in MuseV directory...")
|
118 |
+
if os.path.exists(GradioScriptsDir):
|
119 |
+
video2video_path = find_file("gradio_video2video.py", GradioScriptsDir)
|
120 |
+
text2video_path = find_file("gradio_text2video.py", GradioScriptsDir)
|
121 |
+
print(f"Found in MuseV: video2video={video2video_path}, text2video={text2video_path}")
|
122 |
+
|
123 |
try:
|
124 |
+
print("Attempting to import modules...")
|
125 |
video2video = import_from_path("gradio_video2video", video2video_path)
|
126 |
text2video = import_from_path("gradio_text2video", text2video_path)
|
127 |
online_v2v_inference = video2video.online_v2v_inference
|