Remy commited on
Commit
d4d231e
·
verified ·
1 Parent(s): 28f5782

Update ActionMesh space

Browse files
Files changed (2) hide show
  1. README.md +0 -2
  2. app.py +24 -19
README.md CHANGED
@@ -8,9 +8,7 @@ sdk_version: 6.3.0
8
  app_file: app.py
9
  pinned: true
10
  license: other
11
- models: [facebook/ActionMesh]
12
  short_description: Generate animated 3D meshes from video
13
- tags: [video-to-4D]
14
  ---
15
 
16
  ```
 
8
  app_file: app.py
9
  pinned: true
10
  license: other
 
11
  short_description: Generate animated 3D meshes from video
 
12
  ---
13
 
14
  ```
app.py CHANGED
@@ -42,8 +42,9 @@ def setup_blender() -> Path:
42
  """
43
  Download and setup Blender 3.5.1 for Linux x64.
44
 
45
- Downloads Blender from the official release page if not already present,
46
- extracts it, and returns the path to the blender executable.
 
47
 
48
  Returns:
49
  Path to the blender executable.
@@ -53,8 +54,11 @@ def setup_blender() -> Path:
53
 
54
  # Define paths
55
  repo_dir = Path(__file__).parent.parent
 
56
  third_party_dir = repo_dir / "third_party"
57
- blender_archive = third_party_dir / "blender-3.5.1-linux-x64.tar.xz"
 
 
58
  blender_dir = third_party_dir / "blender-3.5.1-linux-x64"
59
  blender_executable = blender_dir / "blender"
60
 
@@ -66,25 +70,32 @@ def setup_blender() -> Path:
66
  print(f"Blender already installed at {blender_executable}")
67
  return blender_executable
68
 
69
- # Download URL
70
- blender_url = (
71
- "https://download.blender.org/release/Blender3.5/"
72
- "blender-3.5.1-linux-x64.tar.xz"
73
- )
74
 
75
- # Download Blender if archive doesn't exist
76
- if not blender_archive.exists():
 
 
 
 
 
 
 
 
 
77
  print(f"Downloading Blender from {blender_url}...")
78
  try:
79
  urllib.request.urlretrieve(blender_url, blender_archive)
80
  print("Blender downloaded successfully.")
 
81
  except Exception as e:
82
  raise RuntimeError(f"Failed to download Blender: {e}")
83
 
84
  # Extract the archive
85
- print(f"Extracting Blender to {third_party_dir}...")
86
  try:
87
- with tarfile.open(blender_archive, "r:xz") as tar:
88
  tar.extractall(path=third_party_dir)
89
  print("Blender extracted successfully.")
90
  except Exception as e:
@@ -93,16 +104,10 @@ def setup_blender() -> Path:
93
  shutil.rmtree(blender_dir)
94
  raise RuntimeError(f"Failed to extract Blender: {e}")
95
 
96
- # Optionally remove the archive to save space
97
- if blender_archive.exists():
98
- blender_archive.unlink()
99
- print("Removed Blender archive to save space.")
100
 
101
  # Verify installation
102
  if not blender_executable.exists():
103
- raise RuntimeError(
104
- f"Blender executable not found at expected path: " f"{blender_executable}"
105
- )
106
 
107
  print(f"Blender installed successfully at {blender_executable}")
108
  return blender_executable
 
42
  """
43
  Download and setup Blender 3.5.1 for Linux x64.
44
 
45
+ First checks if the Blender archive exists in the home directory.
46
+ If found, extracts it from there. Otherwise, downloads from the
47
+ official release page. Returns the path to the blender executable.
48
 
49
  Returns:
50
  Path to the blender executable.
 
54
 
55
  # Define paths
56
  repo_dir = Path(__file__).parent.parent
57
+ demo_dir = Path(__file__).parent
58
  third_party_dir = repo_dir / "third_party"
59
+ blender_archive_name = "blender-3.5.1-linux-x64.tar.xz"
60
+ blender_archive = third_party_dir / blender_archive_name
61
+ local_blender_archive = demo_dir / blender_archive_name
62
  blender_dir = third_party_dir / "blender-3.5.1-linux-x64"
63
  blender_executable = blender_dir / "blender"
64
 
 
70
  print(f"Blender already installed at {blender_executable}")
71
  return blender_executable
72
 
73
+ # Determine which archive to use for extraction
74
+ archive_to_extract = None
 
 
 
75
 
76
+ if local_blender_archive.exists():
77
+ print(f"Found Blender archive at: {local_blender_archive}")
78
+ archive_to_extract = local_blender_archive
79
+ elif blender_archive.exists():
80
+ archive_to_extract = blender_archive
81
+ else:
82
+ # Download URL
83
+ blender_url = (
84
+ "https://download.blender.org/release/Blender3.5/"
85
+ "blender-3.5.1-linux-x64.tar.xz"
86
+ )
87
  print(f"Downloading Blender from {blender_url}...")
88
  try:
89
  urllib.request.urlretrieve(blender_url, blender_archive)
90
  print("Blender downloaded successfully.")
91
+ archive_to_extract = blender_archive
92
  except Exception as e:
93
  raise RuntimeError(f"Failed to download Blender: {e}")
94
 
95
  # Extract the archive
96
+ print(f"Extracting Blender from {archive_to_extract}...")
97
  try:
98
+ with tarfile.open(archive_to_extract, "r:xz") as tar:
99
  tar.extractall(path=third_party_dir)
100
  print("Blender extracted successfully.")
101
  except Exception as e:
 
104
  shutil.rmtree(blender_dir)
105
  raise RuntimeError(f"Failed to extract Blender: {e}")
106
 
 
 
 
 
107
 
108
  # Verify installation
109
  if not blender_executable.exists():
110
+ raise RuntimeError(f"Blender executable not found: {blender_executable}")
 
 
111
 
112
  print(f"Blender installed successfully at {blender_executable}")
113
  return blender_executable