Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import os
|
|
2 |
import subprocess
|
3 |
from huggingface_hub import login
|
4 |
|
|
|
5 |
def clone_and_initialize_repo(repo_url, target_dir):
|
6 |
"""
|
7 |
Clone a GitHub repository using a personal access token and initialize submodules.
|
@@ -52,6 +53,7 @@ def huggingface_login():
|
|
52 |
print(f"Error during Hugging Face login: {e}")
|
53 |
raise
|
54 |
|
|
|
55 |
def start_gradio_demo():
|
56 |
"""
|
57 |
Start the Gradio demo.
|
@@ -64,6 +66,34 @@ def start_gradio_demo():
|
|
64 |
raise
|
65 |
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
def main():
|
68 |
"""
|
69 |
Main function to perform all operations.
|
@@ -72,10 +102,16 @@ def main():
|
|
72 |
repo_url = "https://github.com/dadwadw233/BoxDreamer.git"
|
73 |
target_dir = "./BoxDreamer"
|
74 |
|
|
|
|
|
|
|
75 |
try:
|
76 |
# Clone the repository and initialize submodules
|
77 |
clone_and_initialize_repo(repo_url, target_dir)
|
78 |
|
|
|
|
|
|
|
79 |
# Log in to Hugging Face
|
80 |
huggingface_login()
|
81 |
|
|
|
2 |
import subprocess
|
3 |
from huggingface_hub import login
|
4 |
|
5 |
+
|
6 |
def clone_and_initialize_repo(repo_url, target_dir):
|
7 |
"""
|
8 |
Clone a GitHub repository using a personal access token and initialize submodules.
|
|
|
53 |
print(f"Error during Hugging Face login: {e}")
|
54 |
raise
|
55 |
|
56 |
+
|
57 |
def start_gradio_demo():
|
58 |
"""
|
59 |
Start the Gradio demo.
|
|
|
66 |
raise
|
67 |
|
68 |
|
69 |
+
def modify_file(file_path):
|
70 |
+
"""
|
71 |
+
Modify specific lines in a file.
|
72 |
+
|
73 |
+
Replace lines 107 and 108 with `raise ImportError`.
|
74 |
+
"""
|
75 |
+
try:
|
76 |
+
# Read the file contents
|
77 |
+
with open(file_path, "r") as file:
|
78 |
+
lines = file.readlines()
|
79 |
+
|
80 |
+
# Modify the specified lines
|
81 |
+
lines[106] = "raise ImportError\n" # Line 107 (index starts at 0)
|
82 |
+
lines[107] = "" # Line 108, replace with an empty line or remove it
|
83 |
+
|
84 |
+
# Write the modified lines back to the file
|
85 |
+
with open(file_path, "w") as file:
|
86 |
+
file.writelines(lines)
|
87 |
+
|
88 |
+
print(f"File {file_path} modified successfully: lines 107 and 108 replaced.")
|
89 |
+
except FileNotFoundError:
|
90 |
+
print(f"Error: File {file_path} not found.")
|
91 |
+
raise
|
92 |
+
except Exception as e:
|
93 |
+
print(f"Error modifying file {file_path}: {e}")
|
94 |
+
raise
|
95 |
+
|
96 |
+
|
97 |
def main():
|
98 |
"""
|
99 |
Main function to perform all operations.
|
|
|
102 |
repo_url = "https://github.com/dadwadw233/BoxDreamer.git"
|
103 |
target_dir = "./BoxDreamer"
|
104 |
|
105 |
+
# Define the file to be modified
|
106 |
+
file_to_modify = "./BoxDreamer/three/dust3r/croco/models/pos_embed.py"
|
107 |
+
|
108 |
try:
|
109 |
# Clone the repository and initialize submodules
|
110 |
clone_and_initialize_repo(repo_url, target_dir)
|
111 |
|
112 |
+
# Modify the specified file
|
113 |
+
modify_file(file_to_modify)
|
114 |
+
|
115 |
# Log in to Hugging Face
|
116 |
huggingface_login()
|
117 |
|