From ea1ea655c69e15f1244f96c2a73a923f6813befd Mon Sep 17 00:00:00 2001 From: Realcat Date: Sun, 6 Oct 2024 00:52:33 +0800 Subject: [PATCH] update: api (#82) * update: api * add: netlify.toml * update: env --- .gitignore | 1 + Dockerfile | 2 +- api/client.py | 14 ++++++++++---- netlify.toml | 15 +++++++++++++++ package.json | 5 ----- vercel.json | 14 -------------- 6 files changed, 27 insertions(+), 24 deletions(-) create mode 100644 netlify.toml delete mode 100644 package.json delete mode 100644 vercel.json diff --git a/.gitignore b/.gitignore index 0cface3..3d16992 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ gen_example.py datasets/lines/terrace0.JPG datasets/lines/terrace1.JPG datasets/South-Building* +*.pkl diff --git a/Dockerfile b/Dockerfile index 7455862..09fd374 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ RUN apt-get update && apt-get install -y git-lfs RUN git lfs install # Clone the Git repository -RUN git clone https://huggingface.co/spaces/Realcat/image-matching-webui /code +RUN git clone --recursive https://github.com/Vincentqyw/image-matching-webui.git /code RUN conda create -n imw python=${PYTHON_VERSION} RUN echo "source activate imw" > ~/.bashrc diff --git a/api/client.py b/api/client.py index 2d1313b..c357642 100644 --- a/api/client.py +++ b/api/client.py @@ -1,15 +1,21 @@ +import os import argparse import pickle import time from typing import Dict - import numpy as np import requests from loguru import logger -API_URL_MATCH = "http://127.0.0.1:8001/v1/match" -API_URL_EXTRACT = "http://127.0.0.1:8001/v1/extract" -API_URL_EXTRACT_V2 = "http://127.0.0.1:8001/v2/extract" +URL = "http://127.0.0.1:8001" +if "REMOTE_URL_RAILWAY" in os.environ: + URL = os.environ["REMOTE_URL_RAILWAY"] + +logger.info(f"API URL: {URL}") + +API_URL_MATCH = f"{URL}/v1/match" +API_URL_EXTRACT = f"{URL}/v1/extract" +API_URL_EXTRACT_V2 = f"{URL}/v2/extract" def send_generate_request(path0: str, path1: str) -> Dict[str, np.ndarray]: diff --git a/netlify.toml b/netlify.toml new file mode 100644 index 0000000..c93d2eb --- /dev/null +++ b/netlify.toml @@ -0,0 +1,15 @@ +[build] + command = """ + git clone --recursive https://github.com/Vincentqyw/image-matching-webui.git && + pip install -r requirements.txt && + python server.py +""" + publish = "." + +[context.production.environment] + PYTHON_VERSION = "3.10" + +[[redirects]] + from = "/*" + to = "/index.html" + status = 200 diff --git a/package.json b/package.json deleted file mode 100644 index de76041..0000000 --- a/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "engines": { - "node": "18.x" - } -} \ No newline at end of file diff --git a/vercel.json b/vercel.json deleted file mode 100644 index 20b7ff2..0000000 --- a/vercel.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "builds": [ - { - "src": "server.py", - "use": "@vercel/python" - } - ], - "routes": [ - { - "src": "/(.*)", - "dest": "server.py" - } - ] - } \ No newline at end of file