Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,8 +10,7 @@ sys.path.insert(0, "/tmp/HorizonNet")
|
|
| 10 |
|
| 11 |
from huggingface_hub import hf_hub_download
|
| 12 |
|
| 13 |
-
|
| 14 |
-
CKPT = hf_hub_download(repo_id="gum-tech/horizonnet-resnet50-rnn", filename="resnet50_rnn__st3d.pth")
|
| 15 |
print(f"Model checkpoint at: {CKPT}")
|
| 16 |
|
| 17 |
def predict(image):
|
|
@@ -29,13 +28,18 @@ def predict(image):
|
|
| 29 |
image.convert("RGB").resize((1024, 512)).save(img_path)
|
| 30 |
|
| 31 |
# ββ Step 1: Preprocess (camera alignment) βββββββββββββββββ
|
| 32 |
-
|
| 33 |
f"cd /tmp/HorizonNet && python preprocess.py "
|
| 34 |
f"--img_glob {img_path} "
|
| 35 |
-
f"--output_dir /tmp/hn_pre"
|
|
|
|
| 36 |
)
|
| 37 |
-
if
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
# Find aligned image output
|
| 41 |
aligned = glob.glob("/tmp/hn_pre/*_aligned_rgb.png")
|
|
|
|
| 10 |
|
| 11 |
from huggingface_hub import hf_hub_download
|
| 12 |
|
| 13 |
+
CKPT = hf_hub_download(repo_id="gum-tech/horizonnet-resnet50-rnn", filename="resnet50_rnn.pth")
|
|
|
|
| 14 |
print(f"Model checkpoint at: {CKPT}")
|
| 15 |
|
| 16 |
def predict(image):
|
|
|
|
| 28 |
image.convert("RGB").resize((1024, 512)).save(img_path)
|
| 29 |
|
| 30 |
# ββ Step 1: Preprocess (camera alignment) βββββββββββββββββ
|
| 31 |
+
os.system(
|
| 32 |
f"cd /tmp/HorizonNet && python preprocess.py "
|
| 33 |
f"--img_glob {img_path} "
|
| 34 |
+
f"--output_dir /tmp/hn_pre "
|
| 35 |
+
f"> /tmp/hn_pre/preprocess_log.txt 2>&1"
|
| 36 |
)
|
| 37 |
+
log = open("/tmp/hn_pre/preprocess_log.txt").read() if os.path.exists("/tmp/hn_pre/preprocess_log.txt") else "no log file"
|
| 38 |
+
print("=== preprocess log ===\n", log, "\n======================")
|
| 39 |
+
|
| 40 |
+
aligned = glob.glob("/tmp/hn_pre/*_aligned_rgb.png")
|
| 41 |
+
if not aligned:
|
| 42 |
+
return json.dumps({"error": "Preprocessing failed", "log": log})
|
| 43 |
|
| 44 |
# Find aligned image output
|
| 45 |
aligned = glob.glob("/tmp/hn_pre/*_aligned_rgb.png")
|