jmanhype commited on
Commit
d6ae642
·
1 Parent(s): 8221cd6

Fix directory case handling and improve module imports

Browse files
Files changed (2) hide show
  1. Dockerfile +6 -4
  2. app.py +27 -21
Dockerfile CHANGED
@@ -45,15 +45,16 @@ RUN pip install --no-cache-dir openmim && \
45
 
46
  # Clone and set up MuseV with exact case
47
  RUN git clone https://github.com/TMElyralab/MuseV.git && \
 
 
48
  cd MuseV && \
49
  git clone https://github.com/huggingface/diffusers.git && \
50
  git clone https://github.com/patrickvonplaten/controlnet_aux.git && \
51
  cd diffusers && pip install -e . && \
52
  cd ../controlnet_aux && pip install -e . && \
53
  cd .. && \
54
- # Create symbolic links for gradio scripts
55
- ln -s scripts/gradio/gradio_video2video.py ../gradio_video2video.py && \
56
- ln -s scripts/gradio/gradio_text2video.py ../gradio_text2video.py
57
 
58
  # Set up Python path
59
  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"
@@ -66,7 +67,8 @@ RUN echo "Current directory:" && pwd && \
66
  echo "Directory contents:" && ls -la && \
67
  echo "MuseV directory contents:" && ls -la MuseV && \
68
  echo "Gradio scripts directory contents:" && ls -la MuseV/scripts/gradio && \
69
- echo "Python path:" && echo $PYTHONPATH
 
70
 
71
  EXPOSE 7860
72
 
 
45
 
46
  # Clone and set up MuseV with exact case
47
  RUN git clone https://github.com/TMElyralab/MuseV.git && \
48
+ mv MuseV musev_temp && \
49
+ mv musev_temp 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
+ cp -r scripts/gradio/* ../ && \
57
+ chmod +x ../gradio_*.py
 
58
 
59
  # Set up Python path
60
  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"
 
67
  echo "Directory contents:" && ls -la && \
68
  echo "MuseV directory contents:" && ls -la MuseV && \
69
  echo "Gradio scripts directory contents:" && ls -la MuseV/scripts/gradio && \
70
+ echo "Python path:" && echo $PYTHONPATH && \
71
+ echo "Checking gradio scripts:" && ls -la gradio_*.py
72
 
73
  EXPOSE 7860
74
 
app.py CHANGED
@@ -16,7 +16,16 @@ print("Starting application...")
16
  # Set up paths
17
  ProjectDir = os.path.dirname(os.path.abspath(__file__))
18
  CheckpointsDir = os.path.join(ProjectDir, "checkpoints")
19
- MuseVDir = os.path.join(ProjectDir, "MuseV") # Note the capital V
 
 
 
 
 
 
 
 
 
20
  GradioScriptsDir = os.path.join(MuseVDir, "scripts", "gradio")
21
 
22
  print(f"Project directory: {ProjectDir}")
@@ -65,7 +74,7 @@ for path in sys.path:
65
 
66
  print("Attempting to import gradio modules...")
67
 
68
- # First check if the files exist
69
  print("Checking for gradio module files...")
70
  video2video_path = os.path.join(ProjectDir, "gradio_video2video.py")
71
  text2video_path = os.path.join(ProjectDir, "gradio_text2video.py")
@@ -82,36 +91,33 @@ if os.path.exists(text2video_path):
82
  else:
83
  print(f"Warning: text2video not found at {text2video_path}")
84
 
 
85
  try:
86
- from gradio_video2video import online_v2v_inference
87
- print("Successfully imported video2video")
 
 
 
88
  except Exception as e:
89
- print(f"Error importing video2video: {str(e)}")
90
- print(f"Current directory: {os.getcwd()}")
91
- print(f"Directory contents: {os.listdir('.')}")
92
- if os.path.exists(GradioScriptsDir):
93
- print(f"Gradio scripts directory contents: {os.listdir(GradioScriptsDir)}")
94
-
95
- try:
96
- from gradio_text2video import online_t2v_inference
97
- print("Successfully imported text2video")
98
- except Exception as e:
99
- print(f"Error importing text2video: {str(e)}")
100
- print("Attempting to import directly from MuseV...")
101
  try:
102
  sys.path.insert(0, os.path.join(MuseVDir, "scripts", "gradio"))
 
103
  from gradio_text2video import online_t2v_inference
104
- print("Successfully imported text2video from MuseV directory")
105
  except Exception as e2:
106
  print(f"Error importing from MuseV directory: {str(e2)}")
 
 
 
 
 
 
107
 
108
  ignore_video2video = False
109
  max_image_edge = 1280
110
 
111
- if 'online_t2v_inference' not in locals():
112
- print("ERROR: Failed to import online_t2v_inference. Cannot continue.")
113
- sys.exit(1)
114
-
115
  print("Setting up Gradio interface...")
116
  demo = gr.Interface(
117
  fn=online_t2v_inference,
 
16
  # Set up paths
17
  ProjectDir = os.path.dirname(os.path.abspath(__file__))
18
  CheckpointsDir = os.path.join(ProjectDir, "checkpoints")
19
+
20
+ # Look for MuseV directory with either case
21
+ if os.path.exists(os.path.join(ProjectDir, "MuseV")):
22
+ MuseVDir = os.path.join(ProjectDir, "MuseV")
23
+ elif os.path.exists(os.path.join(ProjectDir, "musev")):
24
+ MuseVDir = os.path.join(ProjectDir, "musev")
25
+ else:
26
+ print("Error: Could not find MuseV directory")
27
+ sys.exit(1)
28
+
29
  GradioScriptsDir = os.path.join(MuseVDir, "scripts", "gradio")
30
 
31
  print(f"Project directory: {ProjectDir}")
 
74
 
75
  print("Attempting to import gradio modules...")
76
 
77
+ # First check if the files exist in the current directory
78
  print("Checking for gradio module files...")
79
  video2video_path = os.path.join(ProjectDir, "gradio_video2video.py")
80
  text2video_path = os.path.join(ProjectDir, "gradio_text2video.py")
 
91
  else:
92
  print(f"Warning: text2video not found at {text2video_path}")
93
 
94
+ # Try importing from current directory first
95
  try:
96
+ import gradio_video2video
97
+ import gradio_text2video
98
+ online_v2v_inference = gradio_video2video.online_v2v_inference
99
+ online_t2v_inference = gradio_text2video.online_t2v_inference
100
+ print("Successfully imported gradio modules from current directory")
101
  except Exception as e:
102
+ print(f"Error importing from current directory: {str(e)}")
103
+ print("Attempting to import from MuseV directory...")
 
 
 
 
 
 
 
 
 
 
104
  try:
105
  sys.path.insert(0, os.path.join(MuseVDir, "scripts", "gradio"))
106
+ from gradio_video2video import online_v2v_inference
107
  from gradio_text2video import online_t2v_inference
108
+ print("Successfully imported from MuseV directory")
109
  except Exception as e2:
110
  print(f"Error importing from MuseV directory: {str(e2)}")
111
+ print("Current directory contents:")
112
+ print(os.listdir('.'))
113
+ if os.path.exists(GradioScriptsDir):
114
+ print("Gradio scripts directory contents:")
115
+ print(os.listdir(GradioScriptsDir))
116
+ sys.exit(1)
117
 
118
  ignore_video2video = False
119
  max_image_edge = 1280
120
 
 
 
 
 
121
  print("Setting up Gradio interface...")
122
  demo = gr.Interface(
123
  fn=online_t2v_inference,